View · Index

Testing with Selenium

Testing with Selenium

Selenium is primarily for feature testing, user interface and acceptance testing.

Recently OpenACS got support for Selenium RC on CVS HEAD to be released in OpenACS 5.6 sometime in the future.

Forum Posts :

https://openacs.org/forums/message-view?message_id=365992

Command Reference :

Selenium Documentation

Interesting Articles :

Tools :

Selenium Recorder Firefox Extension

Quickstart to Writing Tests:

  This quickstart shows you how to start writing selenium tests with selenium and the selenium recorder (aka selenium-ide).

  1. You need to have the Firefox Browser version 1.5 or higher
  2. Proceed to http://www.openqa.org/selenium-ide/ and click on the link (Firefox Extension) to install the Selenium IDE firefox extension
  3. Restart firefox
  4. Click Tools -> Selenium IDE
  5. The selenium ide window will open
  6. It will start recording your actions in the browser.
  7. You can go ahead and go to a url and click on the links to see how the recorder records your actions.
  8. To disable recording while the recorder window is open, click the "red" button.
  9. Selenium verifies that a test or action is successful by checking the title or text in a webpage
  10. You can verify the title of the current page  by right clicking on the webpage you are currently in and click Append Selenium -> verifyTitle
  11. You can verify the presence of text in a page by highlighting some text and then right click -> Append Selenium Command -> verifyTextPresent

Click here for a video of how to use Selenium IDE.

Selenium IDE allows you to create, save, load and run tests right from firefox without having to install Selenium on the server.

Selenium on the Server

Aside from using the Selenium IDE to test webpages, selenium itself can be installed on the server. This provides a central location for testers and developers to view and execute tests. "Server" here refers to the OpenACS instance where your application is running. If your OpenACS instance is in http://your_openacs_instance, then selenium should be installed in http://your_openacs_instance/selenium

WARNING: We do not recommend installing selenium on the server of a production instance. Only install selenium on a staging or test server. This is because

  • When tests fail, they leave a mess of test data that you will not want on production
  • Selenium is mostly javascript that can run on any browser. While there are currently no reports of exploits on servers running selenium, we do not want and (you should not too) take the risk of having it on a production box where it is possible for a clever hacker to utilize a browser vulnerability to break into your server.

To instal selenium on the server :

  1. Download selenium from http://www.openqa.org/selenium-core/download.action
  2. Choose to download the "Full Release"
  3. After downloading, decompress the file.
  4. You will see a folder selenium-x.x where "x.x" is the version of selenium you downloaded.
  5. Go inside this folder and look for the "selenium" folder.
  6. Copy this "selenium" folder to the openacsroot/www/ directory
  7. Launch a browser and go to http://your_openacs_instance/selenium

At this point, selenium is installed. The page that you see when you visit /selenium is the default selenium page. It lists the tests that come with selenium.

To start using selenium on the server :

  1. Customize the landing page /selenium/index.html
  2. Create Test Suites for each package. A test suite is just a file in selenium/tests that lists a number of tests for a particular feature or section of an application. For instance, TestSuite-News.html would be a file that lists the tests for the News Package.
  3. Upload tests to the /selenium/tests folder.

Guidelines for Creating and Running Tests for OpenACS Packages

Coming Soon .....

Some Limitations :

  • Minor Issue with SSL  : Selenium can't switch properly between http and https pages.
  • File Input type not supported : You can't tell selenium to upload a file. But there is a work around with firefox. Read it here
  • WYSIWYG Editors  : Selenium can't write to some WYSIWYG editors like htmlarea but it seems to work with xinha, you just need to get the textearea element name that xinha uses.

Tips :

Use xpath to find specific html elements

I have  scenario where I want to click ona image field with no id or name attribute so there's no easy way to tell selenium to click it. We can either ask the designer to put an id or name attribute or use xpath. Let's say the image button in question looks like this

 <input type="image" src="images/long-login-btn.gif" width=166 height=15 />

the xpath syntax will be

 //input[@src='https://openacs.org/images/long-login-btn.gif']

and you can use this in conjunction with clickAndWait

Use javascript to create dummy values

You can use javascript to generate values like so

  javascript{'test' + (new Date()).getTime()}

and use store to store them to a value for use later in the selenium script.

 

previous December 2024
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 1 2 3 4

Popular tags

17 , 5.10 , 5.10.0 , 5.10.1 , 5.9.0 , 5.9.1 , ad_form , ADP , ajax , aolserver , asynchronous , bgdelivery , bootstrap , bugtracker , CentOS , COMET , compatibility , CSP , CSRF , cvs , debian , docker , docker-compose , emacs , engineering-standards , exec , fedora , FreeBSD , guidelines , host-node-map
1 registered user in community xowiki
in last 30 minutes
Contributors

OpenACS.org