Setup Chrome WebDriver with remote 'chromedriv

2019-06-13 15:09发布

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 ?

4条回答
ゆ 、 Hurt°
2楼-- · 2019-06-13 15:42

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

查看更多
时光不老,我们不散
3楼-- · 2019-06-13 15:45

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");
查看更多
手持菜刀,她持情操
4楼-- · 2019-06-13 15:46

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
查看更多
ら.Afraid
5楼-- · 2019-06-13 15:54

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");

查看更多
登录 后发表回答