Selenium tests using ChromeDriver [2026]
On This Page What is a Selenium ChromeDriver?
Ever tried runningSelenium tests on Chromeand assumed ChromeDriver would “ just work ”? I did. And it didn ’ t employment. Instead of a suave test run, I end up withfail hand, mismatch driver versions, and hours lost trying repair that should have be simple. ChromeDriver felt like the perfect solution—until I recognize it neededaccurate apparatus, the right versioning, and a clear agreement ofChrome-specific configurations. And with Chrome holding o'er 60 % of the global browser market share, get this correct isn ’ t optional—it ’ s indispensable for delivering unlined web experiences. Selenium ChromeDriver is the dedicated driver that permit Selenium communicate with the Chrome browser, enabling automated actions like clicking, typing, navigating, and validating UI behavior. It acts as the bridge between your Selenium scripts and real Chrome sessions. Key aspects of Selenium ChromeDriver: This clause search how to get ChromeDriver work properly, step by step, so your Selenium tests run faithfully on Chrome every single clip. Selenium ChromeDriver is a standalone viable that serves as thecommunicating interface between Selenium test scripts and the Google Chrome browser. It receives WebDriver commands from Selenium and translates them into native actions within Chrome, enablingautomated interactionssuch as navigation, element handling, and data retrieval. ChromeDriver cohere to theW3C WebDriver protocol, ensuring standardize and reliable browser mechanisation across different environments. By replicating existent user behavior within Chrome, it allows tester to validate functionality, performance, and user flows with high accuracy. Since Google Chrome is updated ofttimes,ChromeDriver must be aligned with the corresponding browser versionto hold compatibility and prevent performance failure. You can download ChromeDriver for Selenium as per the ChromeDriver variant expend its official site. Here are the steps given below: Step 1.Navigate toChromeDriver functionary sitefor downloading the latest ChromeDriver. Step 2.For Chrome browser version 115 and above, click on “ the Chrome for Testing availability dashboard ” which will navigate toChrome for Testing Dashboard. Step 3.This page has respective versions for Stable, Beta, Dev and Canary releases for Windows, Mac and Linux operating system. Click on Stable tie-in and look for ChromeDriver Win32 or Win64 (ground on the Windows OS system type). Step 4.Open the URL in the new browser window and ChromeDriver will be download in zip format. Extract the content and go it to the desired location. (Preferably at the root locating of the automationproject). Step 1.Navigate toChromeDriver official sitewhich name all the late and previous versions of ChromeDriver. Step 2.Based on the Chrome browser version uncommitted on the system download the various ChromeDriver. Assuming current Chrome browser version to be 114, click on “ChromeDriver 114.0.5735.90”. This page will voyage to the download section which has driver for Mac, Linux, and Windows. Step 3.Assuming the current system is Windows, click on “chromedriver_win32.zip”. Step 4. ChromeDriver will be downloaded in zip formatting. Extract the content and move it to the desired location. (Preferably at the root localisation of the automation project). Once the appropriate ChromeDriver is downloaded found on the Chrome browser variation, there are two methods available to configure ChromeDriver: through the environment variable or by expend the System.setProperty () method in Java. Downloading ChromeDriver is just the first pace in building robust Selenium automation tests on Chrome. Proper configuration, environment setup, and leverage Chrome-specific capabilities can significantly advance your test dependability and efficiency. Our experts can assist you with your essay challenges and strategy to maximize your automation success. Schedule a call with BrowserStack QA specialists to discuss your testing challenges, automation strategies, and tool integrations. Gain actionable insights tailored to your labor and check fast, more reliable software bringing. You can configure ChromeDriver expend different method On Windows, you can define system-level variable using theEnvironment Variablessettings. By append ChromeDriver to your system ’ s PATH, Selenium can automatically notice and use it without involve an explicit file path in your code. Once configured, every time a WebDriver illustration is created, Selenium will situate ChromeDriver directly from the scheme environment—simplifying setup and keeping your scripts cleaner. Below steps will facilitate you set up the environment variable for Chrome Driver. Step 1.After the ChromeDriver executable file is extracted and moved to the desired location, transcript that location to set its path in System ’ s environment variables. Step 2.Exposed Environment variable pop up by forthwith searching for “Environment Variables” from Windows Search. This will open “System Properties” pop up. Click on the “Environment Variables” button. Step 3.On Environment Variables pop-up ’ s System Variables section, chink on Path variable and dog on the Edit button. Step 4. On the Edit environment variable pop-up, detent on the “New” push and add the ChromeDriver executable positioning. Click on OK to salvage the shape. ChromeDriver can also be configured by explicitly fix the ChromeDriver path in the test script. System.setPropertyaccepts key value couplet wherekey would be “ webdriver.chrome.driver ” and valuewould be the path of the ChromeDriver exe path. If you ’ re work on macOS, here are the steps to secure ChromeDriver runs smoothly on your system. Read More: Selenium offers a range of Chrome-specific lineament that go beyond basic browser automation. These capabilities allow testers to fine-tune browser behavior, plow complex scenarios, and optimize test dependableness. Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script. By leveraging these functionalities, you can build a more robust Selenium framework—one that adapts to real-world weather, support advanced configurations, and delivers more exact test issue. Below are some of the key Chrome-focused features usable in Selenium: Selenium interacts with Chrome through ChromeDriver, which acts as a span. Make sure to download the appropriate version matching your Chrome browser. Running Chrome in headless mode with Selenium enables browser mechanisation without launching a graphical user interface (GUI). This significantly speeds up test execution and is especially useful in surroundings without a display—such as, remote servers, or containerise setups. Use headless mode when you necessitate faster, resource-efficient test runs without opening the browser window. Here ’ s how to enable it: Use ChromeOptionsto customize Chrome browser settings, such as enabling/disabling propagation, setting window size, or managing profiles by create an representative of ChromeOptions for setting ChromeDriver-specific capabilities. You can then pass the ChromeOptions object into the ChromeDriver constructor: Using browser profiles in Selenium with Chrome allows you to customize your screen surround by continue specific settings, cookies, and session data. This can be especially useful for automatise tests that require logged-in state or particular configurations. You can use exist user profile to retain cookies and setting across sessions. Handling pop-ups and alerts in Selenium when using Chrome involves specific method to interact with JavaScript alerting, verification boxes, and prompts. You can switch to and address alerts that appear in the browser. Executing JavaScript in Chrome employ Selenium provides a potent way to interact with web pages beyond standard WebDriver operation. It allows you to falsify the DOM, induction browser events, regain dynamic data, and perform activeness that may not be directly supported by Selenium APIs. With JavaScript performance, your commands run within the context of the presently loaded page, offering outstanding flexibility and control. Performance logging in Chrome using Selenium allows you to capture detailed execution metrics and web action while running your tests. This can be particularly utilitarian for dissect page load times, resource load, and overall performance. You can enable execution logging to capture metrics. The Chrome DevTools Protocol (CDP) provides a powerful interface for interacting with the Chrome browser & # 8217; s debugging features. In Selenium, you can use CDP to admittance advanced functionality, such as performance metrics, network interception, and more. CDP provide admittance to lineament that are not available through the standard Selenium WebDriver API. You can entrance detailed performance metrics to optimize web coating. Executing JavaScript in Chrome apply Selenium provides a powerful way to interact with web pages beyond standard WebDriver operations. It grant you to manipulate the DOM, trigger browser events, retrieve dynamic datum, and perform action that may not be directly supported by Selenium APIs. With JavaScript execution, your commands run within the circumstance of the currently loaded page, offering greater flexibility and control. Using Chrome extensions in Selenium can enhance your mechanization capabilities by allowing you to interact with additional browser features. To load a Chrome extension in Selenium, you can specify the route to the extension file (usually a.crxor unpacked extension directory) utilizeChromeOptions. Use options.addExtensions () to load a .crxfile or unpacked directory. Ensure that the path is correct. Using Chrome extension in Selenium allows you to enhance your automated examination by adding extra functionalities to the browser. You might load an extension for: Here ’ s how to run Selenium scripts on a Chrome browser using ChromeDriver. Now consider a test case model wherein you need to execute 2 mere steps: Did you know:There are more than. Don & # 8217; t miss out on testing across! Refer to the code snippet below to get a better sense of fulfil the steps remark above: If you are configuring ChromeDriver via the environment variable, delete the System.setProperty () line from the above code and it should act. Run Selenium Tests using ChromeDriver To check your tests run systematically across environments and real-world Chrome setups, local execution isn ’ t always enough. The following section explores how to execute Selenium tests onexistent Chrome browsers in the cloud using . Here ’ s are the steps to run Selenium Tests on Real Chrome Browsers with using BrowserStack SDK: Step 1.Download from the GitHub page. Step 2.Once it is downloaded, unzip it in a desired location in your local system. Step 3.Import the project in Eclipse via File- & gt; Import - & gt; General - & gt; Projects from Folder or Archive in Eclipse. Step 4.Once the project is imported it should have a structure like below. Open browser.yml file which contains all the required capacity to run the exam on BrowserStack platform. Step 5.Set username and password in thebrowserstack.ymlfile available at the beginning directory. Step 6.You can run the test cause on multiple device and browser combinations available at the BrowserStack cloud. Select the required combinations from the. Step 7.Copy and replace the program object in the browserstack.yml file like below. platforms: This is for running the test cases on 3 combinations. If you wish to run just on a single device you may edit the platforms accordingly. Step 8. In the Eclipse Marketplace, lookup for BrowserStack & gt; click Install & gt; Finish. Step 9.Add the above ChromeTest plan under src/test/java folder and com.browserstack package. This class should extend SeleniumTest as it has the setup and teardown methods. The simplified code is as below employ BrowserStack SDK. Step 10.Run ChromeTestas TestNG tryout and view the test result on Automate fascia. Here are the key better practices to follow when using Selenium ChromeDriver: Running Selenium ChromeDriver exam onreal devices and real browserensures that your application behaves as expected under real-user conditions. BrowserStack Automate create this possible by providing instant approach to a all-inclusive range of real device–browser combinations, enable accurate, reliable, and scalable testing. Here ’ s why BrowserStack Automate is an ideal selection for fulfill Selenium tests on existent device and browser: By running Selenium ChromeDriver tryout on real devices through BrowserStack Automate, teams gain higher confidence in application stability, compatibility, and, see every release meets real-world standards. Although it ’ s vital totryout web-apps for Chrome, it ’ s also important for a web app to be optimized for former browsers like Firefox, Safari, Edge, etc. Teams can leverage BrowserStack, which enable QAs to perform for their web apps across thousand of existent browsers and browser versions like Safari, Opera, Edge, etc. All real browser are installed on existent desktop and nomadic devices, thus providing the optimal environment for package quiz in. ChromeDriver is a standalone executable that allows Selenium to control the Google Chrome browser. It read Selenium WebDriver commands into real browser action such as navigation, clicking, and form interactions. Without ChromeDriver, Selenium can not automate Chrome or run tests in a Chrome environment. You must download the ChromeDriver version that matches your installed Chrome browser version. For Chrome 115+, use Chrome for Testing (CfT) download; for older variation, use the legacy ChromeDriver download page. Version mismatch can cause session failures and unpredictable behavior during test execution. Yes. ChromeDriver endorse headless execution through ChromeOptions. Running Chrome in headless mode speeds up test execution and is ideal for CI/CD pipelines or environments without a graphic interface. It provides the same browser capabilities, create it worthy for fast, automatise regression runs. On This Page # Ask-and-Contributeabout this topic with our Discord community. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.Selenium tests on Chrome using ChromeDriver in 2026
Overview
Want to run Selenium tests on Chrome?
What is a Selenium ChromeDriver?
How to download ChromeDriver for Selenium?
Steps to download ChromeDriver version 115 and above
Steps to download ChromeDriver version 114 and below
Get Expert QA Guidance Today
Want to run Selenium exam on Chrome?
How to configure ChromeDriver?
Configure ChromeDriver via Environment Variable
Step 5.Now whenever you will create an illustration of ChromeDriver in the Selenium script, it will automatically detect the ChromeDriver path from the system variable.driver = new ChromeDriver ();
Configure ChromeDriver via System.setProperty method
System.setProperty (`` webdriver.chrome.driver '', `` D: \\BStackDemo\\chromedriver.exe '');
Steps for macOS user
Chrome-Specific Functionalities in Selenium
1. ChromeDriver
2. Chrome Headless Mode
public stratum HeadlessChromeExample {public motionless void main (String [] args) {System.setProperty (`` webdriver.chrome.driver '', `` path/to/chromedriver ''); ChromeOptions options = new ChromeOptions (); options.addArguments (`` -- headless ''); // Enable headless way options.addArguments (`` -- disable-gpu ''); // Disable GPU hardware acceleration WebDriver driver = new ChromeDriver (options); driver.get (`` https: //www.example.com ''); // Perform operation ... driver.quit ();}}3. ChromeOptions
signification org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; meaning org.openqa.selenium.chrome.ChromeOptions; public class ChromeOptionsExample {public static void main (String [] args) {// Set the path to the ChromeDriver executable System.setProperty (`` webdriver.chrome.driver '', `` path/to/chromedriver ''); // Set Chrome options ChromeOptions options = new ChromeOptions (); options.addArguments (`` -- start-maximized ''); // Start maximise options.addArguments (`` -- disable-infobars ''); // Disable infobars // Initialize WebDriver WebDriver driver = new ChromeDriver (option); // Open a webpage driver.get (`` https: //www.example.com ''); // Close the browser driver.quit ();}}4. Browser Profiles
public category BrowserProfileExample {public stable void main (String [] args) {System.setProperty (`` webdriver.chrome.driver '', `` path/to/chromedriver ''); String userDataDir = `` C: /Users/ & lt; YourUsername & gt; /AppData/Local/Google/Chrome/User Data ''; String profileName = `` Profile 1 ''; ChromeOptions options = new ChromeOptions (); options.addArguments (`` user-data-dir= '' + userDataDir); options.addArguments (`` profile-directory= '' + profileName); WebDriver driver = new ChromeDriver (selection); driver.get (`` https: //www.example.com ''); // Perform operations ... driver.quit ();}}5. Handling Pop-ups and Alerts
public class HandleAlertExample {public still void main (String [] args) {System.setProperty (`` webdriver.chrome.driver '', `` path/to/chromedriver ''); WebDriver driver = new ChromeDriver (); driver.get (`` https: //www.example.com ''); // Trigger an alert (e.g., via JavaScript or a button dog) driver.findElement (By.id (`` triggerAlertButton '')) .click (); // Switch to the alert Alert alert = driver.switchTo () .alert (); System.out.println (`` Alert textbook: `` + alert.getText ()); alert.accept (); // Accept the alert driver.quit ();}}6. Executing JavaScript
import org.openqa.selenium.JavascriptExecutor; public course ExecuteJavaScriptExample {public static void main (String [] args) {System.setProperty (`` webdriver.chrome.driver '', `` path/to/chromedriver ''); WebDriver driver = new ChromeDriver (); driver.get (`` https: //www.example.com ''); // Execute JavaScript JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript (`` alerting ('Hello, World! '); ''); // Close the alert driver.switchTo () .alert () .accept (); driver.quit ();}}7. Performance Logging
importation org.openqa.selenium.logging.LogEntries; importation org.openqa.selenium.logging.LogEntry; importee org.openqa.selenium.logging.LogType; public category PerformanceLoggingExample {public static void main (String [] args) {System.setProperty (`` webdriver.chrome.driver '', `` path/to/chromedriver ''); ChromeOptions options = new ChromeOptions (); options.setCapability (`` goog: loggingPrefs '', Map.of (`` performance '', `` ALL '')); WebDriver driver = new ChromeDriver (choice); driver.get (`` https: //www.example.com ''); LogEntries logs = driver.manage () .logs () .get (LogType.PERFORMANCE); for (LogEntry log: logs) {System.out.println (log.getMessage ());} driver.quit ();}}8. Chrome DevTools Protocol (CDP)
import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.devtools.DevTools; import org.openqa.selenium.devtools.v93.browser.Browser; import org.openqa.selenium.devtools.v93.network.Network; import org.openqa.selenium.devtools.v93.performance.Performance; import org.openqa.selenium.WebDriver; import java.util.Optional; public class CDPExample {public inactive nothingness principal (String [] args) {// Set the path to the ChromeDriver executable System.setProperty (`` webdriver.chrome.driver '', `` path/to/chromedriver ''); // Set Chrome alternative ChromeOptions options = new ChromeOptions (); options.addArguments (`` -- remote-debugging-port=9222 ''); // Enable debug // Initialize WebDriver WebDriver driver = new ChromeDriver (options); // Access the DevTools interface DevTools devTools = ((ChromeDriver) driver) .getDevTools (); devTools.createSession (); // Enable network tag devTools.send (Network.enable (Optional.empty (), Optional.empty (), Optional.empty ())); // Intercept web request devTools.addListener (Network.requestWillBeSent (), request - & gt; {System.out.println (`` Request URL: `` + request.getRequest () .getUrl ());}); // Start capturing performance metric devTools.send (Performance.enable ()); // Open a webpage driver.get (`` https: //www.example.com ''); // Replace with your URL // Capture performance metrics devTools.addListener (Performance.metrics (), metrics - & gt; {System.out.println (`` Performance prosody: `` + metrics.getMetrics ());}); // Close the browser driver.quit ();}}9. Geolocation
import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; meaning org.openqa.selenium.devtools.DevTools; import org.openqa.selenium.devtools.v93.geolocation.Geolocation; importee org.openqa.selenium.WebDriver; import java.util.Optional; public class GeolocationExample {public static void main (String [] args) {// Set the path to the ChromeDriver executable System.setProperty (`` webdriver.chrome.driver '', `` path/to/chromedriver ''); // Set Chrome options ChromeOptions options = new ChromeOptions (); options.addArguments (`` -- remote-debugging-port=9222 ''); // Enable debug // Initialize WebDriver WebDriver driver = new ChromeDriver (options); // Access the DevTools interface DevTools devTools = ((ChromeDriver) driver) .getDevTools (); devTools.createSession (); // Set geolocation double latitude = 37.7749; // Example: San Francisco doubled longitude = -122.4194; double accuracy = 100; // Optional accuracy in measure // Send geolocation data devTools.send (Geolocation.setGeolocationOverride (Optional.of (latitude), Optional.of (longitude), Optional.of (truth))); // Open a webpage that uses geolocation driver.get (`` https: //www.example.com ''); // Replace with a URL that requests geolocation // Close the browser driver.quit ();}}10. Extensions in Chrome
meaning org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import java.nio.file.Paths; public family ChromeExtensionExample {public static nullity independent (String [] args) {// Set the path to the ChromeDriver executable System.setProperty (`` webdriver.chrome.driver '', `` path/to/chromedriver ''); // Set Chrome options ChromeOptions options = new ChromeOptions (); // Specify the path to the extension String extensionPath = `` path/to/your/extension.crx ''; // or path to unpacked extension directory options.addExtensions (Paths.get (extensionPath) .toFile ()); // Initialize WebDriver with the delimitate options WebDriver driver = new ChromeDriver (options); // Open a webpage driver.get (`` https: //www.example.com ''); // Replace with your URL // Your code to interact with the page and extension // Close the browser driver.quit ();}}Steps to run Selenium Tests on Chrome Browser
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public course ChromeTest {public static void primary (String args []) {WebDriver driver; //Setting system properties of ChromeDriver System.setProperty (`` webdriver.chrome.driver '', `` D: \\BStackDemo\\chromedriver.exe ''); //Creating an object of ChromeDriver driver = new ChromeDriver (); //launching the qualify URL driver.get (`` https: //bstackdemo.com/ '');}}How to run Selenium Tests on Real Chrome Browser using Automate
- os: Windows osVersion: 10 browserName: Chrome browserVersion: latest
- os: OS X osVersion: Monterey browserName: Safari browserVersion: 15.6
- deviceName: iPhone 13 osVersion: 15 browserName: Chromium deviceOrientation: portrait
packagecom.browserstack;importcom.browserstack.SeleniumTest;importorg.testng.Assert;importorg.testng.annotations.Test;public classChromeTestextendsSeleniumTest {@ Testpublic voidlaunchChrome () {// launch the specified URL driver.get (`` https: //bstackdemo.com/ ''); Assert.assertEquals(driver.getTitle (), `` StackDemo '');}}Best Practices for using Selenium ChromeDriver
Why run Selenium ChromeDriver Tests on Real Devices?
Want to run Selenium tests on Chrome?
Conclusion
FAQs
Related Guides
Automate This With SUSA
Test Your App Autonomously