I trying to automate a hybrid app using the appium.i had developed my app using Ionic Framework. i had completed the total setup ready.then i tried to find the elements inspecting using firebug in Mozilla.i found the xpath of a particular button is //Button[text()='BROWSE MENU']
.
but when i try to test it using appium it is unable to find it , my test got failed.
driver.findElement(By.xpath("//button[text()='BROWSE MENU']")).click();
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 inspector
i didn't know where exactly i am going wrong. initially i tried WEB_VIEW to inspect in chrome then i noticed that ionic has an advantage of direct inspecting using ionic serve. so i simply shifted to that and again i got struct here. please help me guys to this issue for me.
thanks in advance.
I use to have this problem so i have used cssSelector
it's a good way for testing hybrid apps !
Try to add Explicit wait
to your code:
//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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With