We may not have the course you’re looking for. If you enquire or give us a call on 01344203999 and speak to our training experts, we may still be able to help with your training requirements.
We ensure quality, budget-alignment, and timely delivery by our expert instructors.
The decision to test on a browser is the first step in performing automated tests for any website or a web-app. The primary foundation for website testing is to incorporate a browser object and set the system properties of the browser drivers. This is specially done before writing test scripts. Quality Assurance (QAs) use the help of the SetProperty method to do that. In this blog, you will learn about What is System SetProperty in Selenium, its methods with a demo, and its uses. Read more!
Table of Contents
1) What is SetPropertyin Selenium?
2) The use of SetProperty method
a) Syntax explanation
3) Understanding SetProperty in Selenium: Demo
4) Conclusion
What is SetProperty in Selenium?
The SetProperty method, as it is named, permits QAs to set the properties for the preferred browser to be used in test automation. The SetProperty method in Selenium has two attributes, named "propertyName" and "value". The 'propertyName' represents the browser-specific driver's name, and that browser driver's path is pointed by 'value.'
The use of setproperty method
To run a Selenium test, you need a system browser like Google Chrome, Firefox, Edge, Safari, etc. Since Selenium cannot launch any installed browser directly, it needs a specific browser driver. It helps to communicate between installed browsers and Selenium client libraries. The decision on which browser to launch will be made by the System.SetProperty(String key, String value).
Example of SetProperty in Selenium
Following is an example of using system SetProperty in the Chrome browser. To test and run the SetProperty, write the below syntax. It will automate the test case in the browser.
System.SetProperty("webdriver.chrome.driver", "D:chromedriver.exe");
In the above syntax, there are two components, which have been explained below:
a) webdriver.chrome.driver - It decides the test case and will be executed in the chrome browser.
b) D:chromedriver.exe - This is the chrome driver’s executable file path.
Learn how to design, create reports, understand data sources and datasets using our SQL Server Reporting Services – register now!
Understanding SetProperty in Selenium: Demo
Since browsers lack built-in servers for test automation, QAs must first download browser-specific drivers to enable test execution. This step helps bridge the gap between test scripts and browsers. The difference between Cypress and Selenium lies in this setup process—while Selenium requires external drivers, Cypress comes with built-in browser support, simplifying the automation workflow.
A complete list of available browser drivers can be checked on Selenium's official website. For a browser, once the driver is downloaded, the system SetProperty() method is needed by the QAs to define the path for that driver before writing test cases. Knowing the prerequisites to learn Selenium, like understanding the structure of web browsers and driver setup, will make this process smoother.
Let us see with this simple demo:
import org.openqa.Selenium.WebDriver;
import org.openqa.Selenium.chrome.ChromeDriver;
public class SetPropertyDemo
{
public static void main(String[] args)
{
// Set path to chromedriver executable
System.SetProperty("webdriver.chrome.driver", "path/to/chromedriver");
// Create a new instance of the ChromeDriver
WebDriver driver = new ChromeDriver();
// Navigate to a website
driver.get("https://www.example.com");
// Maximize the browser window
driver.manage().window().maximize();
// Close the browser
driver.quit();
}
}
From the above demonstration, the 'SetProperty' method is used to set the path to the executable chromedriver. As often highlighted in Selenium Interview Questions, a new instance of the 'ChromeDriver' class is then created and navigated to the website, where the browser window is finally maximised. Finally, the browser window is closed using the quit method. When dealing with multiple windows, you will need to consider handling multiple windows in Selenium to switch between them effectively, which can vary depending on the version of Selenium (Selenium3 vs Selenium 4) and the language used.
Conclusion
After reading this blog, we hope you understand System setProperty in Selenium and how you can perform test automation on web browsers or web apps. Additionally, knowing how to use the CSS Selector in Selenium will help you more precisely identify elements for your automated tests, enhancing test accuracy.
Want to become familiar with the automation features and Selenium Web Driver. Sign up for our Introduction to Test Automation with Selenium Web Driver course now!
Frequently Asked Questions
Why do we write system SetProperty in Selenium?
In Selenium, the usage of SetProperty method to configure browser-specific drivers. Since browsers lack built-in servers for test automation, they need drivers to communicate with the browser. By setting the driver path using setProperty, Selenium can interact seamlessly with Chrome, IE, or Gecko browsers.
What is the difference between SetProperty and GetProperty in Selenium?
SetProperty is used to configure browser-specific drivers and sets a system property with a name. Since browsers lack built-in servers for test automation. These drivers need to communicate with the browser. GetProperty, on the other hand, is used to read system properties. It retrieves the value of a property named in the argument list.
What are the other resources and offers provided by The Knowledge Academy?
The Knowledge Academy takes global learning to new heights, offering over 3,000 online courses across 490+ locations in 190+ countries. This expansive reach ensures accessibility and convenience for learners worldwide.
Alongside our diverse Online Course Catalogue, encompassing 19 major categories, we go the extra mile by providing a plethora of free educational Online Resources like News updates, Blogs, videos, webinars, and interview questions. Tailoring learning experiences further, professionals can maximise value with customisable Course Bundles of TKA.
What is the Knowledge Pass, and how does it work?
The Knowledge Academy’s Knowledge Pass, a prepaid voucher, adds another layer of flexibility, allowing course bookings over a 12-month period. Join us on a journey where education knows no bounds.
What are related courses and blogs provided by the Knowledge Academy?
The Knowledge Academy offers various Selenium Courses, including Test Automation with Selenium Web Driver Training, Selenium Immersion with C# Training, Selenium Testing Framework Training, and Selenium WebDriver with Python Training. These courses cater to different skill levels, providing comprehensive insights into Prerequisites to Learn Selenium.
Our Programming and DevOps Blogs cover a range of topics related to Selenium, offering valuable resources, best practices, and industry insights. Whether you are a beginner or looking to advance your Selenium skills, The Knowledge Academy's diverse courses and informative blogs have you covered.
Upcoming Programming & DevOps Resources Batches & Dates
Date
Fri 11th Jul 2025
Fri 12th Sep 2025
Fri 14th Nov 2025