We can’t identify WebView elements by using UIAutomatorViewer insdie Android Sdk.
Appium Inspector is unable to capture the device screen in latest Appium.exe (1.4.0V) GUI (i don’t know whether it is a bug in latest Appium UI).
Did any one came across with the same scenario.? Please let me know what are the other ways to identify WebView elements in Android…!! Suggestions would be much appreciated.
WebView Means browser instance
So my statement holds true for HYBRID app also
until property is set WEBVIEW will never be detected by appium
Also WEBVIEW elements for android app can never be inspected by UIAutomator
I worked on hybrid app with WebView and intially same problem occured
driver.getContext returns only NATIVE context after property was set WEBVIEW context appear and setting correct context and using xpath from chrome remote debugger thing worked fine
Please refer below post for automating webview app:
Prerequisites:
apk with setWebContentsDebuggingEnabled flag set to true,
desktop chrome browser to inspect elements
Java code for automating hybrid apps:
// Switching to webview
Set<String> contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
System.out.println(contextNames); //prints out something like [NATIVE_APP, WEBVIEW_<APP_PKG_NAME>]
}
driver.context(contextNames.toArray()[1]); // set context to WEBVIEW_<APP_PKG_NAME>
// do web testing
String myText = driver.findElement(By.cssSelector(".green_button")).click();
// Switching back to NATIVE_APP
driver.context("NATIVE_APP");
// do more native testing if we want
driver.findElement(By.name("home")).click();
Appium comes with built-in hybrid support via Chromedriver. Appium also uses Selendroid under the hood for webview support on devices older than 4.4. (In that case, you’ll want to specify “automationName”: “selendroid” as a desired capability).
Make sure setWebContentsDebuggingEnabled is set to true.
Changing O/S does not change appium code it work same way,
If you are handling webview in windows,mac,linux it code remains same.
Only way to configure android sdk,running appium server will change.App under test will remains same
So same ans for u this platform also for Linux…
get app webview debugger enabled and get app built to support 4.4+,API level>18 then u can easily detect webview using
driver.getContext(); it will return Native,Webview both context
Chrome remote debugger will also show webview elements to spy upon
Hi amitjaincoer191,
Does it practicable to use Chrome remote debugger to show webview elements inside android device?
Like Uiautomator. In other words, we want to complete this work in an android jar.
The app under test has webview debugger enabled and built to support 4.4+,API level>18
Thank you very much!
Check whether WEBVIEW is enabled by developers or not, If it is not enabled you wont be able to Switch it.
The Workaround is first you have to instrument the .apk file, then it will work.
Did you try enabling “Enable view attribute inspection” in “Developer Options” on Android device.
If it still doesn’t work once disable and enable this option and then try.
Lemme know if it works…
@Raveendar_Reddy
I too have similar problem, already developer had enalbed flag, and i tried “Enable view attribute inspection”
It doesn’t work, even after disable and enable this option
I am facing the same issue. Even after trying by enabling “Enable view attribution inspection”. It doesn’t work. I tried to capture the screen which has two fragments inside a view pager and when try to capture the screen it shows the following error “Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Remote object doesn’t exist!
Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Remote object doesn’t exist!” . Even tried with Chrome Inspect devices option it doesnt work since it has two fragments with the same id’s.