-
-
Notifications
You must be signed in to change notification settings - Fork 409
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: catching error when no available web pages #1031
fix: catching error when no available web pages #1031
Conversation
lib/commands/context.js
Outdated
@@ -158,7 +158,12 @@ extensions.listWebFrames = async function listWebFrames (useUrl = true) { | |||
let pageArray; |
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'd rather assign it to []
here
lib/commands/context.js
Outdated
@@ -155,14 +155,13 @@ extensions.listWebFrames = async function listWebFrames (useUrl = true) { | |||
log.debug(`Selecting by url: ${useUrl} ${useUrl ? `(expected url: '${this.getCurrentUrl()}')` : ''}`); | |||
|
|||
const currentUrl = useUrl ? this.getCurrentUrl() : undefined; | |||
let pageArray; | |||
let pageArray = []; | |||
if (this.remote && this.remote.appIdKey) { | |||
// already connected | |||
try { | |||
pageArray = await this.remote.selectApp(currentUrl, this.opts.webviewConnectRetries, this.opts.ignoreAboutBlankUrl); | |||
} catch (err) { | |||
log.debug(`No available web pages: ${err}`); |
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.
perhaps err.message ?
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.
both were fine 馃啑
lib/commands/context.js
Outdated
@@ -168,7 +172,11 @@ extensions.listWebFrames = async function listWebFrames (useUrl = true) { | |||
log.debug('Unable to connect to the remote debugger.'); | |||
return []; | |||
} | |||
pageArray = await this.remote.selectApp(currentUrl, this.opts.webviewConnectRetries, this.opts.ignoreAboutBlankUrl); | |||
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.
this whole block can be moved to a separate local function/closure to avoid duplication
* fix: catching error when no available web pages * set [] by default * define local func
Currently, https://github.com/appium/appium-remote-debugger/blob/b8f5be6bd0fe9577c0f3ca54eac595a049e7aaaa/lib/remote-debugger.js#L324 is rased when we run below scenario.
available contexts
commandNATIVE_APP
馃啑Web View
cellavailable contexts
commandNATIVE_APP
andWEBVIEW_xxxx
馃啑available contexts
commandThis is because we do not handle the error in xcuitest layer.
The error means we have no available webview. So, I think we can make the result
[]
In this PR, I handle the error as try/catch in xcuitest layer, but I also wonder we can return
[]
in https://github.com/appium/appium-remote-debugger/blob/b8f5be6bd0fe9577c0f3ca54eac595a049e7aaaa/lib/remote-debugger.js#L324@imurchie
Do you have any good idea how to handle the issue?
try/catch in xcuitest layer like this PR, return
[]
in the remote debugger or other good ideas...