Laurynas
Laurynas

Reputation: 1032

How to find elements on android hybrid app using appium

I am trying to test Hybrid App using Appium. I am not able to inspect ids using Appium inspector or uiautomatorviewer. It shows only one class for app. I tried to inspect id elements by using web application, but it does not work. So my question would be what is another way to find/get app elements?

EDITED: xpath do not help. Here is my code:

public void findButton() {
        driver.findElement(By.xpath("//html/body/div[5]/div/div/div[1]/div[1]/div[3]/div[1]/div[2]/div[3]/div[2]"));
}

Upvotes: 3

Views: 2680

Answers (3)

Kiran Antony
Kiran Antony

Reputation: 250

Change the view to webview.

Set contextNames = driver.getContextHandles();
for (String contextName : contextNames) {

System.out.println(contextNames);

}
driver.context("WEBVIEW_com.xxx.yyy.zzzz");

It will print the context as Native ,WEBVIEW_com.xxx.yyy.zzzz , then you have to change the context to WEBVIEW in order to automate the hybrid app .

eg: driver.context("WEBVIEW_com.xxx.yyy.zzzz");

driver.context -->it will switch the context

Upvotes: 0

user5398769
user5398769

Reputation: 1

Step 1- Need to move the control from Native app to Web View (where page is rendered using webview)

driver.context("web_view");

Step 2 - Connect the device to system via USB, and open browser with URL chrome://inspect ....

Step 3 - Identify the particular element

Upvotes: 0

Gaurav
Gaurav

Reputation: 1370

Web application don't usually have all the elements we expect to use. Instead what you can do, use the class name/index, filter it and use it as your xpath.

Upvotes: 1

Related Questions