Launch Chrome Browser / Safari Browser:

 

1. Launch Chrome Browser using Selenium

 

  • WebDrivers for different browsers:  FirefoxDriver() for Firefox browser, ChromeDriver() for Google Chrome, SafariDriver() for Safari Browser, InternetExplorerDriver for Internet Explorer etc.
  • Webdriver is an Interface and ChromeDriver() is a class which has implemented Webdriver Interface.
  • Interface, there is a set of variables and methods without any body (no implementation, only method name and signature). We can not instantiate objects from the interface.
  • WebDriver is an interface which contains all the unimplemented common methods, which can be used for any browser e.g. getTitle(), getCurrentUrl(), get(), findElement() etc.

 

Download ChromeDriver.exe:

 

  • Set Webdriver.chrome.driver property to chromeDriver.exe instead.
  • System.setProperty (“webdriver.chrome.driver”, “chromeDriver.exe path”);

 

Launching Chrome Browser:

 

Example of Launching Chrome Browser:

 

Output: 

 

Importing Packages:

  • import org.openqa.selenium.WebDriver;
  • import org.openqa.selenium.chrome.ChromeDriver;
  • Using Above packages selenium launch chrome browser.

 

 

2. Launch Safari Browser using Selenium

 

  • WebDrivers for different browsers: FirefoxDriver() for Firefox browser, ChromeDriver() for Google Chrome, SafariDriver() for Safari Browser, InternetExplorerDriver for Internet Explorer etc.
  • Webdriver is an Interface and SafariDriver() is a class which has implemented Webdriver Interface.
  • WebDriver is an interface which contains all the unimplemented common methods, which can be used for any browser e.g. getTitle(), getCurrentUrl(), get(), findElement() etc.
  • The Safari browser does not require any additional configuration and can be launched immediately with the Safari driver.

 

launching Safari browser:

 

Example of launching Safari browser:

Output: 

 

Importing Packages:

  • import org.openqa.selenium.WebDriver;
  • import org.openqa.selenium.safari.SafariDriver;
  • Using Above packages selenium launch Safari browser.