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

fix: handle safari alerts during atom execution #1176

Merged
merged 2 commits into from
Feb 27, 2020

Conversation

imurchie
Copy link
Contributor

Actually do the check for an alert. The atom will not actually complete until the alert is closed in the native layer, so returning is a must.

The tests were passing because all our alert tests use nativeWebTap, which works.

Fixes appium/appium#13979 and appium/appium#13549

extensions.checkForAlert = async function checkForAlert () { // eslint-disable-line require-await
extensions.checkForAlert = async function checkForAlert () {
try {
await this.getAlert();
Copy link
Contributor

Choose a reason for hiding this comment

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

have you checked how this change affects the performance?

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we could make this check configurable via settings, so it does not slow down tests, which don't face such issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is very little scope for performance effects. Most of the atoms, which do not cause an alert to come up, return well within the 500ms timeout before we check the first alert. If they take longer, it will be extended a very small amount while the alert it checked.

In the case of alerts actually arising, this will be much faster than the current execution, which hangs until the operation times out.

I did a little check, with the 'element handling' tests from the appium-xcuitest-driver Safari suite, which consists of 16 tests that involve running a lot of atoms. Running 5 times, the old strategy took 79767ms on average, and this took 80591ms.

If performance problems do arise, I'm happy to figure out something. But I don't think it is warranted at the moment.

Copy link
Contributor

Choose a reason for hiding this comment

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

cool, thanks for checking it

}

let res = await promise;
if (error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this if is redundant

// check if there is an alert
if (await this.checkForAlert()) {
// we found an alert, and should just return control
return '';
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this empty string have some special meaning?

@imurchie imurchie merged commit b194a76 into appium:master Feb 27, 2020
@imurchie
Copy link
Contributor Author

Weird. A commit on the forked branch didn't get into this. It's just clean up, so I'll do it elsewhere.

1 similar comment
@imurchie
Copy link
Contributor Author

Weird. A commit on the forked branch didn't get into this. It's just clean up, so I'll do it elsewhere.

khanayan123 pushed a commit to khanayan123/appium-xcuitest-driver that referenced this pull request May 10, 2021
* fix: handle safari alerts during atom execution

* fix: make sure alerts are waited for, and run tests in travis
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.

Timeout after clicking on an HTML button
3 participants