Monday, September 18, 2017

First Selenium Webdriver Script Using Safari Driver

First Selenium Webdriver Script Using Safari Driver

In this article, we will discuss about the Safari Web Driver. Like Firefox Web Driver, Here Safari webdriver doesn't require any additional utility to be set before launching the browser.The Selenium package automatically detect the driver. Thus, user can directly launch the Safari Browser similar to that of Mozilla Firefox.

Following source code is use to run the script using Safari Driver:
package demo;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.safari.SafariDriver;

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 Safari driver  ");

        // Instantiate the Safari  driver
        driver = new SafariDriver();

        // 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 Safari Driver


Then it will launch the Safari browser and load the page.
First Selenium Webdriver Script Using Safari Driver


No comments:

Post a Comment