Accessing a detached overlay view (android) with Appium
See original GitHub issueTL;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:
- Created 7 years ago
- Comments:9 (3 by maintainers)
@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.
Yes.
@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…