Running a Selenium RC test using C#
What is Selenium RC?
- It is a tool that enables us to write automated web application UI tests.
- Typical includes support for languages as given under
- Ruby On Rails
Selenium RC Components
The basic function of the selenium server is to
- Launch and Kill browsers
- Interpret and run the Selenese commands
- Act as HTTP proxy to intercept and verify HTTP messages between browser and AUT
Let’s see the steps to write and execute a basic script under Selenium RC.
1) You have already identified the scenario on your web application that you need to test.
2) Identify the start point and end point for your script.
3) In this case, I am beginning with the login, navigating to the home page on successful login and then returning back to the login page by a logout.
4) I invoked the login page for the web application. (Refer to the figure given below).
5) I go to Tools >> Selenium IDE to invoke the IDE reference given within the firefox browser.
6) Selenium IDE is invoked. Please refer to the figure
7) Now click the Record button and record your script/ scenario.
8) Selenium IDE will be populated with the resultant script instructions. You can see the steps in the figure given below.
9) Once the script has been recorded into the Selenium IDE, you can run/ execute it and verify for its correctness. Now this script needs to be converted into the RC script.
10) Go to Options >> Options to invoke the options setup window. You will find a checkbox entry labeled as “Enable experimental features”. Check this entry and click OK.
11) Now you are ready for conversion to the applicable format as deemed fit.
12) Go to Options >> Formats and select the C# format. Refer to the figure given below.
13) On selecting the C# format, you will notice your stepwise IDE instructions automatically converted to the relevant C# code.
14) Open Visual Studio and Select Visual C# >> Windows >> Class Library.
15) Open the class library and copy the converted C# code into this class library file.
16) Now remember the things to be done at this point
- Save the Class Library file
- Rename the namespace (It is originally shown as SeleniumTests during conversion, change it to an appropriate classname.
- Change the project name
- Add references to Nunit dlls.
17) The Nunit references for dotnet need to be downloaded into a folder from which you can refer to the associated .dll files.
18) Now create the build by Debug >> Build <<classlibrary>>. The figure below shows the build carried out successfully.
19) Once the build is created successfully, we need to get this into Nunit for our test. As the build is created, you will find the corresponding dll created into a folder as illustrated below.
20) Open Nunit and open the Nunit project by navigating to this resultant dll file. The figures shows the selection of the resultant .dll file.
21) Now invoke the Selenium server by typing java –jar <<selenium-server-jar-file>>.jar
22) Once the .dll file is opened within NUnit, now click the RUN button to carry out the test.
23) On successful test verification, the NUnit will show the results in Green. Please refer to the figure below.
24) Incorrect results or dependency errors will be shown in NUnit as indicated below.
Once you learn how to get your SElenium RC scripts ready and working, you can work up to the next level by adding exceptions, writing output to particular folders and so on.
So the very best from me for a successful Selenium RC venture. Thank you.