0

集线器:MAC 64 位 点头:Windows 32 位

无法使用 Selinum 网格 MAC 作为集线器和 Windows 作为点头运行 chrome 浏览器?

使用下面的代码我收到一个错误(驱动程序可执行文件的路径必须由 webdriver.chrome.driver 系统属性设置;有关更多信息,请参阅http://code.google.com/p/selenium/wiki/ChromeDriver . 最新版本可以从http://code.google.com/p/chromedriver/downloads/list下载命令持续时间或超时:668毫秒)

public void chromeWindows() throws MalformedURLException{

System.setProperty("webdriver.chrome.driver", "/Users/vinayakkhatate/Desktop/jar/chromedriver2");
ChromeOptions opt = new ChromeOptions();
opt.setBinary("C:/Users/user/AppData/Local/Google/Chrome/Application/chrome.exe");


DesiredCapabilities capabilies = DesiredCapabilities.chrome();
capabilies.setBrowserName("chrome");
capabilies.setPlatform(Platform.VISTA);


driver = new RemoteWebDriver(new URL("http://10.0.11.118:5566/wd/hub"), capabilies);
driver.get(baseUrl);
System.out.println(driver.getTitle());

driver.close();
driver.quit();

}
4

3 回答 3

4

我有从 Mac 机器运行 Chrome 浏览器到 Windows Vista 的解决方案(在 Windows Vista 机器中下载并保存 chromedriver)

使用以下命令在 Mac 中启动集线器

java -jar selenium-server-standalone-2.33.0.jar -role hub

使用以下命令在 windows 中启动节点

java -jar selenium-server-standalone-2.33.0.jar -role node -hub http://localhost:4444/grid/register -maxSession 15 -browser browserName="chrome",version=ANY,platform=WINDOWS,maxInstances=5 -Dwebdriver.chrome.driver=pathtochromedriver\chromedriver.exe

现在在Mac机器上用eclipse写代码

DesiredCapabilities capabilies = DesiredCapabilities.chrome();
capabilies.setBrowserName("chrome");
capabilies.setPlatform(Platform.ANY);

driver = new RemoteWebDriver(new URL("http://<ip address of windows machine>:5555/wd/hub"), capabilies); 
于 2013-07-10T09:14:07.917 回答
1

实际上,chromedriver.exe 必须存储在 Windows 节点上。我通过/lib在我的测试文件夹中创建子文件夹来存储 chromedriver 和所有其他硒网格相关的东西。稍后,在运行节点时,这样做:

java -jar lib/selenium-server-standalone-2.28.0.jar -role node -hub http://localhost:4444/grid/register -maxSession 15 -browser browserName="chrome",version=ANY,platform=WINDOWS,maxInstances=15 -Dwebdriver.chrome.driver=lib\chromedriver.exe 

特别注意 -D 开关:

-Dwebdriver.chrome.driver=lib\chromedriver.exe 

这就是我设置 chromedriver.exe 路径的方式。注意相对路径,所以我不必真正关心工具在绝对路径中运行的位置。希望能帮助到你

编辑 显然,集线器和节点计算机应该可以通过 IP 访问。例如,我的工作 PC10.131.7.11在我们的内部网络中有 IP,所以如果这将是集线器计算机,那么节点设置将如下所示:

java -jar lib/selenium-server-standalone-2.28.0.jar -role node -hub http://10.131.7.11:4444/grid/register -maxSession 15 -browser browserName="chrome",version=ANY,platform=WINDOWS,maxInstances=15 -Dwebdriver.chrome.driver=lib\chromedriver.exe

请注意,本地主机更改为集线器的 IP。所以接下来的步骤是:

  • 将集线器和节点设置在同一网络上并可由 IP 地址访问
  • 在mac机器上运行hub
  • 在vista上运行node,指向hub的IP地址
  • 交叉你的手指:)
  • 并尝试再次运行 chrome

EDIT2 这就是我运行 chrome 的方式:

  if (System.getProperty("os.name").contains("Windows")) {
        System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, "chromedriver.exe");
    } else {
        System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, "chromedriver");
    }

  capabilities = DesiredCapabilities.chrome();
  capabilities.setCapability("chrome.switches", Arrays.asList("--start-maximized"));

  driver = new RemoteWebDriver(new URL("http://127.0.0.1:4444/wd/hub"), capabilities);
于 2013-07-09T15:25:32.270 回答
0

使用以下命令在 Mac 中启动集线器

java -jar selenium-server-standalone-2.33.0.jar -role hub

使用以下命令在 windows 中启动节点

java -jar selenium-server-standalone-2.33.0.jar -role node -hub http://localhost:4444/grid/register -maxSession 15 -browser browserName="chrome",version=ANY,platform=WINDOWS,maxInstances=15 -Dwebdriver.chrome.driver=pathtochromedriver\chromedriver.exe 

从以下位置下载 chromedriver

https://code.google.com/p/chromedriver/downloads/list

现在使用以下逻辑初始化驱动程序实例

System.setProperty("webdriver.chrome.driver", "/Users/test/chromedriver");
DesiredCapabilities dc=new DesiredCapabilities();
dc.setBrowserName("chrome");
dc.setPlatform(Platform.WINDOWS);
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), dc);
driver.get(Constants.SERVER_URL_NAME);
于 2013-07-09T15:35:37.220 回答