Selenium有几种常见定位方式?

  • id:根据id来获取元素,返回单个元素,id值一般是唯一的;
  • name:根据元素的name属性定位;
  • tagName:根据元素的标签名定位;
  • className:根据元素的样式class值定位;
  • linkText:根据超链接的文本值定位;
  • partiaLinkText:根据超链接的部分文本值定位;
  • cssSekector:css选择器定位;
  • xpath:通过元素的路径、属性定位。

其中xpath和css定位都比较强大,在自动化中使用较多。

posted @ 2022-01-11 17:43  两三颗啤酒味的星☆~  阅读(79)  评论(0)    收藏  举报