-
-
Notifications
You must be signed in to change notification settings - Fork 413
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
Conversation
lib/commands/context.js
Outdated
return await this.getContexts(); | ||
} | ||
|
||
while (timer.getDuration().asMilliSeconds < waitForWebviewMs) { |
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 use waitForCondition
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.
That would require an external variable anyway, and be annoying. Also exceptions for control flow are... unneeded.
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, 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;
* feat: add option for wait duration for mobile context list * return an array * make sure getting contexts happens once
Add an option,
waitForWebviewMs
, to the mobile execute version ofgetContexts
, which will make it blocking for that period of time. Workaround for appium/appium#13770