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).

Link: https://sites.google.com/a/chromium.org/chromedriver/downloads

chrome-driver-home-pagechrome-driver-home-page

Download mac64_m1.zip if your mac has Apple Silicon M1 CPU otherwise select the mac64.zip version if your mac has Intel CPU.

select-chrome-driver-versionselect-chrome-driver-version

Step2: Move the driver to the /usr/local/bin folder

Now, we can move the driver to a path that 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.

WebDriver driver = new ChromeDriver();

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.

<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->  
<dependency>
  <groupId>io.github.bonigarcia</groupId>
  <artifactId>webdrivermanager</artifactId>
  <version>4.4.3</version>
</dependency>

Then you can simply use it as follows:

 WebDriverManager.chromedriver().setup();
 driver = new ChromeDriver();

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. 😉

Thanks.
Onur

onur baskirtonur baskirt

Onur Baskirt is a Software Quality Leader with international experience in world-class companies. Now, he is a Lead Technical Consultant at Emirates Airlines in Dubai.

Xổ số miền Bắc