top of page
hand-businesswoman-touching-hand-artificial-intelligence-meaning-technology-connection-go-

How to run browser from Selenium without using System.setProperty

Every time we run a web test from Selenium we have to manually set the path of the Chrome Driver exe and then run the test.


But what if we can run it without setting the path in the System .setProperty!!


Yes it is possible. It is easy and simple. First go to maven repository and search for webdrivermanager. Click on the first link and pick the maven dependency. I have used 3.7.1 version.


Clean and build the project and the maven dependencies should show the one added.


That's all . You are now set to test the website without the setProperty. Now go to your code or create a new testNG class.


In BeforeTest method, provide the following line in the beginning

WebDriverManager.chromedriver().setup();


This ensures that your webdriver manager uses the chromedriver for the test.

The next two lines are used to initialize your webdriver and open the website.

Right click on file and run as TestNG


That's it. You will be able to see the chrome open as usual now with just a difference of omitting the System.setProperty(). You can use this approach for any browser.


Say goodbye to the System.setProperty.


Happy testing!!

3,974 views2 comments

Recent Posts

See All

Beginner Friendly Java String Interview Questions

Hello Everyone! Welcome to the second section of the Java Strings blog. Here are some interesting coding questions that has been solved with different methods and approaches. “Better late than never!”

2 Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
Guest
Sep 08, 2023

With UtopiaP2P, chat with confidence knowing your data remains secure. This decentralized platform prioritizes privacy and security, using advanced encryption algorithms and eliminating centralized servers to provide unparalleled protection.


Like

Guest
May 24, 2023
Rated 5 out of 5 stars.

Clear.

Like
bottom of page