Couldn't inspect elements on mobile Android app using uiautomator viewer

1.4k views Asked by At

I'm trying to automate android mobile app using selenium/java with appium. I connected the android device to my pc and trying to inspect the elements on app screen after taking the screenshot using uiautomator viewer. But the whole screen is displayed inside single frameLayout and I couldn't inspect each element inside the frame.

I tried with chrome inspect as well but elements are not detected using chrome inspector.

Can sometime please help on this?

2

There are 2 answers

0
Shubham Jain On

This is the similar question I have put up some time ago:

How to tap on a element which is focused in appium. Unable to select value of a dropdown in appium

One of the thing you can try by switch to frame if any frame present.

ad.switchTo().frame(ad.findElement(By.xpath("YOURXPATH")));

Try using driver.getPageSource();. It will return you XML DOM, if you are getting the value then it is good. Write a XPath for same.

Either you just need to use co-ordinare and then using tab

Below code work for me

    By filter =By.xpath("MYLOCATOR");
    System.out.println("About to click on result");
    Point point = ad.findElement(filter).getLocation();
    int elementCenterX = point.getX() + 80;
    int elementCenterY = point.getY() + 100;
    System.out.println("value of x = "+elementCenterX+"   value of y = "+elementCenterY);
    ad.tap(2, elementCenterX , elementCenterY , 0);

Note:- you need to adjust X and Y as per your requirement in above code and pass the nearest locator like text box of the dropdown.

0
Luis On

Hey I had the same issue there is nothing wrong with the ui automator it's the phone it's self . The phone is reading the guesture so when you try to find a element you can't lock on it . So go to settings and tap on display change display to full screen