Eclipse For Selenium Webdriver

In the previous post, you have learned about setting up Eclipse IDE for selenium webdriver and writing the simple script in the Java class. In this tutorial, you will learn in detail writing selenium webdriver script in Java using Eclipse IDE. Here, we are also discussing how to write selenium webdriver script for automating different browsers like Chrome, Firefox, IE etc. using most of the common selenium webdriver commands.

  1. Eclipse Selenium Webdriver Chrome
  2. Eclipse For Selenium Webdriver Download
  3. Selenium Ide Download
Table of Contents

Download Eclipse for Java Developers, extract and save it in any drive. It is totally free. You can run ‘eclipse.exe’ directly so you do not need to install Eclipse in your system. Mar 19, 2019 It’s easy to get up and running with Selenium-WebDriver using Eclipse and the Java bindings on Windows.In this article we'll show you how to get the various parts and pieces to configure selenium for Java, plus write and run one simple test. The Components You'll Need. Exporting Webdriver Code and Using It in our Tests. Now we’re going to export what we have so far and use this exported webdriver code in Eclipse: In Selenium IDE hit file- export test case as- Java/Junit 4/Webdriver. Selenium RC Selenium WebDriver; The architecture of Selenium RC is complicated, as the server needs to be up and running before starting a test. WebDriver's architecture is simpler than Selenium RC, as it controls the browser from the OS level. Selenium server acts as a middleman between the browser and Selenese commands.

Selenium Webdriver Script in Java

Following is the sample selenium webdriver script written in Java that uses most common selenium webdriver commands. It will load the URL “https://www.siteforinfotech.com” on the chrome browser, navigates to “Contact Us” page, fills the fields of the forms and submit it, then refreshes the page and go back to the previous page.

You can copy the code and paste it to run on the Java class that you have created with the help of the previous post written aboutinstalling and configuring the Eclipse IDE for running selenium webdriver scripts in Java.

Following is the quick introduction of the selenium webdriver scripts used on the Java class written above.

The first block of the codes started with import keyword will import required packages to the class. These packages will instantiate a new browser which will load required drivers.

The line of code “WebDriver driver = new ChromeDriver();” instantiates driver objects for Google chrome driver. When there is no parameters are added the browser will be launched on default mode.

The “driver.get()” command used just below the driver object opens the provided URL on the google chrome browser. The “driver.getTitle()” command retrieves the actual title of the page and “contentEquals()” method will compare with the expected title in order to verify the title of the page.

I have written “driver.findElement(By.linkText(“Contact Us”)).click();” command to find out the desired link and execute the click() command on it. “findElement(By.name())” method wil find the desired elements by name and “sendkeys()” fills the input field.

The command “driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);” holds the testing process for 10 seconds. “navigate().refresh()” and “navigate().back()” are the browser navigation commands that refreshes and return back to the previous page. The last command “driver.close();” closes the browser opened by the webdriver.

Refer to our next post about the selenium webdriver commands to get more information about most commonly used selenium webdriver commands.

Eclipse Selenium Webdriver Chrome

Running The Script for Firefox

In order to run the selenium webdriver script for Firefox browser, you have to add or replace the following codes.

Import the Firefox driver on the import block for automating the webpage on Firefox browser. Use the following line of code for importing the Firefox driver.

For the latest version of Firefox, you need to use gecko driver created by Mozilla. It should be used before instantiating driver object. For this down the gecko driver from GitHub and extract the compressed “.zip” file on any location of your drive i.e. “E:geckdriver.exe“. Now use this driver file with “System.setproperty()” method as given below.

Running the Script for IE

Same as running the selenium webdriver script for Firefox browser, you can run the script for IE also with making little change on the following lines of codes from the Java class given above.

At first, import the Internet Explorer driver server on the import block for automating the webpage on IE browser. Use the following line of code for importing the Internet Explorer driver server.

Now, download the Internet Explorer driver server file from the selenium website as shown on the image below. The driver server files are available for both 32-bit windows and 64-bit windows.

Now extract the compressed “.zip” file on any location of your drive i.e. “E:IEDriverServer.exe” and use the extracted driver file with “System.setProperty()” method as given below.

