I had developed a hybrid app using ionic framework . Now its time to test my app, so I had choose appium to Automate it. I had kept appium setup ready and my app is installed in my device is connected through usb.
I had written a sample test to chick the login button and send keys to the required fields like email and pwd. I had use uiautomatorviewer to find my elements with id.
eg: driver.findElement(By.id("io.mysoft.testapp:id/login")).click();
Everything is clear and perfect up to now but my sample test failed showing me errors like
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.51 seconds
After a long research I came to know that we have to switch to WEB_VIEW in the testing logic by driver.context("WEB_VIEW");
. I also tried to get WEB_VIEW using following code:
Set<String> contextNames = ((AppiumDriver) driver).getContextHandles();
for (String contextName : contextNames) {
System.out.println("FIRST" + contextNames);//output is //NATIV_APP
((AppiumDriver) driver).context(contextName);
}
I am getting only NATIV_APP form the array but no WEB_VIEW printed. I have researched on that to enable WEB_VIEW debugging we have to call the static method setWebContentsDebuggingEnabled
on the webView Class so that our will be on webView to find elements and test it clear.
I am an angular developer I choose ionic to develop hybrid apps. There is no classes or anything in my app ie no java here while coding. And the question that eats my brain is how to enable setWebContentsDebuggingEnabled
in my ionic app(hybrid)? is there any way to get the web_view from ionic hybrid apps? I think this is the main reason for my test got failed. Please please any one has a solution on that. I had been working on that for the past one week.
Thanks in advance.