Search code examples
seleniumappium

Recognizing element in an Hybrid App - Android


I am new to Android testing. I am currently trying to automate a scenario. I have attached the snapshot of the app screen:

enter image description here

Scenario:

  1. I need to click on "Clock In".
  2. A screen slides from the bottom as shown in the snapshot.
  3. I need to select an item as shown by the arrow.

The developer is saying that it is a Hybrid app. A lot of confusion here for me as I am able to click on "Clock In", but I am not able to select "DL 380 Memory Upgrade".

Doubts:

  1. How to find whether "DL 380 Memory Upgrade" is in Webview/Native?
  2. If it is an element in the webview, how to locate it? I located "CLOCK IN" as below:

    @AndroidFindBy(xpath = "//android.view.View[@resource-id='tab-t0-0']") private AndroidElement clockInTabBtn;


Solution

  • If its an element in WebView, then its web and you won't find anything in web while searching by resource-id - its native attribute only.

    I would recommend to use chrome dev tools for debugging hybrid application. You can read official docs for setup.

    Basically you need:

    1. connect device
    2. go to chrome://inspect/#devices in chrome browser
    3. check phone & allow usb debugging if popup appears
    4. check what webViews chrome spotted and click inspect for the one you need enter image description here
    5. And now you search for elements and their locators the same way you did in Selenum/Web automation enter image description here
    6. Don't forget to switch context to WebView in your appium test before you actually searching inside webView.

    Good luck!