Page MenuHomePhabricator

selenium: handle alert in page.js rather than using the more resource intensive "browser.reloadSession()"
Open, Needs TriagePublic

Description

when the second test in tests/selenium/specs/page.js executes, the following alert appears:

'Leave site? Changes that you made may not be saved.

Screenshot 2023-05-16 at 11.07.11 AM.png (3×3 px, 2 MB)

this alert blocks continuation to subsequent tests. it has a Cancel and a Leave button

the current work-around for getting past this alert is calling browser.reloadSession(), but that's an expensive operation

it would be preferable to just handle that alert by programmatically choosing the Leave option rather than reloading the entire session

Event Timeline

Change 915838 had a related patch set uploaded (by Mhurd; author: Mhurd):

[mediawiki/core@master] selenium: dismiss alert in more efficient manner

https://gerrit.wikimedia.org/r/915838

@kostajh thanks for checking out my patch!

i replied to your questions on it

forgot to mention i've also tested my patch in the case where only the single test i'm using it on is invoked

npx wdio /var/www/html/w/tests/selenium/wdio.conf.js --spec /var/www/html/w/tests/selenium/specs/page.js --logLevel debug --mochaOpts.grep 'should be creatable'"

it works in this single-test use case as well due to the max wait parameter's default value

Mhurd updated the task description. (Show Details)
Mhurd updated the task description. (Show Details)