App & Browser Testing Made Easy

Give your users a seamless experience by testing on 3000+ real devices and browsers. Don't compromise with emulators and simulators

Home Guide Understanding setProperty in Selenium

Understanding setProperty in Selenium

By Jash Unadkat, Technical Content Writer at BrowserStack -

Table of Contents

Deciding which browser to test on is the first step in automating tests for a website or a web-app. As a result, defining the system properties and initializing the browser object becomes necessary, especially before writing test scripts. The setProperty() method helps QAs do exactly that.

This article explains the setProperty method in Selenium with a sample program.

What is setProperty in Selenium?

As the name suggests, the setProperty method enables QAs to set the properties for the desired browser to be used in test automation.

The setProperty method has two attributes – “propertyName” and “value.” The propertyName represents the name of the browser-specific driver, and the value points to the path of that browser driver.

Example :


What is the use of setProperty method?

To automate tests for a specific browser, QAs need to download the browser-specific drivers first as browsers do not have built-in servers for test automation. These drivers act as a bridge between test scripts and browsers for test automation.

One can check the complete list of available browser drivers on the official site of Selenium. Once the driver is downloaded for a specific browser, QAs need the setProperty() method to define the path for that driver before writing any test cases.
This helps the Selenium WebDriver identify the browser on which tests are to be executed.

Let’s analyze this with a simple example:

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class Sample
public static void main(String[] args) {

// Configuring the system properties of chrome driver
System.setProperty("", "C:Selenium-java-chromedriver_win32chromedriver.exe");

//Initializing the browser driver
WebDriver driver = new ChromeDriver();

//Navigating through a particular website

System.out.println("Selenium Webdriver Script in Chrome");


When the script above is executed, it will open the BrowserStack website on a Chrome browser using ChromeDriver. This is achieved because System.setProperty manages the initialization of the Chrome driver in the first step.

Try Selenium Testing For Free

The System.setProperty() method forms the basis for test case automation on any browser. Naturally, QAs must understand how to use this fundamental method for all automation purposes in Selenium.

Read article on How to run Selenium tests on Chrome using ChromeDriver: Tutorial

QAs can use BrowserStack’s cloud Selenium grid to execute their Selenium test cases for multiple browsers running on various devices. BrowserStack also offers Provides integrations with popular frameworks and CI/CD tools like Jenkins, CircleCI, TeamCity to make the test process faster and convenient using plugins.

Automation Testing Selenium Selenium Webdriver

Featured Articles

getAttribute() method in Selenium: What, Why, and How to use

SendKeys in Selenium WebDriver

Curated for all your Testing Needs

Actionable Insights, Tips, & Tutorials delivered in your Inbox
By subscribing , you agree to our Privacy Policy.
thank you illustration

Thank you for Subscribing!

Expect a curated list of guides shortly.