WebDriver Installation and Initialization for Different Browsers
Here we will see how to install driver for different browsers and use it for creating WebDriver session.
We'll cover the following
Before beginning #
Most WebDriver implementations require an additional executable for Selenium to communicate with the browser.
We can manually add the executable before starting WebDriver session, but this can make the framework less portable as the executables are platform-dependent and need to be in the same place on every machine or include the executables with the framework.
By adding the driver to the system classpath, selenium will be able to locate the executables without bundling them with the framework.
Downloading & installation of WebDriver #
Download WebDriver #
For downloading driver executables of different browsers:
Chrome: https://sites.google.com/a/chromium.org/chromedriver/downloads
Firefox: https://github.com/mozilla/geckodriver
Edge: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Internet Explorer: https://selenium-release.storage.googleapis.com/index.html
Opera: https://github.com/operasoftware/operachromiumdriver/releases
Adding WebDriver to classpath #
Windows
setx /m path "%path%;C:\selenium-drivers\bin"
Linux/Macintosh
sudo mkdir -p $HOME/selenium-drivers
export PATH=$PATH:$HOME/selenium-drivers >> ~/.profile
Setting driver path and creating WebDriver instance #
The path of the driver can be set explicitly, and WebDriver instance of different browsers can be created using the following code.
Get hands-on with 1400+ tech skills courses.