System.setProperty - Set path to chromedriver

1

I'm starting to tinker with tests using selenium and JUnit. I need to set the chromedriver.exe path. I would like to know if you have chromedriver.exe inside the project folder and set the path in a way that if someone else downloads the project, for example Github does not need to reset the path.

    
asked by anonymous 28.03.2017 / 20:26

1 answer

0

Oops, do as follows:

1º - Download the .exe driver and place it inside your test resources directory. Something like: src / test / resources / chromedriver.exe. This directory will be able to be committed.

2nd - In your test class, where you are trying to register the property, search for the exe by this.getClass().getResource("chromedriver.exe").getPath(); . It will fetch the executable from within the test resource, where you stored the exe.

3rd Enjoy!

4º - If you are using Arquillian + Maven, in the arquilian.xml configuration file you need extensions:

<extension qualifier="webdriver">
    <property name="browser">${browser}</property>
    <property name="chromeDriverBinary">${chromeDriverBinary}</property>
</extension>

and the properties should be registered in the Maven pom.xml.

<properties>
    <browser>chrome</browser>
    <chromeDriverBinary>src/test/resources/chromedriver.exe</chromeDriverBinary>
</properties>
    
29.03.2017 / 07:40