-
-
Notifications
You must be signed in to change notification settings - Fork 211
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 'ensureWebviewsHavePages' cap #553
Conversation
Thanks @jlipps for looking into this. |
lib/webview-helpers.js
Outdated
if (ensureWebviewsHavePages) { | ||
logger.info('Retrieved potential webviews; will filter out ones with no active pages'); | ||
webviewProcs = await asyncfilter(webviewProcs, async (wp) => { | ||
return await webviewHasPages(adb, wp, webviewDevtoolsPort); |
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.
return is redundant
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.
i don't think so, doesn't the filter method need to return true or false in order to do its job?
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.
I mean
await asyncfilter(webviewProcs, async (wp) => await webviewHasPages(adb, wp, webviewDevtoolsPort))
should work just fine
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.
🎉
ok @mykola-mokhnach i endured the tedium of updating all the function comments to proper docstrings :-) and found an excuse to use |
it would be useful to have the new cap documented after the PR is merged |
published in 4.18.0. will put in docs PR soon. |
This PR fixes an odd situation which I have observed with Chrome-backed webviews on Android. Currently, Appium's code assumes that if it can find a webview-type process in
/proc/net/unix
, then a webview exists for that process.I've noticed that this assumption is not always true. Sometimes, the process exists, and a Chrome remote debugger is even running for the process, but there are no active webview pages. In this case, Chromedriver will always fail to attach to the webview, resulting in an error like "unable to discover open pages".
This PR adds a new capability
ensureWebviewsHavePages
which, if true, attempts to verify that a webview actually has active pages before adding it to the list of contexts. This serves to prevent users from trying to connect to a webview which is guaranteed to fail, and which will result in a cryptic error message.I've added this behind a capability because the only way I can see to achieve this is to send a request to one of the Chrome devtools HTTP endpoints. This involves running an adb command to forward a local port to the remote debugger port on the device, so we can make the necessary HTTP request, and then cleaning up the forwarded port afterwards. Thus it potentially adds overhead of time, and I'm also not certain that all webviews on all supported versions of Android support the Chrome devtools HTTP server. Once this feature is well-tested and proved useful, we could make this behavior opt-out rather than opt-in.
Because a local port is required for this feature, I've also added another capability,
webviewDevtoolsPort
, so that clients can specify a port to avoid port conflicts between sessions.