Wednesday, February 15, 2012

Basic Selenium setup-SeleniumIDE,RC,EclipseIDE and TestNG

Installation steps for Selenium IDE:
The pre-requisite for installing Selenium IDE is to have a Mozilla FireFox installed in the machine with a 3X or later version as Selenium IDE is an add-on to FireFox.
  1. Go to http://seleniumhq.org/download/
  2. Click on Download version 1.6.0 (at the time of writing this) under Selenium IDE
  3. Click on Allow button on the pop-up blocker
  4. Click on Install Now button on the opened pop-up
  5. After the Installation click on Restart FireFox for complete setup.
Installation steps for Selenium RC:
The pre-requisites to install RC are to have Java 1.5 or above version and Eclipse IDE installed in your machine.
  1. You can download and install Java URL from the following http://www.oracle.com/technetwork/java/javase/downloads/index.html
  2. You can download and install Eclipse from the following URL: http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/helios/R/eclipse-jee-helios-win32.zip
  3. Extract the Zip Folder and run the eclipse.exe File. There is no separate installation required rather than running the .Exe file.
  4. Now go to http://seleniumhq.org/download/ and click on Download version 2.19.0(at the time of writing) under Selenium Server section
  5. Click download link under selenium Client drivers for your desired language. (e.g. To download Selenium Java client drivers, click on Download link for Java)
  6. Extract the Client drivers into to your Local disk.
  7. Open Eclipse IDE.
  8. Create a New Project (Right Click on Project Explore-->New-->select Java Project-->Give the name and click on Finish.
  9. Right click on the Project-->Build Path-->Configure Build Path--> Libraries tab-->Add External Jars.
  10. Add the following list of jars to the libraries and Click on Ok to complete the setup.
  • Selenium-server-standalone-2.14.0
  • Selenium-java-2.14.0
  • Selenium-java-2.14.0-srcs
Configuring TestNG Framework to Selenium RC:
  1. Go to http://testng.org/doc/download.html and download the latest version of TestNG.
  2. Extract the zip file to your local disk
  3. Go to Eclipse and add the testng-6.3.1.jar file to the external jar files as above.
  4. Now go to Help Menu and click on Install New Software
  5. Click on Add button
  6. Give the Name as TestNG (you can give any name, but we prefer TestNG)
  7. In the location provide the following URL and click on OK http://beust.com/eclipse (For Eclipse 3.4 and above) http://beust.com/eclipse1 (For Eclipse 3.3 and below)
  8. Now Check the checkbox TestNG and click on Next to install the TestNG
Steps to Run Selenium Server:
Before starting the execution of your scripts on selenium RC we have to start the selenium server. Following are the steps to start your server.
  1. Open command prompt
  2. Type cmd
  3. Go to the location where your selenium-standalone-server2.14.0.jar resided
  4. Type the following command at command prompt to start the server. java –jar selenium-standalone-server-2.14.0.jar
Creating a Batch File for Selenium server:
  1. Open Notepad and type the following text D: cd Selenium\ java -jar selenium-server-standalone-2.14.0.jar(Here I assumed that your server is at D: drive)
  2. Now save the File as server.bat on your desktop.
  3. Now whenever you want to start the server you just run this batch file. When the server starts running you can see the following screenshot on your desktop.

Tuesday, October 18, 2011

Run https site with Selenium, C#.Net and Firefox 3.5.3

1) Open the Windows "Start" menu, select "Run", then type and enter one of the following:

firefox.exe -profilemanager

2) Create a new profile (e.g. selenium-https-profile) and work with this profile.

3) Open your application manually and accept the certificate permanently with the newly created profile (i.e. selenium-https-profile) and hit the ok button.

4) Run the Selenium RC server with -firefoxProfileTemplate option and specify the path.

java -jar selenium-server.jar –firefoxProfileTemplate "C:\Users\\AppData\Roaming\Mozilla\Firefox\Profiles\gmkxzvfb.selenium-https-profile"

5) Go to SetupTest() function in your designed C# Code and Start Selenium server with following code:

selenium = new DefaultSelenium("localhost", 4444, "*firefox", "https://www.xxx.com/");

6) Run The Test from C#.NET.

Run https site with Selenium, C#.Net and IE 8.0

1) Open IE.

2) Go to Tools->Internet Options->Content->Certificate->Trusted Root Certificate Authorized and Import new Certificate (i.e. cybervillainsCA) from “\selenium-remote-control-1.0.1\selenium-server-1.0.1\sslSupport “

3) Start selenium server with the Following command:

:\selenium-remote-control-1.0.1\selenium-server-1.0.1>java -jar Selenium-server.jar -interactive –trustAllSSLCertificates

4) Go to SetupTest() function in your designed C# Code and Start Selenium server with following code:

selenium = new DefaultSelenium("localhost", 4444, "*piiexplore", "https://xxx.com/);

5) Run The Test from C#.NET.