Chris Kenst
The ChromeDriver getting started guide isn’t super helpful if you are unfamiliar with including the ChromeDriver location in your PATH environment variable. (The PATH variable helps Chrome find the downloaded ChromeDriver exe). Also it’s a lot of work for something so common. Never fear, here is a better way:
Installing on macOS:
Listed in order of easiest to hardest install, these are the best ways to install ChromeDriver on a Mac:
- The easiest way to install ChromeDriver is to use your package manager such as brew or npm to install the driver.
- In your terminal window with the Homebrew package manager:
- Install ChromeDriver with brew install cask chromedriver
- Confirm it was installed using chromedriver —version and seeing it returns a version. If it errors it wasn’t installed
- Other package managers like npm have similar commands npm install chromedriver
- In your terminal window with the Homebrew package manager:
- Run Chrome & ChromeDriver in a container using Docker. Simply download the combined container, start it and point your code at the right address.
- Specify it in your Selenium setup code and check it into source control like any other configuration detail. If you go this route, you can include additional drivers like GeckoDriver (aka Firefox) as well.
- Download the driver and add its location to your System PATH.
Which methods have you found the easiest or most success with? Which methods didn’t work for you? Please leave a comment below.
Additional Resources
Oh and if this article worked for you please consider sharing it or buying me coffee to say thanks.
Источник
Installing browser drivers
Through WebDriver, Selenium supports all major browsers on the market such as Chrom(ium), Firefox, Internet Explorer, Opera, and Safari. Where possible, WebDriver drives the browser using the browser’s built-in support for automation, although not all browsers have official support for remote control.
WebDriver’s aim is to emulate a real user’s interaction with the browser as closely as possible. This is possible at varying levels in different browsers.
Even though all the drivers share a single user-facing interface for controlling the browser, they have slightly different ways of setting up browser sessions. Since many of the driver implementations are provided by third parties, they are not included in the standard Selenium distribution.
Driver instantiation, profile management, and various browser specific settings are examples of parameters that have different requirements depending on the browser. This section explains the basic requirements for getting you started with the different browsers.
Adding Executables to your PATH
Most drivers require an extra executable for Selenium to communicate with the browser. You can manually specify where the executable lives before starting WebDriver, but this can make your tests less portable as the executables will need to be in the same place on every machine, or include the executable within your test code repository.
By adding a folder containing WebDriver’s binaries to your system’s path, Selenium will be able to locate the additional binaries without requiring your test code to locate the exact location of the driver.
- Create a directory to place the executables in, like C:\WebDriver\bin or /opt/WebDriver/bin
- Add the directory to your PATH:
- On Windows — Open a command prompt as administrator and run the following command to permanently add the directory to your path for all users on your machine:
- Bash users on macOS and Linux — In a terminal:
You are now ready to test your changes. Close all open command prompts and open a new one. Type out the name of one of the binaries in the folder you created in the previous step, e.g.:
If your PATH is configured correctly, you will see some output relating to the startup of the driver:
You can regain control of your command prompt by pressing Ctrl+C
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 10 | Microsoft | Downloads | Issues |
Internet Explorer | Windows | Selenium Project | Downloads | Issues |
Safari | macOS El Capitan and newer | Apple | Built in | Issues |
Opera | Windows/macOS/Linux | Opera | Downloads | Issues |
Chromium/Chrome
To drive Chrome or Chromium, you have to download chromedriver and put it in a folder that is on your system’s path.
On Linux or macOS, this means modifying the PATH environmental variable. You can see what directories, separated by a colon, make up your system’s path by executing the following command:
To include chromedriver on the path, if it is not already, make sure you include the chromedriver binary’s parent directory. The following line will set the PATH environmental variable its current content, plus an additional path added after the colon:
When chromedriver is available on your path, you should be able to execute the chromedriver executable from any directory.
To instantiate a Chrome/Chromium session, you can do the following:
Источник
Downloads
If you are using Chrome version 9 5 , please download ChromeDriver 95.0.4638.17
If you are using Chrome version 9 4 , please download ChromeDriver 94.0.4606.61
If you are using Chrome version 9 3 , please download ChromeDriver 93.0.4577.63
For older version of Chrome, please see below for the version of ChromeDriver that supports it.
If you are using Chrome from Dev or Canary channel, please following instructions on the ChromeDriver Canary page.
For more information on selecting the right version of ChromeDriver, please see the Version Selection page.
Supports Chrome version 95
Resolved issue 3857: Host header or origin header is specified and is not whitelisted or localhost [Pri-1]
Added ` —allowed-origins ` argument
For more details, please see the release notes .
Supports Chrome version 9 5
Resolved issue 3857: Host header or origin header is specified and is not whitelisted or localhost [Pri-1]
Added ` —allowed-origins ` argument
For more details, please see the release notes .
Supports Chrome version 94
For more details, please see the release notes .
Supports Chrome version 9 4
For more details, please see the release notes .
Supports Chrome version 93
For more details, please see the release notes .
Supports Chrome version 9 3
For more details, please see the release notes .
Supports Chrome version 92
For more details, please see the release notes .
Supports Chrome version 9 2
Resolved issue 3389: Host validation for ChromeDriver requests
For more details, please see the release notes .
Supports Chrome version 91
Resolved issue 1205107 : Unable to get attribute value for fields on the web application.
For more details, please see the release notes .
Supports Chrome version 91
Resolved issue 3744: SendKeys() and Click() silently fail after link navigation
Resolved issue 3746: attribute endpoint incorrectly updates values
For more details, please see the release notes .
Supports Chrome version 90
Resolved issue 3708: GetElementLocation’s inView fails for elements in shadow DOM
Resolved issue 3721: Collect performance log for service worker when enabled
Resolved issue 3731: AdbImpl::GetPidByName does not work correctly on non-standard Android OS’s like on OnePlus
Resolved issue 3733: Catastrophic failure with domain on localhost
Resolved issue 3734: Driver should Error Attempting to set Cookie on Wrong Domain
Resolved issue 3743: Refactor call function and fix remove element issue
For more details, please see the release notes .
Supports Chrome version 89
Resolved issue 3667: Timed out receiving a message from renderer
Resolved issue 3675: GetElementLocation uses inView method which mishandles boolean as array
Resolved issue 3682: GetElementRegion returns incorrect size for elements which are partially out of viewport
Resolved issue 3690: ChromeDriver fails if extensions use chrome.windows API
For more details, please see the release notes .
Supports Chrome version 88
Resolved issue 3641: Page not getting loaded/rendered when browser window is not in focus with Chrome Beta v87 and chromedriver v(87/86)
For more details, please see the release notes .
Supports Chrome version 88
Resolved issue 3611: getText() output in protractor different from .innerText
Resolved issue 3625: Improve element screenshot compatibility
Resolved issue 3628: Stale Element Reference and wrong URL reported back with URL having another URL as part of its path
Resolved issue 3631: Add support for the `webauthn:extension:largeBlob` capability
Resolved issue 3635: Chromedriver 86 — chromedriver .quit() doesn’t seem to pass unload event properly
Resolved issue 3649: Copying selected text to clipboard does not work on Windows 10 when using headless mode
For more details, please see the release notes .
Supports Chrome version 87
Resolved issue 3641: Page not getting loaded/rendered when browser window is not in focus with Chrome Beta v87 and chromedriver v(87/86)
Resolved issue 3657: Screenshot background browser timed out
For more details, please see the release notes .
Supports Chrome version 87
Resolved issue 2421: Delete old port-forwarding channels on android adb-server
Resolved issue 3474: Emulated mobile device list needs updating
Resolved issue 3507: Implement «get computed role»
Resolved issue 3508: Implement «get computed label»
Resolved issue 3584: Rename ChromeDriver command line option —whitelisted-ips
Resolved issue 3588: Bidi WebSocket connection
Resolved issue 3594: Navigation completes prematurely if OOPIF loads before main page
Resolved issue 3598: A command line option for devtools port to be forwarded to webview_devtools_remote socket
Resolved issue 3608: Chromedriver debuggerAddress does not support ipv6
For more details, please see the release notes .
Supports Chrome version 86
Resolved issue 3370: Shut down Chrome gracefully or cookie will not be correctly saved to SQLite persistence file
Resolved issue 3401: Get Element Location JS does not locate the visible center of the element
Resolved issue 3462: For sendKeys, CMD key don’t work for MAC
Resolved issue 3541: Improve log between Client and ChromeDriver
Resolved issue 3559: Output Chrome version when ChromeDriver reports incompatible
For more details, please see the release notes .
Supports Chrome version 85
Resolved issue 3578: Chrome 85 no longer allows graceful interaction with windows when an alert dialog is open
For more details, please see the release notes .
Supports Chrome version 85
Resolved issue 3577: ChromeDriver 85 does not detect changed Chrome directory (C:\Program Files)
For more details, please see the release notes .
Supports Chrome version 85
Resolved issue 3214: ChromeDriver78: Sendkeys resets text selection with contenteditable
Resolved issue 3376: Remove LaunchApp command from ChromeDriver
Resolved issue 3432: Sometimes NavigationTracker fails to detect when the page has finished loading
Resolved issue 3481: New Print endpoint according to w3c spec
Resolved issue 3488: driver.get doesn’t throw error when proxy is wrong configured
Resolved issue 3502: Use document.hasFocus() to check if element is focused
Resolved issue 3515: selenium.common.exceptions.WebDriverException: Message: unknown error: bad inspector message
For more details, please see the release notes .
Источник
How to Install Chrome Driver on Mac
Hi, in this tutorial we will learn how to install chrome driver on Mac OS. It is very easy. 😉
Step1: Download Chrome Driver
You need to go to the below address and download the chrome driver for Mac operating system based on (M1 or Intel chip versions).
Download mac64_m1.zip if your mac has Apple Silicon M1 CPU otherwise select the mac64.zip version if your mac has Intel CPU.
Step2: Move the driver to the /usr/local/bin folder
Now, we can move the driver a path which is defined as a path in your system. You can check them with the below command and you will see that /usr/local/bin folder is defined as a global path on your system.
sudo nano /etc/paths
If you want you can add a specific path here and you can move the chromedriver to this folder but as you see, /usr/local/bin folder is defined as a path by default.
Now, go to your downloads folder, find the chromedriver_mac64.zip file and unpack it. You will see the chromedriver executable file.
Now, we can run the below command and move the chromedriver file to the /usr/local/bin folder.
mv chromedriver /usr/local/bin
And now, you can define chrome driver as shown below in your tests and you can run your selenium tests by using Chrome driver.
If you face “Error: “chromedriver” cannot be opened because the developer cannot be verified. Unable to launch the chrome browser“, you need to go to usr/local/bin folder and right-click chromeDriver file and open it. After this step, re-run your tests, chrome driver will work.
Also, you can use Bonigarcia Webdriver Manager library in your project, for this you need to add its dependency in your project.
Then you can simply use it as follows:
For more complex usage please refer to the webdriver manager GitHub page .
I hope this article helps you and thanks for reading. 🙂 Please feel free to write your comments and questions. 😉
Onur Baskirt is a senior IT professional with 15+ years of experience. Now, he is working as a Senior Technical Consultant at Emirates Airlines in Dubai.
Источник