enter image description hereenter image description here我无法在我的移动应用程序中使用appium找到使用任何定位器的元素,请查看下面附带的屏幕截图和我的代码
driver.findElementById("serviceUrl").sendKeys("ABC");
driver.findElementByClassName("android.widget.Button").click();
Appium服务器响应
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug]从客户端获取数据:{“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector” “:”// [@ class ='android.widget.EditText']“,”context“:”“,”multiple“:false}} [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug]获取类型命令ACTION [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug]得到命令动作:find [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug]查找'//[@class='android.widget.EditText']'使用带有contextId的'XPATH':''multiple:false [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug]找不到元素。清除辅助功能缓存并重试。 [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug]查找'//* [@class='android.widget.EditText']'使用'XPATH'和contextId:''multiple:false [debug] [AndroidBootstrap]从bootstrap接收命令结果[debug] [MJSONWP]匹配的JSONWP错误代码7到NoSuchElementError
你可以试试这个:
driver.findElement(By.id("serviceUrl")).sendKeys("ABC");
而不是这个
driver.findElementById("serviceUrl").sendKeys("ABC");
试试这个。
driver.findElementByClassName("android.widget.EditText").sendKeys("ABC");
正如OP建议你也可以试试xapth
。
driver.findElementByxpath("//*[@resource-id='serviceUrl']").sendKeys("ABC");
要么
driver.findElementByxpath("//*[@class='android.widget.EditText']").sendKeys("ABC");