How to setup and configure selenium webdriver environment with NetBeans?.


Software Requirement
  • JDK
  • NetBean IDE
  • Selenium WebDriver Library
  • FireBug and FirePath
Setting up the environment involves the following steps.
  • Download and Install SDK
  • Download and Configure NetBean IDK or  Eclipse with Selenium Webdriver
  • Install and Configure FireBug and FirePath
  • Configure Selenium WebDriver
Download and Install SDK
We need to have JDK (Java Development Kit) installed in order to work with Selenium WebDriver/Selenium. Please follow below step to download and install JDK.

Step 2 : Go to "Downloads" section and select "JDK Download".  
Step 3 : Select "Accept License Agreement" radio button. 
Step 4 : Select the desired installation. In this case, it is 'Windows 7-64' bit. Click the appropriate link and save the .exe file to your disk. 
Step 5 : Click the downloaded exe file to launch the Installer wizard. Click 'Next' to continue.  
Step 6 : Select the features and click 'Next'.  
Step 7 : The installer is extracted and its progress is shown in the wizard.  
Step 8 : The user can choose the install location and click 'Next'. 
Step 9 : The installer installs the JDK and new files are copied across. 
Step 10 : The Installer installs successfully and displays the same to the user. 
Step 11 : To verify if the installation was successful, go to the command prompt and just type 'java' as a command. The output of the command is shown below. If the Java installation is unsuccessful or if it had NOT been installed, it would throw an "unknown command" error.
 


Configure Selenium WebDriver
Step 1 : Go to the selenium downloads section http://www.seleniumhq.org/download/ and download Selenium WebDriver by clicking on its version number as shown below.


Step 2 : The downloaded file is in Zipped format and one has to unzip





Step 3 : The Unzipped contents would be displayed as shown below.  

 
 

Download and Configure Netbeans IDE with Selenium Webdriver
Download:
Step 1 : Navigate to the URL: https://netbeans.org/downloads/index.html and download
Step 2 : Click the 'Download' button.  
Installation:
Step 3 : Click the downloaded exe file to launch the Installer wizard. Click 'Next' to continue. 

Step 4 : Click on 'Next'
 

Step 5 : Select license agreement then Click on 'Next'

Step 6 : Select your desired option then Click on 'Next'


Step 7 : Click on 'Next'


Step 8 : Click on 'Next'

Step 9 : Click on 'Next'

Step 10 : Click on 'Install'




Step 11 : Click on 'Finish'
  

Configure NetBeans IDE With Selenium WebDriver
Step 12 : Click on 'Start' --> Write 'Netbeans' on search input field then click on 'Netbeans'

Step 13 : Go to File->New Project->Categories Java and Projects Java Application and click next.

Step 14 : Give the Project Name and Destination where it it will be saved and click finished.

Step 15 : Right Click on project which is shown on the left side of NetBeans and select Properties

Step 16 : Add all jars with in the selenium-2.45.0 folder (selenium-2.45.0 + selenium-java-2.45.0-srcs.jar +All jar in libs folder) 

Step 17 : After adding the all jar this should be shown on the NetBeans.
Step 18 :Now we are ready to write code in NetBeans using Selenium WebDriver.Here we write some code like
package seleniumfirstproject;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;


public class Seleniumfirstproject {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
         // Initialize driver      
        WebDriver dr = new FirefoxDriver();  
        //Maximize browser window       
        dr.manage().window().maximize();  
        //Go to URL      
        dr.get("http://www.google.com");  
        //Set  timeout      
        dr.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);  
  
        //close firefox browser  
        dr.close();  
    }
    
}
 

Step 19 : Right click on source code then click on 'Run File
Step 20 : 'firefox will be opened and show the google page like this


 Configure FireBug and FirePath
FireBug and FirePath very vital to locate elements based on their XPath or ID or name, etc. In order to locate an element, we need tools/plugins. 
Step 1 : Go to the URL : https://addons.mozilla.org/en-US/firefox/addon/firebug/ and download plugin.

Step 2 : The add-on installer is shown to the user and it is installed upon clicking the 'Install' button.


Step 3 : After installing, we can launch the plugin by navigating to "Web Developer" --> "Firebug".


Step 4 : FirePath, a plugin that works within Firebug, helps users to grab the 'XPath' of an element. Install FirePath by navigating to "https://addons.mozilla.org/en-US/firefox/addon/firepath/"


Step 5: The add-on installer is shown to the user and it is installed upon clicking the 'Install' button.

 Step 6 : Now launch "Firebug" by navigating to "Tools" --> "Webdeveloper" --> "Firebug". 
 Example
Step 1 : First click on the arrow icon as highlighted in the following screenshot and drag it to the object for which we would like to capture the properties. The HTML/DOM of the object would be displayed as shown below. We are able to capture the 'ID' of the input text box with which we can interact.



Step 2 : To fetch the XPath of the object, go to 'firepath' tab and perform the following steps.

  • Click the Spy icon.
  • Select the Control for which we would like to capture the XPath
  • XPath of the selected control would be generated

2 comments:

  1. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Netbeans, kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on Netbeans. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Nitesh Kumar
    MaxMunus
    E-mail: nitesh@maxmunus.com
    Skype id: nitesh_maxmunus
    Ph:(+91) 8553912023
    http://www.maxmunus.com/




    ReplyDelete
  2. The information which you have provided is very good. It is very useful who is looking for selenium Online Training

    ReplyDelete