Skip to content
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

Merged
merged 3 commits into from
Aug 7, 2019

Conversation

KazuCocoa
Copy link
Member

@KazuCocoa KazuCocoa commented Aug 7, 2019

Currently, https://github.com/appium/appium-remote-debugger/blob/b8f5be6bd0fe9577c0f3ca54eac595a049e7aaaa/lib/remote-debugger.js#L324 is rased when we run below scenario.

  1. Open an ios-uicatalog app
  2. Call available contexts command
    • Get NATIVE_APP 馃啑
  3. Open Web View cell
    • open webview
  4. call available contexts command
    • Get NATIVE_APP and WEBVIEW_xxxx 馃啑
  5. Back
    • No webview page
  6. call available contexts command

This 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...

@KazuCocoa KazuCocoa requested a review from imurchie August 7, 2019 11:05
@KazuCocoa KazuCocoa changed the title fix: catching error when no available web pages [do not merge yet] fix: catching error when no available web pages Aug 7, 2019
@@ -158,7 +158,12 @@ extensions.listWebFrames = async function listWebFrames (useUrl = true) {
let pageArray;
Copy link
Contributor

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

@@ -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}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps err.message ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both were fine 馃啑

@@ -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 {
Copy link
Contributor

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

@KazuCocoa KazuCocoa changed the title [do not merge yet] fix: catching error when no available web pages fix: catching error when no available web pages Aug 7, 2019
@KazuCocoa KazuCocoa merged commit ba4e79f into appium:master Aug 7, 2019
@KazuCocoa KazuCocoa deleted the km/cartching-error-no-pages branch August 7, 2019 15:46
khanayan123 pushed a commit to khanayan123/appium-xcuitest-driver that referenced this pull request May 10, 2021
* fix: catching error when no available web pages

* set [] by default

* define local func
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants