Difference between revisions of "Intermediate Selenium Example"

From Joomla! Documentation

Line 1: Line 1:
  
== Writing a More Advanced Test ==
+
== Writing a More Advanced Selenium Test ==
  
  
Line 58: Line 58:
  
 
Your test should then be ready to go.
 
Your test should then be ready to go.
 +
 +
[[Category:Testing]]

Revision as of 15:21, 13 December 2009

Writing a More Advanced Selenium Test[edit]

Now that you have created your first simple test, let's try something a little more advanced.

Let's write a test that verifies the functionality of creating and deleting a user.

We will start by browsing to the login screen of the administrator panel of our Joomla site.

Then, we will open up Selenium IDE.

You should notice that the record button is highlighted, which means we are recording.

Go back to the main browser window and enter the username and password for a Super Administrator user.

  • Click Site, and select User Manager
  • Click New
  • Enter some details, such as:
    • Name: My Test User
    • Username: TestUser
    • E-mail: test@example.com
    • Password: password
    • Group: Registered
  • Click Save
  • Highlight the text 'Successfully saved User: My Test User'
  • Right Click and Select 'assertTextPresent Successfully saved User: My Test User'
  • Enter TestUser into the Filter text box and click Go
  • Highlight the username TestUser, right click and Select 'AssertText'
  • Right click on the User link and select 'AssertText'
  • Browse to the frontend of your site
  • Go to the Login form and enter your credentials, and click Login
  • Highlight the text 'Hi TestUser', right click and select 'AssertTextPresent 'Hi TestUser'
  • Click Logout
  • Browse to the admin panel of your site
  • Go the user manager
  • Select the Checkbox for 'My Test User'
  • Click Delete
  • Click Logout

And we're done recording.

Now, due to some quirks in Selenium, there are some things that we need to fix. There are two main quirks that we need to look at: 1. For some reason, entering the password in the administrator does not get recorded. We have to add a manual command for this. 2. Selenium often misses the step of going to a new URL via the browser address bar. We have to add these manually.

To fix the first problem, we do the following

  • Click on the first 'ClickAndWait' (with Target link=Login).
  • Right Click and select 'Insert New Command'
  • The command should be Type, the Target should be modlgn_passwd and the Value should be the password for your admin user.

To fix the second problem:

  • scroll down through your command list until you find the second type - modlgn_username. click on this command.
  • Right Click and select 'Insert New Command'
  • The command should be open, and the Target should be the path to your Joomla frontend.
  • scroll down through your command list until you find clickAndWait - link=User Manager
  • Enter a new command there also - the command should be open, and the Target should be the path to your Joomla Administrator panel.

Your test should then be ready to go.