Я пытался автоматизировать сценарии для Android приложения с помощью uiautomatorviewer и управлением appium версии 1.6.3, рамочное TestNGНе удалось найти элемент с uiautomatorviewer и appium
Вот мой код, все элемент хорошо найден, но только последний с индексом = 2, это видно на uiautomatorviewer (см. рисунок ) Все элементы с индексом 0 и 1 находятся в порядке! только последний. Я использую ту же логику, просто изменяя индекс с 2
@Test(priority = 1)
public void SignIn() throws InterruptedException {
System.out.println("newlook-tutoriel");
/*
* boolean ispresent = driver.findElement(By.id("skip")).isDisplayed();
* if (ispresent == true) { driver.findElement(By.id("skip")).click();
* System.out.println("Tutorials are present"+ispresent); } else
* System.err.println("Tutorials aren't present ! "+ispresent);
*/
System.out.println("newlook-welcome");
driver.findElement(By.id("btn_signin_welcome")).click();
System.out.println("newlook-Me connecter");
driver.findElement(By.id("input_email")).sendKeys(
"[email protected]");
System.out.println(driver.findElement(By.id("input_password"))
.getClass());
// Thread.sleep(5000);
driver.hideKeyboard();
driver.findElement(By.id("input_password")).sendKeys("00000000");
// Thread.sleep(5000);
driver.hideKeyboard();
driver.findElement(By.id("btn_signin")).click();
Thread.sleep(5000);
System.out.println("connected !!!!");
System.out.println(driver.findElement(By.xpath(".//@class='android.widget.TextView'")).getText());
System.out.println("Bienvenue"+driver.findElement(By.xpath("//*[@class='android.widget.TextView' and @index='0']")).getText());
System.out.println("Emna"+driver.findElement(By.xpath("//*[@class='android.widget.TextView' and @index='1']")).getText());
System.out.println("répondez....." + driver.findElement(By.xpath("//*[@class='android.widget.TextView' and @index='2']")).getText());
driver.findElement(By.xpath("//*[@class='android.widget.Button']")).click();
}
Здесь appium войти
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//*[@class='android.widget.TextView' and @index='2']","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//*[@class='android.widget.TextView' and @index='2']","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '//*[@class='android.widget.TextView' and @index='2']' using 'XPATH' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"Could not find an element using supplied strategy. "}
Вы пытались найти элемент по тексту? – Vinod
Нет такой команды в данном списке – Emna
Вы можете найти элемент по тексту, если он недоступен через индекс, id, имя_файла и т. Д. – Vinod