Frage

I have chrome installed in my system. I'm using Selenium to run some tests on chrome.

I have downloaded the Chromedriver.exe to MyDocuments. I have set the 'webdriver.chrome.driver' using System.setProperty() and started ChromeDriver(). It works fine.

System.setProperty("webdriver.chrome.driver", "C:\\MyDocuments\\chromedriver.exe");
driver=new ChromeDriver();

Now, I'm trying to put Chromedriver.exe in a remote machine 'https://remotemachine/chromedriver.exe'. When I set the System property and start ChromeDriver(), I'm getting an exception, where Selenium is searching for chrome in a strange path:

The webdriver.chrome.driver defined chromedriver executable does not exist in C:\Users..\Appdata\Local\Google Chrome\Application...\https://remotemachine/chromedriver.exe

Why is Selenium searching for the chromedriver.exe by appending the system property to some location in C drive ?

How to launch Chrome from Selenium using a remote chromedriver.exe file ?

Not related to above, but:

Is it also possible to find the default browser binary path using Java/Selenium ?

War es hilfreich?

Lösung

It expects chrome to be in this location in windows

%HOMEPATH%\AppData\Local\Google\Chrome\Application\chrome.exe

For remote it has to be either in path or the -Dwebdriver.chrome.driver value should be pointing to a local chromedriver.exe location.

Local as in local to the place it is being run.

Here is the link for setup: http://code.google.com/p/selenium/wiki/RemoteWebDriver http://code.google.com/p/selenium/wiki/ChromeDriver

Andere Tipps

You cannot set the system path of a remote machine like -

System.setProperty("webdriver.chrome.driver", "remotemachine/chromedriver.exe");.

This code will get executed only in Hub/local machine where it resides.

To run it remotely, you need to mention -Dwebdriver.chrome.driver=pathtochromedriver.exe while starting the WD node.

java -jar seleniumserver.jar -role wd -hub http://hubhost:port/grid/register -Dwebdriver.chrome.driver=pathtochromedriver

System.setProperty("webdriver.chrome.driver", "C:\Documents and Settings\sssuppaluri\Desktop\Spicejet_Automation\chromedriver.exe"); driver = new ChromeDriver(); driver.get("https://149.122.160.94:8443/skylights/cgi-bin/skylights.cgi");

Create a new folder within your project called "chromedriver" and place the "chromedriver.exe" file in it then add the following line to your code

System.setProperty("webdriver.chrome.driver",System.getProperty("user.dir")+"\\chromedriver\\chromedriver.exe");
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top