Monday, May 16, 2011

Working with Selenium-Grid and TestNG


Prerequisites:
1. Firefox 3.0 or higher version.
2. Firefox Add-on Selenium IDE.
Installation Steps:
1. Download selenium-grid-1.0.7-bin.zip and extract the folder.
2. Download ANT from below link and extract the folder.
3. Add the path of Ant (Till /bin folder path) in the system environment variable.
This can be done by following steps:
· Go to My Computer->Properties
· Click Advanced->Environment Variables
· In System Variables click on Path (Edit System Variables Window Opens)
· Go to Variable Value and go till end of the path enter ' ;' and paste the path of Ant till bin folder.
· Click OK and Close.
4. Download JDK from below link and install (higher version after 6).
5. Install Eclipse (Freely available in Net for installation).
6. Add TestNG to Selenium IDE by following the steps below:
Open Firefox->Tools->Selenium IDE
Go to Options->Options->Formats
Click Add and Enter 'Name of the Format' as TestNG
Paste the formatting code present in TestNG.txt file.
Click Save and OK.
Make sure that TestNG format is selected in Selenium IDE.
7. Add TestNG plug-in to Eclipse by following the steps below:
Open Eclipse click on Help->Install new Software->Click Add
Enter the URL “http://beust.com/eclipse/” in Location and Install TestNG.
Execution of Automation Script:
1. Open Eclipse and create Project and then a Package.
2. Include JAR files of Selenium and TestNG to the created package by the following steps:
Right click on Package->Build Path->Configure Build Path
Go to Libraries and click Add External JARs
Browse and open all jar files in \selenium-grid-1.0.7\lib folder
Go to Order and Export tab and Check all JAR files and click OK
In the same way add JAR file of TestNG.
3. Create new class and write the automation code.
4. Create a batch file and place it inside selenium-grid folder.
The batch file should contain the following commands.
Launch the Hub ( start /B ant launch-hub )
Launch a remote control declaring that it provides the Safari environment:
(start /B ant -Denvironment="*safari" -Dport=5562 launch-remote-control)
5. For executing automation scripts follow the steps below:
Run the Batch file present in Selenium-grid folder
To make sure hub and remote controls are active and running open http://localhost:4444/console in Firefox.
Go back to Eclipse where your automated script to be executed is present,
Right Click->Run As->TestNG test.
Before running scripts make sure all the code errors are resolved.
Note:
1. This installation process is for Windows XP.
References:

______________________________________________
Reference: http://myselenium.wordpress.com

1 comment:

  1. Thats a great one :)
    Keep on writing your challenges in Mobile testing as well..would be of great help to all of us

    ReplyDelete