When there was an error while running the selenium webdriver script on the IE browser, verify the following settings on internet options security.

For this, go to IE toolbar, click on the gear icon and click on the internet options link. It will open the Internet Options dialog box. Now, go to the security tab and make sure that protected mode is enabled for all the zones i.e. Internet, Local intranet, Trusted sites and Restricted sites.

Eclipse download for selenium

Read Next: Selenium Webdriver Commands Required for Automated Testing

Software Testing4Shuseel BaralShuseel Baral is a web programmer and the founder of InfoTechSite has over 8 years of experience in software development, internet, SEO, blogging and marketing digital products and services is passionate about exceeding your expectations.
  • Website
  • Prev Post

    5 Best On-page SEO Tactics That Makes You #1 on Google

    Next Post

    25 Basic Selenium Webdriver Commands for Automated Testing

    Related Posts

    What Is Fuzz Testing And How Can Your Business Benefit?

    Top 20 MCQ Questions on Software Testing Tools

    How to Create Database Test Plan in JMeter using MySQL

    How to Use the Most Common Types of JMeter Listeners

    How to Use Different Types of Assertions in JMeter

    How to get started with JMeter – Step by Step Guide

    Write A Comment

    Configure Eclipse with Selenium Webdriver in Java

    1. Download Install for Eclipse Setup

    2. Download Selenium Webdriver

    3. Add Selenium Jar Files into Eclipse

    4. Download Third Party Browser Driver e.g(Gecko, Chrome etc…)

    1. Download Install and Setup Eclipse

    EclipseEclipse

    Step 1 :

    Go to google then search eclipse download.

    Click on Eclipse Downloads.

    Step 2 :

    In Eclipse website click on Download packages.

    Step 3 :

    Click on Windows 32 bit / 64 bit Under Eclipse IDE for Java EE Developers.

    Step 4 :

    Then Click on Eclipse Zip File for eclipse setup.

    Step 5 :

    Extract Downloaded Zip File.

    Step 6 :

    Open Extracted eclipse folder.

    Double click on eclipse Application to Run Eclipse setup.

    Step 7 :

    Select workspace location and click on Launch button for eclipse setup.

    Eclipse For Selenium Webdriver

    Step 8 :

    After Launching Eclipse.

    2. Download Selenium Webdriver

    Step 1 :

    Enter Download Selenium Webdriver in google.

    Click on First Link http://www.seleniumhq.org/download/

    Step 2 :

    Download Java latest Client version

    Step 3 :

    After Download Selenium Webdriver Add Jar files into Libraries.

    Extract Here Selenium Webdriver zip folder.

    3. Add Selenium Jar Files into Eclipse

    Step 4 :

    To add Selenium Jar files into Java Projects need to Create a new Java Project.

    Create a new Java Project.

    Step 5 :

    Enter Project Name

    Click on Next.

    Step 6 :

    Select Libraries tab and Click on Add External Jars.

    Step 7 :

    Select all Jar files selenium-java-3.8.1 folder.

    Select all Jars under libs folder also.

    Step 8 :

    After adding all Jar files Click on Finish button.

    4. Download Third Party Browser Driver e.g(Gecko, Chrome etc…)

    Step 1 :

    Go to http://www.seleniumhq.org/download/

    Click on Any Browser Version For e.g : Click on 0.19.0 GeckoDriver version.

    For

    For e.g :

    Mozilla GeckoDriver, Google Chrome Driver, Opera, Microsoft Edge Driver, HtmlUnitDriver etc…

    Eclipse For Selenium Webdriver Download

    Step 2 :

    Download GeckoDriver as per Operating System with 32 / 64 bit OS.

    We Download GeckoDriver for Windows as per 32 / 64 bit OS.

    Step 3 :

    After Downloading Extract here geckodriver-v0.19.1-win64 file.

    Selenium Ide Download

    Configure Eclipse with Selenium Webdriver in Java and Configure Eclipse with Selenium Webdriver in Java or and Configure Eclipse with Selenium Webdriver in Java selenium java Configure Eclipse with Selenium Webdriver in Java