I am currently creating selenium automation using webdriver in Maven using Java. Now for initializing the browsers such as Chrome and IE I have to set the system property such as
System.setProperty("webdriver.chrome.driver", "F:\\somewhereintheworkingdir\\drivers\chromedriver.exe");
Now, my deliverable is in terms of JAR. I am using maven so this is currently under main>resources>drivers>chromedriver.exe
So after package it will be unders root>drivers>chromedriver.exe
So How to make the system property that it will run in both the cases?
I researched about some constants like java.class.path
or java.file.seperator
etc. but I am not sure how they will useful here in this case.
I hope someone can help me.
I would suggest having a look at this:
https://github.com/Ardesco/Selenium-Maven-Template
The relevant parts are the POM where it uses this plugin:
and in the base class where it pulls in the locations of the binaries:
You also need to have a properties file in src/main/resources (has to be in main, not test) that maven can update at build time to pass in properties set in the POM/overridden on the command line.
That file would look like this:
The easiest thing to do would be clone the project linked to at the start of this answer and just run:
That will show you everything working and give you a good base to start from.