Appium: The item cannot be found using Xpath in hybrid Android apps.

I am trying to automate a hybrid application using appium.i by developing my application using the Ionic Framework. I completed the full customization ready.then, I tried to find the elements that verify the use firebug in Mozilla.i, where xpath specific button - //Button[text()='BROWSE MENU'].

but when I try to test it with appium, it cannot find it, my test failed.

I tried something like this in my test

driver.findElement(By.xpath("//button[text()='BROWSE MENU']")).click();

this is the error i get on the console

FAILED: Loginforsample
org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 5.13 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html

this is an inspector enter image description here

, . WEB_VIEW , , . , . , , , .

.

+4
3

, cssSelector !

+2

Explicit wait :

//driver.switchTo().frame("put_iframe_id_or_name_here");  //to switch to iframe
WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//button[text()='BROWSE MENU']")));
element.click();
//driver.switchTo().defaultContent();  //to switch back if required
+2

10 [Thread.sleep(10000);] . , cssSelector.

+1

Source: https://habr.com/ru/post/1664540/


All Articles