Understanding System setProperty in Selenium
Related Product On This Page What is System class in Java?May 10, 2026 · 5 min read · Tool Comparison
The first measure in automating tests for a website or web app is deciding which browser to quiz. As a result, delineate the system place and initializing the browser object becomes necessary, particularly before writing. ThesetProperty ()method helps QAs do incisively that. This article explains thesetPropertymethod in Selenium with a sample program. The setProperty () method in Selenium is a part of the System class in Java and is apply to set a scheme property. A scheme property is a key-value duad that the Java runtime environment can use during the execution of a programme. System.setProperty ()will set system place that QAs can access via any class running as a part of that java process (JVM). setProperty () in Selenium, is much apply to define the position of the browser driver executables (like chromedriver.exe for Chrome, geckodriver.exe for Firefox, etc.). Parameters: Key: This is the name of the system property. Value:This is the value of the system holding. setProperty () methodhelps to set the system holdingkey to experience the value asvalue. The system setProperty method has two attribute & # 8211; “propertyName” and “value. ” The propertyName represents the name of the browser-specific driver, and the value points to the itinerary of that browser driver. The java.lang.System.setProperty ()method lay the system property indicated by the conditionkey. Syntax: Returns: This method would retrovert the premature value of the system property in the form of String, or null if it did not have one. Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script. Throws: In Selenium, setProperty () can be used to set the driver path of the respective browser. Read More: To automate tests for a specific browser, QAs need to download the browser-specific driver first as browser do not have built-in servers for. These drivers act as a span between test scripts and browsers for test mechanization. One can ascertain the consummate list of uncommitted browser drivers on theofficial siteof Selenium. Once the driver is downloaded for a specific browser, QAs demand thesetProperty ()method to define the path for that driver before writing any test cases. Let ’ s analyze this with examples: Here, setProperty () has two parameters: Here, the key implies the Selenium WebDriver uses Google Chrome driver to execute on the Chrome browser. Value implies the placement from where the Chrome executable should be called. If you like to run on Firefox browser, download the binary and set the values accordingly. The sampling is as below: Note:Binary file location value should be update per your system itinerary. We need to initialize the browser as the scheme properties are set now. For Chrome browser: For Firefox browser: You should run Selenium Java Tests on a real gimmick cloud like for below reasons: The System.setProperty () method forms the base for test case automation on any browser. Naturally, QAs must understand how to use this key method for all automation intent inSelenium. QAs can use BrowserStack ’ s cloud Selenium grid to fulfil their for multiple browsers on various devices. BrowserStack also proffer with popular frameworks and like Jenkins, CircleCI, and TeamCity to make the test process faster and more convenient using plugins. # 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.Related Product
Understanding System setProperty in Selenium
What is System class in Java?
What is setProperty in Selenium?
setProperty in Selenium
public static String setProperty (String key, String value)
What is the use of the setProperty method? (with Examples)
This helps the identify the browser on which tests will be executed.System.setProperty (`` webdriver.chrome.driver '', `` D: \\Browser Binaries\\chromedriver_win32\\chromedriver.exe '');
Key: “ webdriver.chrome.driver ”Value: “ D: \\Browser Binaries\\chromedriver_win32\\chromedriver.exe ” (Path of the practicable)
Key: “ webdriver.gecko.driver ”Value: & lt; Firefox binary file location & gt;
WebDriver driver = new ChromeDriver ();
WebDriver driver = new FirefoxDriver ();
Example 1: Launching BrowserStack site using Selenium employ setProperty method
public class SetPropertyExample {public still void main (String args []) {System.setProperty (`` webdriver.chrome.driver '', `` D: \\Browser Binaries\\chromedriver_win32\\chromedriver.exe ''); // Initializing the browser driver WebDriver driver = new ChromeDriver (); // Navigating to BrowserStack site driver.get (`` https: //www.browserstack.com ''); System.out.println (`` BrowserStack is launched successfully on Chrome! ``); driver.close ();}}Example 2: Passing Key as Null
public class NullPointerExceptionExample {public static void principal (String args []) {System.setProperty (null, `` D: \\Browser Binaries\\chromedriver_win32\\chromedriver.exe ''); //Initializing the browser driver WebDriver driver = new ChromeDriver (); //Navigating to BrowserStack website driver.get (`` https: //www.browserstack.com ''); System.out.println (`` BrowserStack is launch successfully on Chrome! ``); driver.close ();}}Example 3: Passing Key as Empty
public grade SetPropertyExample {public static void independent (String args []) {System.setProperty (`` '', `` D: \\Browser Binaries\\chromedriver_win32\\chromedriver.exe ''); // Initializing the browser driver WebDriver driver = new ChromeDriver (); // Navigating to BrowserStack site driver.get (`` https: //www.browserstack.com ''); System.out.println (`` BrowserStack is establish successfully on Chrome! ``); driver.close ();}}Why use BrowserStack Automate to run Selenium Tests?
Conclusion
Related Guides
Automate This With SUSA
Test Your App Autonomously