1.安装View XPath工具(XPath checker);

 

  • 1. 索引[x]  
    • //div/input[2]  表示:div下面第二个input
  • postion()=2  postion()>3  postion<5
  • last()  last()-1
  • 属性定位 @class  例如://div[@class]  表示:有 class属性的div

 

功能关键字:

  •     and/[][] , or ,  not  ,  contains  ,  starts-with  ,   
  • 通配符 *     //span[@* = 'bruce']  //*[@*='bruce']
  • parent  父节点
  • ancestor  祖先节点,包括父节点,层级向上;
  • descendant (即://)   表示所有子孙节点  //div[@class='123']//input
  • following-sibling  表示当前元素后面同级下的所有节点
  • preceding-sibling  表示元素前面同级下的所有节点

XPATH函数:

starts-with()    //img[starts-with(@alt, 'div')]

contains()     //img[contains(@alt, 'gl')]

测试进阶 - selenium之XPATH笔记

 

 

 

相关文章:

  • 2021-07-06
  • 2021-07-26
  • 2022-12-23
  • 2021-12-12
  • 2021-04-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-04
  • 2022-02-15
  • 2021-09-16
  • 2022-01-12
  • 2022-12-23
相关资源
相似解决方案