XPath编写规则学习
辅助工具:firefox安装findbugs,view Xpath
firefox :Xpath验证方式:$x("xpath"); 粘贴xpath语句回车即可
定位:
1、依靠自己属性,文本定位:
//td[text()='test']
//div[contains(@class,'test')]
//input[@type='radio' and @value='1']
//span[@name='bruce' and text()='bruce2'] 或 //span[@name='bruce'][ text()='bruce2'] --and关键字
//span[@name='bruce' or text()='bruce2'] --or关键字
2、依靠父节点定位:
//div[@class='test mytest']/div
//div[@id='test']/div
3、依靠子节点定位
//div[div[@id='test']] --寻找含有id=test的div的div