背景

使用Appium Server 1.15.1版本

执行了以下脚本

test = driver.find_element_by_name("自动化测试")
print(test.text)

报了以下错误

Appium问题解决方案(5)- selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy 'name' is not supported for this session

 

圈重点

selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy 'name' is not supported for this session

简译:  by_name 这种定位元素方式已经不支持了

然后查了下资料,发现是在appium1.5之后, by_name 的这种定位方式已经彻底移除

 

解决方法一

最简单,不再用 by_name 定位方式了,改用id、class、xpath、accessibility id

 

解决方法二

看了网上的教程【driver.js】,最终发现也是没用的,这里就不展开了~还是换个定位方式叭!

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-04-23
  • 2021-04-07
  • 2021-07-23
  • 2022-12-23
  • 2021-09-15
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
  • 2022-01-21
  • 2021-10-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案