Page MenuHomePhabricator

Add helper to Selenium that allows you to query whether JavaScript module has loaded
Closed, ResolvedPublic

Description

One of the most common issues we have with browser tests is things failing due to JS not having loaded.

Something like:
Given I am on the X page
And I click the open JS overlay button
Then I see an overlay

In this case if I click the open JS overlay button executes before the overlay JavaScript has loaded the latter step (or this step) will fail.

To remedy this in MobileFrontend and QuickSurveys we run the following snipper of JS to see if the module is ready

'mw.loader.getState("ext.quicksurveys.init") === "ready";'

We'd like to formalise this in the Selenium library.

Event Timeline

https://gerrit.wikimedia.org/r/#/c/310458/6 is a first stab at this in MobileFrontend. It would be more useful as part of the general mediawiki_selenium library. cc @dduvall @thcipriani - I would love to pair with you on this

ovasileva triaged this task as Medium priority.Sep 21 2016, 4:38 PM
ovasileva moved this task from Incoming to Triaged but Future on the Web-Team-Backlog board.

The rule of thumb so far was that if a feature is needed in at least two repositories (in this case MobileFrontend and QuickSurveys), we would move it to the mediawiki_selenium gem. I will make a simple implementation and test it.

Change 312047 had a related patch set uploaded (by Zfilipin):
WIP Add helper to Selenium that allows you to query whether JavaScript module has loaded

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

zeljkofilipin subscribed.

Will continue next week, ran out of time.

Change 310458 had a related patch set uploaded (by Jdlrobson):
Allow browser tests to check RL modules are ready

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

Change 310458 merged by jenkins-bot:
Allow browser tests to check RL modules are ready

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

I've moved this to tracking as this is better placed in the release engineering domain.

Change 322897 had a related patch set uploaded (by Zfilipin):
WIP Move #wait_until_module_ready to mediawiki_selenium

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

Change 312047 merged by jenkins-bot:
Helper that allows you to query whether JavaScript module has loaded

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

Moving columns as the last remaining patch is for MobileFrontend : https://gerrit.wikimedia.org/r/322897

Change 322897 merged by jenkins-bot:
Move #wait_until_module_ready to mediawiki_selenium

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