Xpath与css定位方式:
1.Xpath绝对路径定位
1.绝对路径定位:一般不用
2.Xpath相对路径定位
2.相对路径定位:xpath=//form/span/input
rebotframework:
在input标签下
3.Xpath元素属性定位
xpath=//input[@autocomplete=“off”]或
xpath=//input[@autocomplete=“off” and @class=“s_ipt”]
rebotframework:
在input标签下
4.Xpath部分属性定位
xpath=//input[contains(@autocomplete,“of”)]
rebotframework:
在input标签下
5.Xpath文本定位
xpath=//a[text()=“新闻”]
rebotframework:
在a标签下
6.css通过绝对路径定位
css通过绝对路径定位几乎不用
7.css通过id或class定位
#id
.class
8.css通过元素属性定位
css=input[autocomplete=“off”]或者
input[autocomplete=“off”] [class=“s_ipt”]
9.通过部分属性定位
9.1以of开头
css=input[autocomplete^=“of”]
9.2包含of
css=input[autocomplete*=“of”]
10.通过文本进行定位
例如定位地图(div底下第三个元素)
css=div#s-top-left a:nth-child(3)