通过 Appium Inspector 我能够找到元素,但在运行脚本时出现以下错误: 失败:org.TsApp.B004_passenger_search.PassengerSearchName org.openqa.selenium.NoSuchElementException:使用给定的搜索参数无法在页面上找到元素。 有关此错误的文档,请访问:https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception 构建信息:版本:'4.16.1',修订版:'9b4c83354e' 系统信息:os.name:'Linux',os.arch:'amd64',os.version:'5.14.0-1059-oem',java.version:'17.0.9' 驱动程序信息:io.appium.java_client.android.AndroidDriver 命令:[c0263d75-e56d-4648-8578-4ef969c810dc, findElement {using=xpath, value=//android.widget.TextView[@text='PNR 搜索']}]
我尝试使用 id 和 Xpath 但给出了相同的错误。 X路径:driver.findElement(By.xpath("//android.widget.TextView[@text='PNR Search']")).click();
使用下面的xpath //android.widget.TextView[contains(@text,'PNR 搜索')]