Selenium/Ruby/Shared features
This page is obsolete. It is being retained for archival purposes. It may document extensions or features that are obsolete and/or no longer supported. Do not rely on the information here being up-to-date. See Selenium instead. |
This is a list of features provided by the mediawiki_selenium
RubyGem that are available to all browser tests in all repos.
See Quality Assurance/Browser testing/Writing tests for an introduction to writing tests.
Login
editLogs the user in on the wiki specified by the environment variable MEDIAWIKI_URL
Usage
editIn any Scenario in any Feature, just use
Given I am logged in
and the shared login step will use the environment variables MEDIAWIKI_USER and MEDIAWIKI_PASSWORD to login at the target wiki.
Notes
editLogin is accomplished as thoroughly as possible:
- in order to avoid missed clicks, the script fires an "onfocus" event on the login button before clicking
- in order to confirm login, the script checks for the existence of a link to "Special:UserLogout" in order to proceed. This check works in all languages for all wikis
Random page
editSends the script to a random page in the target wiki
Usage
editIn any Scenario in any Feature, just use
Given/When I am am at a random page
Notes
edituses Special:Random in the target wiki
Reset preferences
editResets all of the test user's preferences to default settings.
Usage
editIn any Scenario in any Feature, just use
Given/When I have reset my preferences
Notes
editThis feature has the potential to interfere with other tests that rely on particular preferences being set in a particular way. Make certain that this feature is used only for test users whose preference settings are irrelevant for other work.
ResourceLoader errors
editAfter loading any page, this step will check for ResourceLoader errors and report any modules that have errors and any modules that are missing.
Usage
editIn any Scenario in any Feature, just use
Given/When/Then page has no ResourceLoader errors
Notes
editThis is a pure javascript check and does not manipulate any aspect of browser function.
Upload file
editSteps to upload valid or invalid media files via the shared interface in both Firefox and Chrome
Usage
editIn any Scenario in any Feature, just use
When upload file <filename>
to upload a valid PNG image file
and
When upload bogus file <filename>
to upload an invalid empty file
Notes
editAs of 2014 April this is valid only the MobileFrontend and UploadWizard repositories. The steps are shared, but each repo right now has it's own version of the UploadPage page object. This is Bug 63833
Create page at run time via API
editCreates a page with particular title and text in the target wiki at runtime.
In the target wiki:
- if no page with this title exists, the page will be created with the specified content
- if a page with this title exists but the contents of the page differ from what is in the API call, the existing page will be updated with the contents of the API call by means of a normal revision, which will appear in the history of the page.
- if a page with this title exists and the contents of the page are identical to what is in the API call, the existing page is not changed in any way, and no additional revisions are created. This is a no-op.
Usage
editIn the steps for any Scenario do
Given(/^I create some page with some content$/) do
on(APIPage).create "page title", "page contents"
end
Note the creative possibilities:
- to create a page in the target wiki with a quasi-unique title that the running Scenario will be able to find and use in the course of the test:
Given(/^I create a random page using the API$/) do
on(APIPage).create @random_string, @random_string
end
- to guarantee that a particular page in the target wiki will have particular content, and then navigate to that page:
Given(/^I go to a page that has references$/) do
wikitext = "MobileFrontend is a
MediaWiki extension.<ref>[http://mediawiki.org/wiki/Extension:MobileFrontend Extension:MobileFrontend]</ref>
==References==
<references />"
on(APIPage).create "Selenium References test page", wikitext
step 'I am on the "Selenium References test page" page'
end
Protect
editsets the level of protection to
edit=sysop|move=sysop
Usage
editon(APIPage).protect "Title of page to be protected", "Reason for protection"
Notes
editAPIPage features rely on an environment variable MEDIAWIKI_API_URL. Before the test runs, do for example:
export MEDIAWIKI_API_URL=http://en.wikipedia.beta.wmflabs.org/w/api.php
The test will abort immediately if it calls (ApiPage).create and the MEDIAWIKI_API_URL env var is not in place.
Also note that the user identified by the environment variables MEDIAWIKI_USER and MEDIAWIKI_PASSWORD must have proper permissions to manipulate pages on the target wiki via the API in order to use this feature.