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


背景

使用Appium Server 1.15.1版本

執行了以下腳本

test = driver.find_element_by_name("自動化測試")
print(test.text)

報了以下錯誤

 

圈重點

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】,最終發現也是沒用的,這里就不展開了~還是換個定位方式叭!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM