2012-09-26

Setting up Selenium Webdriver

Setting up Selenium Web driver environment in Windows PC

In the following article, we will learn how to setup environment for selenium IDE & selenium Webdriver.

Step 1: Installing Firefox
We need selenium IDE supported Firefox. To know supported Firefox version visit selenium IDE release note . See suitable version number and Download Firefox 
Step 2: Installing Selenium IDE
Run the newly installed Firefox and go to the link 
Download suitable Selenium IDE (Firefox supported, that you have seen from step 1). The Firefox plug-in will be installed.
Or, from Firefox, go to Tools -> add on (Ctrl+Shift+A) search selenium and install selenium IDE. You may find many helping add on. We may need to install when we will start for deeper level coding.

Step3: Selenium Driver Download
Download “Selenium Client Drivers” from here   for JAVA or C# . We will download both as we will setup both environments.Extract the folders and see
For Dot Net: We will get 2 folders for net35& net40 (for different dot Net versions). We have to include DLLs located inside folder as reference of the selenium project in VS 2010.
For JAVA: We will get 2 jar files. selenium-JAVA-2.25.0.jar, selenium-JAVA-2.25.0-srcs.jar. We have to include the jar in the project.

Step 4: IDE and Unit Test Frame Work Installation.
For Dot Net:
1.    Visual studio 2010 should be installed.
2.    NUnit(Download and install latest one)

For JAVA:
1.    Download and install latest Eclipse  or Net Beans(My examples are on Eclipse of that version )
2.    JUnit 4.0 JARs (Already included in eclipse, if not present please install latest one from here )

Step 5 : Including Unit Test framework in the project
For Dot Net : After Crating a Project(class library)
->From solution explorer Right click Reference
-> add reference 
-> Browse
-> Locate to the installed path of NUnit (under program files)
-> bin\framework
->select all (nunit.framework.dll, nunit.mocks.dll, pnunit.framework.dll) and press ok.
For JAVA: After Crating a JAVA Project
-> Mouse right click from Package explorer and click properties
(It also can be found while creating a new JAVA project)
-> build path
 -> Libraries
-> Add Library
-> JUnit
-> JUnit 4.0(not 3.0) and Finish
(Usually it is included in the eclipse, if not, include as external JARs that we have downloaded in step 4

Step 6 : Including Selenium Client Drivers reference  in the project
For Dot Net :
->From solution explorer Right click Reference
-> add reference 
-> Browse
-> Locate to the downloaded & extracted folder path of step 3
-> Select net40
-> include all DLLs (Castle.Core.dll, Ionic.Zip.dll, Newtonsoft.Json.dll, Selenium.WebDriverBackedSelenium.dll, ThoughtWorks.Selenium.Core.dll,
WebDriver.dll, WebDriver.Support.dll)
And press OK.
For JAVA:
-> Mouse right click from Package explorer and click properties
(It also can be found while creating a new JAVA project)
-> build path
 -> Libraries
->Add External JARs
-> Locate to the downloaded & extracted folder path of step 3
->selenium-JAVA-2.25.0.jar 

Step 7 : Add Unit Test framework Header in the Code
In the Class header, we have to add those references that we add in Step 5. Add the header in the top of a Test class.
For Dot Net  :
using NUnit.Framework;
For JAVA :
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;

Step 8 : Add Selenium WebDriver Header in the Code
In the Class header, we have to add those references that we add in Step 6. Add the header in the top of a Test class.
For Dot Net  :
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.IE;

For JAVA :
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

Now, we are ready for selenium web driver test implementation.
Be noted that, In Dot Net, we are using class library project type as we will use NUnit GUI for observing test results. And for JAVA, we are using run as JUnit(project) for observing test results.

9 comments:

  1. Nicely described, it would be great if u include video tutorials. thanks a lot :)

    ReplyDelete
  2. Thanks god... I have planning but don't have enough time right now.

    ReplyDelete
  3. Valuable information and excellent design you got here! I would like to thank you for sharing your thoughts and time into the stuff you post!!
    Big data online training

    ReplyDelete
    Replies
    1. Thanks , but your SEO link posting keep this in my spam notification...:)

      Delete
  4. good info...but will u plz post some examples using dotnet ?

    ReplyDelete
    Replies
    1. Most of my selenium work is based on dot net but I cant show the project certainly. I can show based on problem domain . If you need specif problem based solve as example, please mail me. I will share code.

      Delete
  5. It helps me a lot. Appreciate for sharing. THANKS!!!

    ReplyDelete