2014-03-06 6 views
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 안드로이드 윈도우 : 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 (""))가 작동하지 않는 이유는 무엇입니까?

답변

0

Appium Inspector를 사용하여 확인 -> 'password'필드에 액세스 할 때 "password"로 설정된 이름 값이 없을 수 있습니다. Appium 관리자를 사용하여 XPath는 다른 특성을 얻을 수

WebElement password = driver.findElement(By.xpath("//window[1]/scrollview[1]/secure[1]")); 
    password.click(); 
    password.sendKeys("psswrd"); 

팔로우 다음 단계 :

하는 대신 같은 XPath를 사용하여 요소에 액세스 해보세요

[1] Launch Appium server. 
[2] Check the check box 'App Path'. 
[3] Click on the 'Choose' button and select your .app file location from your local, e.g. xyz.app 
[4] Now click on the 'Launch' button . Once appium server is launched, the blue color icon besides the 'Launch' button is enabled. 
[5] Click on the blue color icon, it will open up the appium inspector and simulator with your application : 

enter image description here

당신은 요소의 계층 구조를 볼 수 있습니다 이름, xPath, 값 등의 속성을 표시하는 앱의 이름입니다.

+0

"// [1]/window [1]/scrollview [1]/secure [1]"경로는 어떻게됩니까? @Smriti – Tarumoy

+0

위의 내 의견을 편집하고 Appium Inspector를 실행하고 속성을보기위한 단계를 언급했습니다. – Smriti

+0

이것은 나쁜 습관입니다. 레이아웃을 조금만 변경해도 테스트가 중단됩니다! 여기에 className과 text를 사용하십시오. http://stackoverflow.com/questions/22142219/can-we-find-element-by-id-in-appium – Shirane85