-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add mobile endpoint to retrieve UIAutomator page source dump #628
Conversation
Why not to create another |
...rver/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/UiautomatorPageSource.kt
Outdated
Show resolved
Hide resolved
var dumpXml = "" | ||
var dumpView: File? = null | ||
|
||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kotlin allows to return directly from try: https://kotlinlang.org/docs/reference/exceptions.html#try-is-an-expression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method could be simplified as
override fun handleInternal(params: AppiumParams): String = try {
val stream = ByteArrayOutputStream()
InteractionHelper.getUiDevice().dumpWindowHierarchy(stream)
String(stream.toByteArray())
} catch (e: IOException) {
throw AppiumException("Could not get page source with UiAutomator", e)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Problem:
driver.page_source
doesn't return page source when AUT is not in focus.We had an issue while working on an application flow where the test navigates outside of the AUT's context. The test performs a photo upload operation as part of the test flow. When the active app is not AUT we use
driver.execute_script('mobile:uiautomator',*args)
to perform the UI interactions.When a test fails our framework attaches the screenshot and page source of the active screen. But when the active app is not AUT, espresso driver can't return the page source with
driver.page_source
. To overcome this we can dump the UI dom with UIDevice.Problem with the current implementation:
I don't expect this PR change's to be merged, this is just what works for me now. Perhaps @mykola-mokhnach or @KazuCocoa can suggest a more refined solution for this.