Using the Selenium WebDriver - Unable to launch chrome browser on Mac


While working with Selenium webdriver, we may be unable to launch the Chrome browser on Mac. However, it can be avoided by following the steps listed below −

Step1 − Navigate to the link:https://sites.google.com/chromium.org/driver/ and click on the download link of the chromedriver version which is compatible with our local chrome browser.

Step2 − Click on the chromedriver link available for the Mac operating system.

Step3 − Once the download of the zip file gets completed, unzip it to get the chromedriver.exe file. Save it to a desired location.

Step4 − While mentioning the path of the chromedriver.exe file in the System.setProperty method, we can mention only chromedriver instead of chromedriver.exe.

Code Implementation

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class FirstAssign {
   public static void main(String[] args) {
      //configure path of chromedriver.exe
      System.setProperty("webdriver.chrome.driver", "chromedriver");
      //ChromeDriver instance
      WebDriver driver = new ChromeDriver();
      //implicit wait
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      //url launch
      driver.get
      ("https://www.tutorialspoint.com/about/about_careers.htm");
      System.out.println("Page title: "+ driver.getTitle());
      //browser quit
      driver.quit();
   }
}

Output

Updated on: 25-Jun-2021

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements