It works using an absolute path like:
WebDriver = new ChromeDriver(@"C:\Users\<my user>\Documents\<my project>\WebDrivers\Chrome\");
But since I run my tests on a TFS build server too, I need it to be a relative path.
Add the drivers into your solution and in the properties window, define that you want to copy the files to the output directory.
File Properties
In the picture above, the drivers are in the resources directory:
/my solution
/resources
/chromedriver.exe
/IEDriverServer.exe
After a build, they will be copied to:
/bin
/debug
/resources
/chromedriver.exe
/IEDriverServer.exe
When you are creating your driver, you can define the path to the driver now relative in the bin directory.
return new ChromeDriver("resources");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With