Skip to end of metadata
Go to start of metadata

Testing using the Selenium Framework

Selenium is a suite of tools designed to automate web app testing over many browsers.

Selenium can be used within the eclipse framework as an effective way of performing web ui unit tests.


  1. This testing setup was first introduced on July the 14th 2009, post 2.3.1 release. So you will need to check out the latest code from head (including the changes to move to jboss-5) to test this. In lams_build/lib/selenium, there are several new libraries, and there is also a change to the 3rdParty.userlibraries file.
  2. Once you have libraries ready, you need to have the selenium java service running. In eclipse go to Run -> External Tools -> External Tool Configurations. This is using Eclipse 3.4, please refer to the Eclipse documentation on how to get to this page on a different version.
  3. Under Program select new.
  4. Name the run configuration "Selenium".
  5. In the location field enter the path the the java excutable, in ubuntu this is normally /usr/bin/java.
  6. In the arguments area, enter the following text
    -jar ${workspace_loc}/lams_build/lib/selenium/selenium-server.jar -port 5555 -userExtensions ${workspace_loc}/lams_build/lib/selenium/user-extensions.js -timeout 30
  7. Select Run and you should get some output in your console.
  8. Find the CloudWizard module with the SeleniumFlexAPI Library added in. It's located in lams_build/lib/selenium/CloudWizard.swf. Just pop it into lams.ear/lams_monitoring/web under the JBoss server.
  9. Also start your lams server as this must be running to run the tests. You should start it using the settings found in lams_common/src/java/org/lamsfoundation/lams/selenium/
  10. Now select a test that you want to run, for example lams_tool_wiki/test/java/org/lamsfoundation/lams/tool/wiki/selenium/
  11. Right click on the class and select Run As -> JUnit test.

Writing Tests for a Tool

You can write your own tests for a tool by looking at the Selenium API and applying the tests in JUnit. Of course, you will need to handle loggin in, author, learner etc. However an easily extendible abstract class has already been made that will do most of this for you. Its located in lams_common/src/java/org/lamsfoundation/lams/selenium/ Have a look at this class and you'll find alot of useful methods like loginToLams() and createNewLesson() that will make the testing process much easier.

To set up your tests you can use following methods: setUpAuthoring(), setUpLearning(), setUpMonitoring(). It will open up and set up required windows. Don't worry about closing them as it's done automatically during tearDown().

Also pay attention that each test can contain several test cases. But you must have already run the author test and startLesson test before testing learner and monitor. To guarantee the order in which the test cases will be run use static suite() method like this one:

public static TestSuite suite() {
	String[] testSequence = {"testAuthor", "testStartLesson", "testLearner", "testMonitor"};
	return new SeleniumTestSuite(TestWiki.class, testSequence);

Furthermore many Actions should be followed by one of the "waitFor" commands. This tells Selenium that the action will cause the browser to make a call to the server, and that Selenium should wait for a new page to load.

Selenium Assertions

Selenium lets you test UI by making assertions that the intended requirements are met.

Besides, you can use number of "verify" commands. These commands are like "assert" commands, but they don't stop the test when they fail. Instead, verification errors are all thrown at once during tearDown.

Known Issues

Although there are a few cases when testing framework fails to work:

  • The problem with hidden/visible "root" element. When you try to add new lesson this element can just appear out of nowhere (It happens very rare though). Testing framework will just throw an exception: "Tests aborted due to the problem with CloudWizard's root element problem. Please, restart tests".
    Solution: fix cloudwizard or wait for the next version of selenium.
  • If you run Selenium tests in IE then sometimes Selenium server may just fail to start (throwing the JS exception). It happens once every 10-20 starts of Selenium.
    Solution: this is known selenium issue. should wait when it'll be fixed
  • LDEV-2413
    Use only lowercase letters in learning design names until this issue will be resolved.
  • No labels