2
WebElement username=driver.findElement(By.name("username"));
username.sendKeys("test");
WebElement password=driver.findElement(By.name("password"));
password.sendKeys("test");
WebElement loginBtn=driver.findElement(By.name("Login"));
loginBtn.click();
WebElement backBtn=driver.findElement(By.tagName("Button"));
backBtn.click();
當我使用上述測試用例時,用戶名正在成功運行,但是當輸入密碼時顯示以下錯誤。Appium Android Windows:driver.findElement(By.name(「」))不能連續工作
debug: Appium request initiated at /wd/hub/session/71ed55ce-c3ae-46d8-9ce7-67452
0992c0a/element/1/value
debug: Request received with params: {"id":"1","value":["test"]}
info: Pushing command to appium work queue: ["element:setText",{"elementId":"1",
"text":"test"}]
info: [BOOTSTRAP] [info] Got data from client: {"cmd":"action","action":"element
:setText","params":{"elementId":"1","text":"test"}}
info: [BOOTSTRAP] [info] Got command of type ACTION
info: [BOOTSTRAP] [debug] Got command action: setText
info: [BOOTSTRAP] [info] Returning result: {"value":true,"status":0}
info: Responding to client with success: {"status":0,"value":true,"sessionId":"7
1ed55ce-c3ae-46d8-9ce7-674520992c0a"}
POST /wd/hub/session/71ed55ce-c3ae-46d8-9ce7-674520992c0a/element/1/value 200 26
53ms - 89b
debug: Appium request initiated at /wd/hub/session/71ed55ce-c3ae-46d8-9ce7-67452
0992c0a/element
debug: Request received with params: {"using":"name","value":"password"}
info: Pushing command to appium work queue: ["find",{"strategy":"name","selector
":"password","context":"","multiple":false}]
info: [BOOTSTRAP] [info] Got data from client: {"cmd":"action","action":"find","
params":{"strategy":"name","selector":"password","context":"","multiple":false}}
info: [BOOTSTRAP] [info] Got command of type ACTION
info: [BOOTSTRAP] [debug] Got command action: find
info: [BOOTSTRAP] [debug] Finding password using NAME with the contextId:
info: [BOOTSTRAP] [info] Returning result: {"value":"No element found","status":
7}
info: Responding to client with error: {"status":7,"value":{"message":"An elemen
t could not be located on the page using the given search parameters.","origValu
e":"No element found"},"sessionId":"71ed55ce-c3ae-46d8-9ce7-674520992c0a"}
POST /wd/hub/session/71ed55ce-c3ae-46d8-9ce7-674520992c0a/element 500 783ms - 22
3b
爲什麼findElement(By.name(「」))第二次不工作?
「// window [1]/scrollview [1]/secure [1]」這條路是怎麼來的? @Smriti – Tarumoy
我已經編輯了我上面的評論,並提到了啓動Appium Inspector並查看屬性的步驟。 – Smriti
這是不好的做法,佈局中的任何小改動都會打破你的測試!使用className和文本在這裏提到http://stackoverflow.com/questions/22142219/can-we-find-element-by-id-in-appium – Shirane85