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!!

4,443 views2 comments

2 comentarios

Obtuvo 0 de 5 estrellas.
Aún no hay calificaciones

Agrega una calificación
Invitado
08 sept 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.


Me gusta

Invitado
24 may 2023
Obtuvo 5 de 5 estrellas.

Clear.

Me gusta
bottom of page