Accessing a detached overlay view (android) with Appium

See original GitHub issue

TL;DR:

It would be great if Appium would have a command to find and even access overlays (android views that were added dynamically with WindowManager).

Longer version:

I have an android application in which I pop up an overlay window. This is done by calling:

myWebView.loadUrl("someUrl");
windowManager = (WindowManager) context.getSystemService(WINDOW_SERVICE);
windowManager.addView(myWebView, layout);

And I want to test that the overlay is displayed successfully, and also that I can perform actions in it (example scenario: there is an X button inside that web view, and clicking it should close the overlay).

I tried to use Appium inspector / android uiautomator and neither was able to detect the webview on the screen at all. I’ve also tried to use myWebView.setContentDescription("some_tag") to label the view and then access it with driver.findElement("//*[@content-desc='some_tag']") but it didn’t find it.

I’ve found that the following ADB command can indicate wether the overlay is present:

adb shell dumpsys window windows | grep "package=myPackage appop=SYSTEM_ALERT_WINDOW"

But this would be a fragile solution, because I will probably be counting on running an external process in my test, not to mention that it depends on grep (can be easily transferred to JS).

I couldn’t find anything similar in Appium. Can this ability be added? To query for WindowManager’s dynamically added views, and even provide selector-based access to them?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jlippscommented, Jan 23, 2017

@DvirSh every appium and selenium client has a command to retrieve the page source, which is an XML document. I don’t know what library you’re using so I can’t comment on the specific command you should use, but it would be in the library docs.

About the content-desc, you mean I should set the content-desc in my Java code (as above), but on my JS test I should use driver. findElementByAccessibilityId(“some_tag”)? I’ll try it out…

Yes.

0reactions
simon30ruscommented, Jun 7, 2019

@fruwe any chance did you find the solution? I am facing exactly the same issue. I tried removing WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE from my view overlay that causes UIAutomator to see the overlay view, but the rest gets lost…

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to click an overlay popup in android using Appium when ...
I tried with UI automaton and appium desktop inspector. The mobile element locators for the overlay is not detected.
Read more >
Accessing a detached overlay view (android) with Appium
I tried to use Appium inspector / android uiautomator and neither was able to detect the webview on the screen at all. I've...
Read more >
How to click an overlay popup in android using Appium when ...
If the element can not been found in page source, you can: Click via the coordinate of screen. Add accessibility for the element...
Read more >
Use openQuickSettings in root With Examples | LambdaTest
Learn how to use openQuickSettings function in root framework for your next JavaScript automation project with LambdaTest Automation Testing Advisor.
Read more >
How to handle iFrame in Selenium - BrowserStack
Switching Frames in Selenium using Index; Switching Frames using Name or ID ... If you find an option like This Frame, view Frame...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found