3

I trying to automate a hybrid app using the appium-selenium setup. I facing problem in getting the object properties. I am using ui automator to identify elements but it is unable to do the job. It is only identifying the outer or parent frame of the app and doesn't go beyond that.

My appium version : 1.3.4.1 Chromedriver version: 2.4

I tried in both emulators (Genymotion) and physical devices.

Device environment: Android 4.2 above

For handling hybrid apps we have to switch the contexts between Native view and Webview according to our needs.

Set<String> contextNames = driver.getContextHandles();
    for (String contextName : contextNames) {
        // prints out something like NATIVE_APP or WEBVIEW_*
        System.out.println(contextName);
    }
    driver.context(contextNames.toArray()[1].toString()); // set context to
                                                            // WEBVIEW_*

But for Hybrid apps (developed using Angulas JS in my case) i could not find any tool to get the object properties. Only way i could find in using the inspect element feature of chrome and getting the xpath. However i was able to use inspect element only on emulators(genymotion). It did not work on real devices for me.

Would be good if any one could shed some more light on that area.

15
  • Make sure you appium server should be OFF when you are trying to get object properties using UI automator. Mar 23, 2015 at 4:22
  • Tried after shutting down Appium. Still not able to get object properties
    – Vir
    Mar 23, 2015 at 8:06
  • what error you getting?? Mar 23, 2015 at 8:07
  • i am not getting any errors. The UI Automator is capturing screenshot of the app in the emulator but when i hover the mouse on various elements it doesnot identify any element in the screenshot. It only identifies the entire frame.
    – Vir
    Mar 23, 2015 at 8:14
  • does your APK is from live server? or local? Mar 23, 2015 at 8:17

2 Answers 2

1

You should be able to use the Appium Inspector to find the xpath of the element, and then call xpath within your test cases.

Appium also contains a step to switch contexts between native and web. I believe it is

switch_context(context)
0

Neither uiautomator nor Appium will help you to identify webview elements.

— You can do this with Chrome Developer tools, look at Remote Debugging on Android with Chrome guide. It will work for hybrid apps as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.