Sunday, September 17, 2017

First Selenium Webdriver Script Using Mozilla Firefox Driver

First Selenium Webdriver Script Using Mozilla Firefox Driver

In this article, we will discuss about the Mozilla Firefox Web Driver. Firefox is the most traditional browser, Selenium WebDriver doesn't require any additional utility to be set before launching the browser.The Selenium package automatically detect default location of the firefox.exe, User need not to set any other property. FirefoxDriver comes as a part of Selenium package and is present in xpi format.

Following source code is use to run the script using Mozilla Firefox Driver:

SeleniumDemo.java
package demo;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class SeleniumDemo {

    // variable name
    public static WebDriver driver;

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        System.out.println("Launching the Mozilla Firefox driver  ");

        // Instantiate the Mozilla Firefox driver
        driver = new FirefoxDriver();

        // set the browser URL in get() to load the webpage
        driver.get("https://www.google.com");
        
        // Close the driver
        driver.quit();

    }

}

To run and execute the code in Eclipse IDE, you need to follow the below step:
  • On Eclipse's menu bar, click Run > Run.
First Selenium Webdriver Script Using Mozilla Firefox Driver


Then it will launch the Mozilla Firefox browser and load the page.


First Selenium Webdriver Script Using Mozilla Firefox Driver





No comments:

Post a Comment