Most of engineers started to learn mobile automation with Appium. This is the most popular framework for mobile automation testing and I think that everybody agree with this. But sometimes it’s not enough to have only Appium, especially if we want to test native Android application with only WebView container inside. Appium cannot recognise elements in WebView container.
What to do in this case? Some test engineers decided to postpone with automation. But in reality this automation is even much easier than testing of native application with native controls.
How WebView container works? It’s loading mobile version of web site into custom WebView form. It means that we can easy inspect elements with Chrome or Firefox inspector.
But how to say Appium to search for elements exactly in this WebView? Many of You guys heard that need to switch context. But what if You run Appium inspector and You see only 1 context called NATIVE_APP ? In this case You need to switch Appium to Selendroid mode. For UI Appium inspector this is here:
After this You will see that You have more contexts than only NATIVE_APP, but also 1 or more WEBVIEW contexts. The next step is switching to correct context (for example):
And that’s all. Now You can easy use the same methods like for Selenium WebDriver to navigate and click.
Also, You can use method .get(“url”) to easy navigate to any pages without clicking on UI.
Hope it will help You to solve some issues and start automation of hybrid apps.
Thanks for reading my blog!
Have a good automation!