I'm writing a web-automation program and so far, it works fine using Selenium's FirefoxDriver. However, I want to make it use Chrome if Firefox is not installed. I downloaded the ChromeDriver, put it inside a folder in my Eclipse project, and ran it. After I added System.setProperty("webdriver.chrome.driver", "Drivers/chromedriver.exe");
it worked fine. However, when I try to export it (using Eclipse's standard Export). It crashes, I believe because it can't find the ChromeDriver (I think this because exporting it with FirefoxDriver works fine).
I have tried changing the .JAR to a .ZIP in order to look inside, and I see that the driver
folder was stripped away, simply putting chromedriver.exe
inside the top-level JAR. I tried changing the property to System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
but still crashes.
Does anyone know why the exported JAR is unable to find chromeDriver
, despite the fact that I have verified that it is in the JAR?
Thanks, Daniel
Below are the steps to follow while configuring the chrome setup for Selenium. #1) Check the version of the chrome. #3) Download the chromedriver.exe file for the respective OS and copy that .exe file into your local. #4) The path of the chromedriver (C:\webdriver\chromedriver.exe) will be used in our program.
Make sure that the chromedriver.exe file is directly under the PATH you specified, i.e. under C:\chromedriver (or an alternative path). If your zip unpacker created a new folder with a different name inside your specified folder, move the .exe file to that path.
Export your code as jar without the chromedriver. Create a folder ChromeDriver. Place your chromedriver.exe in this folder. Place ChromeDriver folder along with your jar.
Also dont forget to set the System property in the code to
System.setProperty("webdriver.chrome.driver", "ChromeDriver/chromedriver.exe");
Please let me know if this works for you.
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