java - 无法使用remotewebdriver和gecko驱动程序创建新的远程 session

标签 java selenium selenium-grid remotewebdriver geckodriver

我正在尝试迁移到 selenium 3,但是我在创建新的远程 session 时遇到问题,下面是我的代码:

 protected RemoteWebDriver driver;
    @Test
    public void testing() throws FileNotFoundException, IOException {

        System.setProperty("webdriver.gecko.driver", "C:\\java\\geckodriver.exe");
        DesiredCapabilities capability = DesiredCapabilities.firefox();
        capability.setCapability("marionette", true);
        driver = new RemoteWebDriver(new URL("http://google.com"),capability);
        System.out.println();
    }

我正在运行一个 Selenium 网格,这是我的命令行:

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

用于运行中心服务器。

java -Dwebdriver.firefox.marionette=true -jar selenium-server-standalone-3.0.1.jar -role node -hub http://localhost:4444/grid/register

这用于运行节点。任何帮助将不胜感激。

谢谢

最佳答案

我发现并解决了这个问题,通过在运行 selenium 节点时更改命令行:

java -Dwebdriver.gecko.driver=C:\java\geckodriver.exe -jar selenium-server-standalone-3.0.1.jar -role node -hub http://localhost:4444/grid/register

我注意到您甚至不需要更改您的remotewebdriver实例化,您的代码可以简单地如下所示:

protected RemoteWebDriver driver;
@Test
public void testing() throws FileNotFoundException, IOException {
    DesiredCapabilities capability = DesiredCapabilities.firefox();
    driver = new RemoteWebDriver(new URL("http://google.com"),capability);
    System.out.println();
}

关于java - 无法使用remotewebdriver和gecko驱动程序创建新的远程 session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42115678/

相关文章:

java - 使用 JPA (TreeView) 在同一个表中实现无限的分层子父关系

java - Java的线程状态如何映射到linux?如果Java的状态是runnable,Linux上是什么

java - Selenium webdriver - 无法在 youtube 上找到元素

java - 报告从 Jenkins 管道作业运行的多个 Selenium Webdriver 作业

java - 45000 毫秒后,端口 7055 上出现 Selenium 错误 : Unable to connect to host 127. 0.0.1。火狐控制台输出?

Selenium 无法启动 IE。

java - PHP 上的 DESede 长 key ,而不是 Java 中的

java - 尝试使用maven程序集插件时出现 "Assembly is incorrectly configured: null"

java - 使用 Appium 运行 Web 应用程序自动化的步骤

c# - 使用 selenium、Nunit、Selenium Grid、C#、webdriver/remote control 的自动浏览器测试