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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option for wait duration for mobile context list #1135

Merged
merged 3 commits into from
Jan 3, 2020

Conversation

imurchie
Copy link
Contributor

@imurchie imurchie commented Jan 2, 2020

Add an option, waitForWebviewMs, to the mobile execute version of getContexts, which will make it blocking for that period of time. Workaround for appium/appium#13770

return await this.getContexts();
}

while (timer.getDuration().asMilliSeconds < waitForWebviewMs) {
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 use waitForCondition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would require an external variable anyway, and be annoying. Also exceptions for control flow are... unneeded.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, we anyway need to call getContexts() at least once.
How about:

     let contexts = await this.getContexts();

     while (timer.getDuration().asMilliSeconds < waitForWebviewMs) {
       log.debug('Retrieving contexts');
       contexts = await this.getContexts();
       if (contexts.length >= 2) {
         log.debug(`Found webview context after ${timer.getDuration().asMilliSeconds.toFixed(0)}ms`);
         return contexts;
       }
       log.debug(`No webviews found in ${timer.getDuration().asMilliSeconds.toFixed(0)}ms`);
     }
     return contexts;

@imurchie imurchie merged commit 5ba79aa into master Jan 3, 2020
@imurchie imurchie deleted the isaac-context-poll branch January 3, 2020 14:43
khanayan123 pushed a commit to khanayan123/appium-xcuitest-driver that referenced this pull request May 10, 2021
* feat: add option for wait duration for mobile context list

* return an array

* make sure getting contexts happens once
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