Selenium

From Organic Design wiki
Revision as of 04:05, 1 August 2008 by Nad (talk | contribs)
Selenium TestRunner environment ([PATH to selenium core]/TestRunner.html)

Selenium Core is a test tool for web applications. Selenium Core tests run directly in a browser, just as real users do. And they run in Internet Explorer, Mozilla and Firefox on Windows, Linux, and Macintosh. No other test tool covers such a wide array of platforms.

  • Browser compatibility testing. Test your application to see if it works correctly on different browsers and operating systems. The same script can run on any Selenium platform.
  • System functional testing. Create regression tests to verify application functionality and user acceptance.

Selenium Core uses a unique mechanism which allows it to run on so many platforms. Written in pure JavaScript/DHTML, you copy Selenium Core tests directly into your your application webserver, allowing the tests to run in any supported browser on the client-side. Thus, you must have write access to the machine your web application server is running on to install Selenium Core.

Selenium Core was developed by team of programmers and testers at ThoughtWorks. It is open-source software and can be downloaded and used without charge. It is currently under active development by our team. Stay tuned for updates and further announcements.

ThoughtWorks is a leader in Agile development methods for enterprise software development. Selenium is designed specifically for the acceptance testing requirements of Agile teams. However, teams using more traditional development will also find it useful.

Selenium is a browser testing environment for testing the various aspects of a sites features and functionality from a users perspective. We see this as an extremely useful tool for use in the MediaWiki environment, for testing MediaWiki installations and installed extensions. Such tests could be maintained along with extension code and documentation by the community responsible for that extension.

Selenium is available for many programming environments including PHP. The tests are written in a simple language called Seleniumese which can be contained in many common textual structures such as XML or HTML. Essentially tests are just lists of Selenium function calls so if tests were maintained as articles in the wiki, a bullet list would be most appropriate. There are also test suites which are in a similar format to the tests but refer to a list of tests rather than a list of functions. We have some example tests which act on a wiki here.

Installation

For the server-side (Selenium core) installation instructions, see Extension talk:Selenium.php which explains how to install the core along with the MW:Extension:Selenium MediaWiki Selenium extension.

Client side

Selenium IDE

Selenium has both a server and a client side, the client side is Selenium IDE which is a Firefox browser plugin. Selenium IDE is an integrated development environment for Selenium tests. It is implemented as a Firefox extension, and allows you to record, edit, and debug tests. Selenium IDE includes the entire Selenium Core, allowing you to easily and quickly record and play back tests in the actual client browser environment that they will run.

Selenium IDE is not only recording tool: it is a complete IDE. You can choose to use its recording capability, or you may edit your scripts by hand. With autocomplete support and the ability to move commands around quickly, Selenium IDE is the ideal environment for creating Selenium tests no matter what style of tests you prefer.

It is also recommended to install the firefox extension XPath Checker which provides a right click option View XPath over any part of a webpage which provides the XPath expression

Creating Tests

The easiest way to create tests is to record them in firefox after enabling the Selenium IDE from the tools pull down menu. As you fill in fields within forms, hitting tab will guarantee that the value is recorded by the Selenium IDE. If a recorded field is incorrect, just edit the html table source removing the table row error and continue the recording process. After recording a test, the source html can be modified and refined by hand. In general long form URLs should be used to minimize ambiguity for portability of tests as some wiki's use Friendly URLs.

Examples

  • Our tests Note the query string points to the directory where the html test files are located via TestRunner.html?test=../../tests/test.html. The selenium document root relative to the installation path is [PATH TO SELENIUM]/selenium/core. In this example the html file tests.html is an index table of available selenium tests which are themselves html tables. If this index file is called index.html then you do not need to specify it in the path, just [URL]TestRunner.html?test=../../tests/.

See also