Page MenuHomePhabricator

QA: implement "login to <PAGE>" to speed up browser tests
Closed, ResolvedPublic

Description

Many tests follow "I am logged in" with "visit FlowPage", "I navigate to Upload Wizard", "I visit the User page of Selenium_user2", etc. In these cases Special:UserLogin's default behavior of loading the Main_Page upon successful login is a waste of precious time.

MediaWiki has already solved this for human beings. Clients can pass ?returnto=Some_wiki_page to Special:UserLogin so that upon successful login the user is redirected to Some_wiki_page. It's what the _Log in_ link on every wiki page does, as you can see if you hover over it and note its URL.

For example, http://en.wikipedia.beta.wmflabs.org/wiki/Special:UserLogin?returnto=Talk:Flow_QA

We could expose this as

Given I am logged in to <PAGE>

in tests. mediawiki_selenium/step_definitions/login_steps.rb would need to recognize the presence of this optional parameter and append ?returnto=URLEncode(pageName) to LoginPage

I would prototype this but I don't know where the visit() function is defined or documented in our webdriver-selenium-watir-cheezy-cucumber stack.

Is using

on(APIPage).client.log_in(ENV["MEDIAWIKI_USER"], ENV["MEDIAWIKI_PASSWORD"])

another alternative?


Version: unspecified
Severity: enhancement

Details

Reference
bz71635

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 3:44 AM
bzimport set Reference to bz71635.
bzimport added a subscriber: Unknown Object (MLST).
Spage created this task.Oct 4 2014, 5:06 AM

(In reply to spage from comment #0)

Is using

on(APIPage).client.log_in(ENV["MEDIAWIKI_USER"], ENV["MEDIAWIKI_PASSWORD"])

another alternative?

This doesn't work. The mediawiki_api module issues its own HTTP requests from Ruby. So the cookies it gets back aren't set in the browser under test, it only uses them in subsequent API calls. You'd have to tell the browser to make the API POST, or "push" the cookies from the API response into the WebDriver session.

(In reply to spage from comment #1)

(In reply to spage from comment #0)

Is using

on(APIPage).client.log_in(ENV["MEDIAWIKI_USER"], ENV["MEDIAWIKI_PASSWORD"])

another alternative?

This doesn't work. The mediawiki_api module issues its own HTTP requests
from Ruby. So the cookies it gets back aren't set in the browser under test,
it only uses them in subsequent API calls. You'd have to tell the browser to
make the API POST, or "push" the cookies from the API response into the
WebDriver session.

Passing the cookies over from an API call is an interesting idea, assuming API sessions work in the same way interactive ones do. Of course, this should only be using in setup context (i.e. Given) but it would greatly reduce the overhead and fragility of tests that assume a logged-in state.

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 30 2015, 3:52 PM
zeljkofilipin closed this task as Resolved.Nov 2 2015, 4:23 PM
zeljkofilipin claimed this task.
zeljkofilipin added a subscriber: zeljkofilipin.

Browser tests can now log in via the API, making it really fast. Please reopen the task if there is something else left to do here.