Automation is now a critical detail of software program development, and Selenium stands proud as one of the leading tools for browser automation. if you plan to use Selenium with Java on macOS, the first step is to install ChromeDriver. ChromeDriver is a critical thing that enables Selenium to talk and interact with the Chrome browser, consequently making it feasible to automate many browsing responsibilities properly.
Steps to Set Up ChromeDriver with Selenium Java on MacOS
Step 1: Install Java
Java is necessary for running Selenium tests. to test if Java is installed to your machine:
- Open Terminal and run:
java -version
2. If Java isn't always mounted, set up it the use of Homebrew:
brew install openjdkStep 2. Install Homebrew (if not already installed)
Homebrew simplifies the installation of software on macos. the first step is to move account data and settings from one Mac device to another that has no installation Homebrew.
- if you do not have Homebrew formerly hooked up please do the subsequent to your terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 3. Installation of Google Chrome
By all means Google Chrome must be present in macOS. If it is not present as of now:
- download and install it from the goggle chrome website.
Step 4. Install ChromeDriver
ChromeDriver is the bridge among Selenium and Chrome to install it:
- Run the following command using Homebrew:
brew install chromedriver
2. As an substitute, you could manually download ChromeDriver from the legitimate ChromeDriver website online, extract it, and flow it to /usr/local/bin.
3. To verify that ChromeDriver is install and run:
chromedriver --version
Step 5. set up a Java project in IntelliJ (or any Java IDE)
Open IntelliJ or some other Java IDE
1. Open IntelliJ (or every other Java IDE)
2. Create a brand new project:
- select Java and set up Maven because its the project management tool.
3. pom.xml configuration of your challenge folder file:
- copy Selenium dependency and paste interior pom.xml document:
<dependencies>
<!-- Selenium Java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.9.1</version>
</dependency>
</dependencies>
Step 6. Selenium Test Code
- Create a new Java test in your challenge document folder (e.g., GoogleSearchTest).
- add the following Selenium Code to launch Chrome, conduct a Google search, and close the browser:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class SeleniumTest {
public static void main(String[] args) {
// Set the path to the ChromeDriver executable manually
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
// Initialize ChromeDriver
WebDriver driver = new ChromeDriver();
// Navigate to a website
driver.get("https://www.google.com/");
// Print the page title
System.out.println("Page title is: " + driver.getTitle());
// Close the browser
driver.quit();
}
}
Output

Step 7. Execute the Test
- Make use of your IDE to compile and Run the Java code.
- In the ideal circumstances, Chrome will launch, go to Google and this web page notice will appear on the console.
Step 8. Add ChromeDriver to your profile’s path
If you no longer want to use Homebrew or WebDriverManager and would like to install ChromeDriver by yourself it is still possible:
- Edit .zshrc file or .bash_profile file.
- One more time, do this in your practical terminal arg-script here, please, in case you have forgotten what and may be even the command is still on your terminal:
export PATH=$PATH:/usr/local/bin/3. clip the orientation of the directive about the direction of the chromedriver and type in the command supply ~/.zshrc or bother about the source file .bask_profile that it changed as the document was opened for the relative updates.
Conclusion
So in this way and from the instructions given above you have successfully installed the ChromeDriver using Selenium Java in the macOS operating system. This setup is critical for automating browser responsibilities or attempting out web applications with the Chrome browser. Bear in mind to keep both Chrome and ChromeDriver updated to maintain compatibility..