1、xpath元素定位
1)ele = b.find_element_by_xpath(『/html/body/from/input[1]』)
2)ele = b.find_element_by_xpath(『//input[2]』) 定位第二個input
3)ele = b.find_element_by_xpath(『//from//input』) 定位from裡面的
input
4)ele = b.find_element_by_xpath(『//input[@id]』) 定位input裡面含有
id5)ele = b.find_element_by_xpath(『//input[@name=」firstname」]』)
6)ele = b.find_element_by_xpath(『//*[count(input)=2]』) 定位具有兩個input的元素(
*為所有元素)
7)ele = b.find_element_by_xpath(『//*[count(input)=2/..]』)定位具有兩個
input
的元素的父節點
8)ele = b.find_element_by_xpath(『//*[local-name()=」input」]』)定位標籤為
input
的元素9)ele.tag_name 顯示定位的標籤名稱
10)ele.get_attribute(『name』) 顯示定位到的屬性名稱
11)ele = b.find_element_by_xpath(『//*[starts-with(local-name(),」i」)]』)定位所有
tag以
i開頭的元素
12)ele = b.find_element_by_xpath(『//*[contains(local-name(),」i」)]』)定位所有
tag包含
i的元素
13)ele = b.find_element_by_xpath(『//from//*[contains(local-name(),」i」)]』)定位在
from
裡面所有
tag包含
i的元素
14)ele = b.find_element_by_xpath(『//from//*[contains(local-name(),」i」)][last()]』)定位在
from
裡面所有
tag包最後乙個含
i的元素
15)ele = b.find_element_by_xpath(『//from//*[contains(local-name(),」i」)][last()-1]』)定位在
from
裡面所有
tag包倒數第二個含
i的元素
16)ele = b.find_element_by_xpath(『//*[string-length(local-name())=5]』)定位所有
tag裡面長度為
5的元素
17)ele = b.find_element_by_xpath(『//title | //input』) 多個路徑查詢
python自動化測試 元素定位
input id qcreatetask class placeholder italic placeholder 提交 通過id定位 driver.find element by.id,qcreatetask 通過css定位 driver.find element by.css selector,...
UI自動化元素定位
1.id定位 find element by id self,id 2.name定位 find element by name self,name 3.class定位 find element by class name self,name 4.tag定位 find element by tag n...
web自動化 元素定位
x 和 都是chrome開發者工具提供的方法定位元素的時候 根據自己的需求定位到唯一 的乙個元素或者符合自己需要的一組元素。絕對路徑 html開頭表示,從html文件的根節點開始進行查詢,直到找到想要的元素 相對路徑 開頭,表示從html文件的任意位置進行查詢,如果在表示式中間出現77表示從 之前的...