Contents
Install browser drivers
Setting up your browser to be automated. Through WebDriver, Selenium supports all major browsers on the market such as Chrom ( ium ), Firefox, Internet Explorer, Edge, Opera, and Safari. Where potential, WebDriver drives the browser using the browser ’ s built-in accompaniment for automation. Since all the driver implementations except for Internet Explorer are provided by the browser vendors themselves, they are not included in the standard Selenium distribution. This section explains the basic requirements for getting you started with the different browsers. Read about more advanced options in our Capabilities software documentation.
Reading: Install browser drivers
Quick Reference
Browser | Supported OS | Maintained by | Download | Issue Tracker |
---|---|---|---|---|
Chromium/Chrome | Windows/macOS/Linux | Downloads | Issues | |
Firefox | Windows/macOS/Linux | Mozilla | Downloads | Issues |
Edge | Windows/macOS | Microsoft | Downloads | Via Browser |
Internet Explorer | Windows | Selenium Project | Downloads | Issues |
Safari | macOS High Sierra and newer | Apple | Built in | Issues |
Opera | Windows/macOS/Linux | Opera | Downloads | Issues |
Three Ways to Use Drivers
1. Driver Management Software
Most machines mechanically update the browser, but the driver does not. To make sure you get the correct driver for your browser, there are many third party libraries to assist you .
// Use WebDriver Manager : hypertext transfer protocol : //github.com/bonigarcia/webdrivermanager
// Import WebDriver Manager : significance io.github.bonigarcia.wdm.WebDriverManager ;
// Call frame-up ( ) method for the browser driver you want : WebDriverManager. chromedriver ( ). setup ( ) ;
// Initialize your driver as you normally would : ChromeDriver driver = modern ChromeDriver ( ) ;
# Use Webdriver Manager for Python : hypertext transfer protocol : //github.com/SergeyPirogov/webdriver_manager
# Import code :
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
# Use the `install ( ) ` method acting to set `executabe_path` in a raw `Service` case :
service = Service ( executable_path = ChromeDriverManager ( ). install ( ) )
# Pass in the `Service` exemplify with the `service` keyword :
driver = webdriver. chrome ( service = military service )
// Use WebDriver Manager box : hypertext transfer protocol : //github.com/rosolko/WebDriverManager.Net
// Import the dependencies : using WebDriverManager ;
using WebDriverManager.DriverConfigs.Impl ;
// Use the `SetUpDriver ( ) ` which requires a config class : modern DriverManager ( ). SetUpDriver ( new ChromeConfig ( ) ) ;
// Initialize your driver as you normally would : volt-ampere driver = new ChromeDriver ( )
# Use webdrivers gem : hypertext transfer protocol : //github.com/titusfortner/webdrivers
# Add jewel to Gemfile :
jewel 'webdrivers ', '~ > 5.0 '
# Require webdrivers in your stick out :
ask 'webdrivers '
# Initialize driver as you normally would :
driver = selenium : : WebDriver. for : chrome
// There is not a recommended driver director for JavaScript at this clock
// Use WebDriverManager : hypertext transfer protocol : //github.com/bonigarcia/webdrivermanager
// Import the library import io.github.bonigarcia.wdm.WebDriverManager
// Call the setup method before initializing the driver as you normally would : fun chrome ( ) : WebDriver {
WebDriverManager. chromedriver ( ). frame-up ( )
return ChromeDriver ( )
}
2. The PATH
Environment Variable
This choice first gear requires manually downloading the driver ( See Quick Reference Section for links ). This is a elastic option to change localization of drivers without having to update your code, and will work on multiple machines without requiring that each machine put the drivers in the same place. You can either place the drivers in a directory that is already listed in PATH
, or you can place them in a directory and add it to PATH
.
- To see what directories are already on
PATH
, open a Command Prompt / Terminal and type:
echo $PATH
echo %PATH%
- If the directory you want to place the drivers is not already on PATH, you need to add it:
export PATH=$PATH:/opt/WebDriver/bin >> ~/.profile
setx PATH "%PATH%;C:\WebDriver\bin"
- You can test if it has been added correctly by starting the driver:
chromedriver
- If your
PATH
is configured correctly,
you will see some output relating to the startup of the driver:
Starting ChromeDriver 95.0.4638.54 (d31a821ec901f68d0d34ccdbaea45b4c86ce543e-refs/branch-heads/4638@{#871}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
You can regain control of your command prompt by pressing Ctrl+C
3. Hard Coded Location
exchangeable to Option 2 above, you need to manually download the driver ( See Quick Reference Section for links ). Specifying the placement in the code itself has the advantage of not needing to figure out Environment Variables on your arrangement, but has the drawback of making the code much less flexible .
system. setProperty ( `` webdriver.chrome.driver '', `` /opt/WebDriver/bin/chromedriver '' ) ;
ChromeDriver driver = new ChromeDriver ( ) ;
service = Service ( executable_path = `` /opt/WebDriver/bin/chromedriver '' )
driver = webdriver. chrome ( service = service )
volt-ampere driver = new ChromeDriver ( @ '' C : \WebDriver\bin '' ) ;
service = selenium : : WebDriver : : Service. chrome ( path : '/opt/WebDriver/bin/chromedriver ' )
driver = selenium : : WebDriver. for : chrome, service : service
const { builder } = ask ( 'selenium-webdriver ' ) ;
const serve = fresh chrome. ServiceBuilder ( '/opt/WebDriver/bin/chromedriver ' ). build ( ) ;
const driver = new builder ( ). forBrowser ( 'chrome ' ). setChromeService ( service ). build ( ) ;
// Please raise a PR to add code sample
Starting Browsers
Chromium/Chrome
By default, Selenium 4 is compatible with Chrome v75 and greater. note that the interpretation of Chrome and the translation of chromedriver must match the major translation. See the Quick Reference section for the applicable download connection. Examples for how to start Chrome are provided in the previous section detailing the Three Ways to Use Drivers .
Edge
Microsoft Edge is implemented with Chromium, with the earliest subscribe version of v79. similar to Chrome, the translation of Edge and the adaptation of edgedriver must match the major version. See the Quick Reference section for the applicable download connection .
meaning org.openqa.selenium.WebDriver ;
spell org.openqa.selenium.edge.EdgeDriver ;
WebDriver driver = raw EdgeDriver ( ) ;
from selenium.webdriver meaning edge
driver = edge ( )
using OpenQA.Selenium ;
using OpenQA.Selenium.Edge ;
IWebDriver driver = raw EdgeDriver ( ) ;
necessitate `` selenium-webdriver ''
driver = selenium : : WebDriver. for : edge
const { builder } = want ( 'selenium-webdriver ' ) ;
volt-ampere driver = new builder ( ). forBrowser ( 'edge ' ). build up ( ) ;
import org.openqa.selenium.WebDriver
significance org.openqa.selenium.Edge.EdgeDriver
val driver : WebDriver = EdgeDriver ( )
Firefox
selenium 4 requires Firefox 78 or greater. It is recommended to always use the latest version of geckodriver. See the Quick Reference section for the applicable download link .
import org.openqa.selenium.WebDriver ;
consequence org.openqa.selenium.firefox.FirefoxDriver ;
WebDriver driver = new FirefoxDriver ( ) ;
from selenium.webdriver import Firefox
driver = Firefox ( )
using OpenQA.Selenium ;
using OpenQA.Selenium.Firefox ;
IWebDriver driver = newly FirefoxDriver ( ) ;
ask `` selenium-webdriver ''
driver = selenium : : WebDriver. for : firefox
const { builder } = ask ( 'selenium-webdriver ' ) ;
volt-ampere driver = fresh builder ( ). forBrowser ( 'firefox ' ). build ( ) ;
import org.openqa.selenium.WebDriver
consequence org.openqa.selenium.Firefox.FirefoxDriver
val driver : WebDriver = FirefoxDriver ( )
Internet Explorer
The Selenium project aims to support the same releases that Microsoft considers current. Older releases may work, but will not be supported. note that Internet Explorer 11 will end patronize for sealed operating systems, including Windows 10 on June 15, 2022. Edge has an IE Compatibility mood that will continue to be supported. The IE Driver is the entirely driver maintained by the Selenium Project directly. While binaries for both the 32-bit and 64-bit versions of Internet Explorer are available, there are some limitations with the 64-bit driver. As such it is recommended to use the 32-bit driver. It should be noted that as Internet Explorer preferences are saved against the logged in drug user ’ sulfur bill, some extra setup is required. extra information about using Internet Explorer can be found on the Selenium wiki, and you can see the Quick Reference section for the applicable download link .
consequence org.openqa.selenium.WebDriver ;
consequence org.openqa.selenium.ie.InternetExplorerDriver ;
WebDriver driver = modern InternetExplorerDriver ( ) ;
from selenium.webdriver import i
driver = i ( )
using OpenQA.Selenium ;
using OpenQA.Selenium.IE ;
IWebDriver driver = new InternetExplorerDriver ( ) ;
command `` selenium-webdriver ''
driver = selenium : : WebDriver. for : i
const { builder } = command ( 'selenium-webdriver ' ) ;
volt-ampere driver = newfangled builder ( ). forBrowser ( 'internet internet explorer ' ). build ( ) ;
import org.openqa.selenium.WebDriver
import org.openqa.selenium.ie.InternetExplorerDriver
val driver : WebDriver = InternetExplorerDriver ( )
Opera
current releases of Opera are built on top of the Chromium locomotive, and WebDriver is now supported via the closed-source Opera Chromium Driver .
import org.openqa.selenium.WebDriver ;
import org.openqa.selenium.opera.OperaDriver ;
WebDriver driver = new OperaDriver ( ) ;
from selenium.webdriver import opera
driver = opera ( )
using OpenQA.Selenium ;
using OpenQA.Selenium.Opera ;
IWebDriver driver = new OperaDriver ( ) ;
# not presently implemented
const { builder } = want ( `` selenium-webdriver '' ) ;
volt-ampere driver = raw builder ( ). forBrowser ( 'opera ' ). build ( ) ;
import org.openqa.selenium.WebDriver
import org.openqa.selenium.opera.OperaDriver
val driver : WebDriver = OperaDriver ( )
Safari
Unlike Chromium and Firefox drivers, the safaridriver is installed with the operate System. To enable automation on Safari, run the follow command from the terminal :
safaridriver --enable
import org.openqa.selenium.WebDriver ;
spell org.openqa.selenium.safari.SafariDriver ;
WebDriver driver = newly SafariDriver ( ) ;
from selenium.webdriver import campaign
driver = campaign ( )
using OpenQA.Selenium ;
using OpenQA.Selenium.Safari ;
IWebDriver driver = new SafariDriver ( ) ;
command `` selenium-webdriver ''
driver = selenium : : WebDriver. for : campaign
const { builder } = want ( 'selenium-webdriver ' ) ;
volt-ampere driver = fresh builder ( ). forBrowser ( 'safari ' ). human body ( ) ;
significance org.openqa.selenium.WebDriver
import org.openqa.selenium.safari.SafariDriver
val driver : WebDriver = SafariDriver ( )
Those looking to automate Safari on io should look to the Appium project .