WebDriver Types
Different types of WeDriver implementations and their set up
As discussed WebDriver is an interface and there are several implementations of the same in Selenium. Selenium supports most of the web browsers and provides implementations for them. Some of the popular ones are
Chrome
FireFox
Safari
etc.,
Example:
WebDriver driver = new ChromeDriver();
//or
WebDriver driver = new FirefoxDriver();
//or
WebDriver driver = new SafariDriver();
Example:
//For Chrome browser
System.setProperty("webdriver.chrome.driver","/path-to-driver.exe");
WebDriver driver = new ChromeDriver();
//For Firefox browser
System.setProperty("webdriver.gecko.driver","/path-to-driver.exe");
WebDriver driver = new FirefoxDriver();
If we don't keep the binaries in root or set the path selenium is going throw an exception saying webdriver path has not been set.
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
Last updated
Was this helpful?