Intermediate Selenium Example: Difference between revisions

From Joomla! Documentation

Ian (talk | contribs)
New page: == Writing a More Advanced Test == 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 c...
 
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
#REDIRECT [[Writing_System_Tests_for_Joomla!_-_Part_1#Writing_an_Intermediate_Test_with_Selenium_IDE]]


== Writing a More Advanced Test ==
== Writing a More Advanced Selenium Test ==




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


Then, we will open up Selenium IDE.
Then, we will open up [http://docs.joomla.org/Functional_Testing Selenium] IDE.


You should notice that the record button is highlighted, which means we are recording.
You should notice that the record button is highlighted, which means we are recording.
Line 15: Line 16:
Go back to the main browser window and enter the username and password for a Super Administrator user.
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 Site, and select User Manager
Click New
* Click New
Enter some details, such as:
* Enter some details, such as:
Name: My Test User
** Name: My Test User
Username: TestUser
** Username: TestUser
E-mail: test@example.com
** E-mail: test@example.com
Password: password
** Password: password
Group: Registered
** Group: Registered
 
* Click Save
Then Click Save
* Highlight the text 'Successfully saved User: My Test User'
Highlight the text 'Successfully saved User: My Test User'
* Right Click and Select 'assertTextPresent 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
Enter TestUser into the Filter text box and click Go
* Highlight the username TestUser, right click and Select 'AssertText'
Highlight the username TestUser, right click and Select 'AssertText'
* Right click on the User link and select 'AssertText'
Right click on the User link and select 'AssertText'
* Browse to the frontend of your site
Browse to the frontend of your site
* Go to the Login form and enter your credentials, and click Login
Go to the Login form and enter your credentials, and click Login
* Highlight the text 'Hi TestUser', right click and select 'AssertTextPresent 'Hi TestUser'
Highlight the text 'Hi TestUser', right click and select 'AssertTextPresent 'Hi TestUser'
* Click Logout
Browse to the admin panel of your site
* Browse to the admin panel of your site
Go the user manager
* Go the user manager
Select the Checkbox for 'My Test User'
* Select the Checkbox for 'My Test User'
Click Delete
* Click Delete
Click Logout
* Click Logout


And we're done recording.
And we're done recording.
Line 45: Line 46:
2. Selenium often misses the step of going to a new URL via the browser address bar.  We have to add these manually.
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 test, we do the following:
To fix the first problem, we do the following
Click on the first 'ClickAndWait' (with Target link=Login).
* Click on the first 'ClickAndWait' (with Target link=Login).
Right Click and select 'Insert New Command'
* 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.
* The command should be Type, the Target should be modlgn_passwd and the Value should be the password for your admin user.


Then, scroll down through your command list until you find the second type - modlgn_username.  click on this command.
To fix the second problem:
Right Click and select 'Insert New Command'
* scroll down through your command list until you find the second type - modlgn_username.  click on this command.
The command should be open, and the Target should be the path to your Joomla frontend.
* 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.


Then, scroll down through your command list until you find clickAndWait - link=User Manager
Your test should then be ready to go.
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.
[[Category:Testing]][[Category:Automated Testing]]

Latest revision as of 14:23, 10 June 2010

Writing a More Advanced Selenium Test

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.