Wednesday, March 26, 2014

Selenium User Guide



Selenium User Guide






Selenium IDE: This is a Mozilla Firefox’s addon and can be downloaded from http://release.seleniumhq.org/selenium-ide/1.0.10/selenium-ide-1.0.10.xpi . An addon will ask permission for installation. Follow the steps. When ask for restart Firefox first close the tab containing the above Url then restart Firefox. Now Selenium IDE is installed and can be accessed through Mozilla Firefox > Tools > Selenium IDE.

(Note: The provided link should be opened only through Mozilla Firefox Browser)





Selenium RC Server: This can be downloaded http://selenium.googlecode.com/files/selenium-remote-control-1.0.3.zip .








Nunit: This can be downloaded from http://launchpad.net/nunitv2/2.5/2.5.9/+download/NUnit-2.5.9.10348.msi .








Microsoft Visual Studio





JRE 1.5 or later


















How to record scripts in Selenium






Open Mozilla Firefox web browser.


Go to Tools.


Click Selenium IDE. (Selenium IDE will be opened in recording mode by default)


Go to Selenium IDE > File and click "New test Case".


Go to Firefox tab and enter the Url of the website you want to test.


Selenium will automatically record all the steps followed by you.


After the recording completed click the RED round button located in the right hand top side of Selenium IDE. This button is used to start and stop the recording.


Save the recorded test case through File > "Save test case".




Test Script types in Selenium:





Basic tabular scripts.


Advanced scripts.




Basic tabular scripts




The scripts recorded by Selenium IDE are initially in this format. These scripts are in the tabular format and run by Selenium IDE itself.




Advanced scripts




These scripts are programming language specific. And can run through Nunit + RC Server.







Steps to run Basic Scripts


Start Selenium IDE.


Go to File > Open (Navigate to the location where basic scripts are available)


Select the script(the script will be selected to run)


Click the PLAY button and the script will run.



Result Evaluation

Result can be analyzed from result status bar. If script is passed then Failure=0 and Run = 1 (in case one test script is run at a time). If script is passed then Failure=1 and Run = 0.






Steps to run Advanced scripts



Download and install Nunit, JRE 1.5 or later, Visual Studio and Mozilla Firefox.


Download Selenium RC server.


Configure dot net client drivers (as specified below)


Copy and paste the advanced script into the class1 created in Visual studio in step 3.


Click f6 to Build.


Now open command prompt.


Navigate to the location where Selenium RC is downloaded.

e.g. if it is located in ‘E’ drive then go to: “E:\selenium-remote-control-1.0.3\selenium-server-1.0.3”


In the command prompt run the command. “java -jar selenium-server.jar”. (Don’t close the command prompt)


Open Nunit.


Go to File > Open Project


Navigate to the Visual Studio 2008 > Projects > Selenium Project > Selenium Project > Bin > Debug.


Select Selenium Project.dll.


In Nunit click ‘Run’.




The script will run now in 2 Mozilla Firefox browsers and if the status will be failed then there will be a red bar in Nunit and if status will be passed then the bar will be green.




Among two browsers one will display the log and other will execute the script in GUI format.




The browsers will be automatically closed when the test case is completed.


.NET client driver configuration

.NET client Driver can be used with Microsoft Visual Studio. To configure it with Visual Studio do as Following.


Launch Visual Studio and navigate to File > New > Project.



Select Visual C# > Class Library > Name your project > Click on OK button.


A Class (.cs) is created. Rename it as appropriate.



Under right hand pane of Solution Explorer right click on References > Add References.




Select following dll files - nmock.dll, nunit.core.dll, nunit.framework.dll,ThoughtWorks. Selenium.Core.dll, ThoughtWorks.Selenium.IntegrationTests.dll, ThoughtWorks.Selenium.UnitTests.dll and click on Ok button




With This Visual Studio is ready for Selenium Test Cases.













Special Note:





We can test Local, Dev, Preprod and Live site by making a minute change in the scripts.





In case of Base scripts we can change the url in the “Base url” column to the desired one in Selenium IDE.




In case of Advanced scripts we can change the url in the below code string to the desired one




Note : Here “localhost“ will not be changed in the below script.




selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://fd.fd2009.dev.fdwork.com/");





For in-depth knowledge of Selenium, Selenese (Selenium Commands), Selenium RC and Selenium Advanced usage follow the link : http://seleniumhq.org/

No comments:

Post a Comment