我正在尝试迁移到 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/