Though from J2ee Background we are, my experience has shown me that, Testing in Web Application is a typical component for success for any scale of Web Projects. So I wanted to write some articles related to a much known Testing Framework – Selenium, which I have used in my projects.
I will try to light up developers for application scenario testing s via selenium in 3 or more parts of posts, of which my first part is here below –
Selenium 1 (Selenium RC)
Selenium RC comes in two parts.
1. A server which automatically launches and kills browsers, and acts as a HTTP proxy for web requests from them.
2. Client libraries for favorite computer language.
How Selenium RC Works
Below are the working steps:
1. The client/driver establishes a connection with the selenium-RC server.
3. The client-driver passes a Selenese command to the server.
5. Selenium-Core instructs the browser to act on that first instruction, typically opening a page of the AUT.
6. The browser receives the open request and asks for the website’s content from the Selenium RC Server (set as the HTTP proxy for the browser to use).
7. Selenium RC server communicates with the Web server asking for the page and once it receives it, it sends the page to the browser masking the origin to look like the page comes from the same server as Selenium-Core.
So the above is theoretical aspects. Below are instructions to put Selenium at work –
Installation & Commands for Run
Install the Selenium RC Server: It is a Java jar file (selenium-server-standalone-<version-number>.jar), which doesn’t require any special installation. Just downloading the zip file and extracting the server in the desired directory is sufficient.
Before starting any tests one must start the server. Go to the directory where Selenium RC’s server is located (Ex. D:\Eclipse Selenium\Test Automation\lib – in my case) and run the following from a command-line console.
Write the command : java -jar selenium-server-standalone-2.21.0.jar
This can be simplified by creating a batch or shell executable file (.bat on Windows and .sh on Linux) containing the command above. Then make a shortcut to that executable on desktop and simply double-click the icon to start the server.
For the server to run java is need to be installed and the PATH environment variable correctly configured to run it from the console. Required java version is 1.5 or later (I have used JDK 1.6).
Set up a programming project using a language specific client driver
1. Download Selenium java client driver zip from the SeleniumHQ.
2. Extract selenium-java-<version-number>.jar file.
3. Open your desired Java IDE (Eclipse, NetBeans, IntelliJ, Netweaver, etc.
4. Create a java project.
5. Add the selenium-java-2.21.0.jar files to your project as references.
6. Add to your project classpath the file selenium-java-2.21.0.jar.
7. From Selenium-IDE, export a script to a Java file and include it in Java project, or write a Selenium test in Java using the selenium-java-client API. One can either use JUnit, or TestNg to run test cases, or one can write own simple main() program.
8. Run Selenium server from the console.
9. Execute your test from the Java IDE or from the command-line.
Ok. Now this is my first part. I will explain setup Selenium RC in Eclipse in next post.
References/External Links :
To my wife Ketaki Nandi (J2ee Professional also…) for helping me in preparing contents.