Manual:Coding conventions/Selenium-Ruby

This page describes coding conventions used by Cucumber test files in MediaWiki codebase. For the list of repositories that contain the files see links section of mediawiki-selenium readme file. There are three types of files, Cucumber features files, Cucumber step definition files and page object files.

Cucumber feature files
For example file see any file in  folder of qa-browsertests repository. Feature files usually contain features and scenarios.

Required tags
Every feature or scenario in a feature file should have a site and browser specific tag.
 * Site specific tag is for example  or  . The tag specifies where the feature or scenario should run. This convention is currently used in most places.
 * Browser specific tag is for example  or  . The tag specifies which browser should be used to run the feature or scenario. This convention is currently not used. At the moment we tag features or scenarios if they are known to fail with specific browser, for example.

Optional tags
Some features or scenarios can have an optional tag.
 * If the feature or scenario requires the user to log in, it should have  tag. This convention is currently used in most places.


 * If the feature or scenario runs fine on a clean wiki, it should be tagged . This convention is currently not used. At the moment we tag features or scenarios that are known to fail on a clean wiki with.
 * If the feature or scenario requires custom browser configuration, it should be tagged . This convention is currently not used. At the moment we tag features or scenarios that need custom browser configuration with   tag in UniversalLanguageSelector repository and with   tag in MobileFrontend repository.

Cucumber step definition files
For example file see any file in   folder of qa-browsertests repository. Step definition files usually contain,   and   steps.

Simplicity
In general, code in step definition files should be as simple as possible. Ideally, just one or two lines per step. All complicated code should be moved to page objects. This convention is currently used in most places.

Grouped By Type
Steps should be grouped by type. and  steps should be grouped in one group,   steps should be grouped separately. Inside the group, steps should be sorted alphabetically by step name. This convention is currently not used. At the moment we do not combine  and   steps in one group.

Alphabetically Sorted
Inside a group, Cucumber step definitions should be sorted alphabetically. This groups steps with similar name. Steps with similar name usually have similar functionality, making them good candidates for merging. This convention is currently used in most places.

Page object files
For example file see any file in   folder of qa-browsertests repository. Step definition files usually contain page URL, page elements and methods. All complicated functionality should be moved to methods.

URL
Page URL is optional. It is used in step definitions when a  or   step needs to go directly to a page, or when a   step needs to check page URL.

Page elements
Simple page elements should be defined using page-object Ruby gem API.

Example: