Elements cannot be found on Appium Inspector and when running scripts but can be found in UI Automator Viewer

Hi,

Can someone help me? I’m not able to locate the element and use the element in my scripts. Was using Appium Inspector at first but went to UI Automator Viewer. I can find the elements but when I run the scripts, it still cannot be found.

I encircled the elements needed. It’s in a menu that will only show after click an element. These are the desired capabilities I’m using:

Also I’m using AppiumDriver<MobileElement> as the driver. Am I missing something? My I included the desired capability automationName and passed UiAutomator2 as the value. No problem in logging in but when arriving at that menu, it does not detect the elements.

Regards,
Enzo

try enable:

capabilities.setCapability("enableMultiWindows", true);

also check element in page source on this screen:

System.out.println(driver.getPageSource())
1 Like

Hi Aleksei,

Thank you for the reply. Do I need to like have commands when to switch windows? Given that it has multiple windows?

no. just add into capabilities and check.

Hi,

It still cannot detect the elements in the side menu.

And also tried printing the pageSource. The element is not in there.

share page source and how you looking for items

The only elements in the page source are the ones that is not in the menu. The original screen elements.

I uploaded the page sourceUp!.txt (48.2 KB).

For element looking, I’m using UI Automator Viewer.

As you can see, I can detect the logout button from the viewer tool.

Do I need to switch to webview or something? This is from the Appium Inspector.

uuuuu. we see webview here. better switch to it and use full power of webview search e.g. css like:

    @FindBy(css = "#btnLogin")
    private WebElement loginButton;

use Chrome browser to inspect it from computer.

also there is ‘autoWebview’ in capabilites https://appium.io/docs/en/writing-running-appium/caps/ that possible will be usefull if your app have many such screens.

So I need switching to web view and back to native view whenever I encounter something like this right? I can use find by xpath also right? And also, are there like any requirements for switching to webview or some sort given I use AppiumDriver? Do I need like WebDriver or AppiumDriver will be sufficient?

it all depends on your app. if you have many webviews that go one by one you can switch one time and follow. possible ‘autoWebview’ will make it even easier without any work on our side. try. continue use AppiumDriver.

1 Like

But if I use WebElement, will it work on AppiumDriver< MobileElement > driver?

it will work. no worry. just try.

Ok thanks. I’ll let you know tomorrow. Please don’t close this thread yet.

i use:

AppiumDriver driver;

driver = new IOSDriver<>(url, caps); // ios
// and
driver = new AndroidDriver<>(url, caps); // android
1 Like

Hi Aleksei,

I can switch to webview now but it still cannot detect or click on elements of the navigation drawer of the app.

make sure that your app build has debuggable webView. ask developer to make it debugabble.

It’s debugggable under web view but I think it’s because in web view, those elements are inside nav tags. I’m not entirely sure if it’s an issue but I can’t click or check any elements under it.