Selenium Java - - RemoteWebDriver错误/异常

时间:2017-04-26 22:32:27

标签: java selenium remotewebdriver

java版:1.8

selenium版本:截至2017年4月的最新版本

集线器/网格已在另一台机器上设置,该机器是ec2 windows实例。节点成功注册。

集线器和节点控制台上没有错误。我可以在浏览器上看到控制台,注册节点和浏览器已公开。

java -Dwebdriver.gecko.driver=C:\selenium_grid\geckodriver\geckodriver.exe -jar selenium-server-standalone-3.4.0.jar -role hub -host <ipaddress> -port 4444

java -jar selenium-server-standalone-3.4.0.jar -role node -port 5555 -hub http://127.0.0.1:4444/grid/register -browser "browserName=firefox,platform=WINDOWS" -browser "browserName=opera,platform=WINDOWS" -browser "browserName=safari,platform=WINDOWS" -browser "browserName=internet explorer,platform=WINDOWS" -browser "browserName=chrome,platform=WINDOWS"

webdriver = new RemoteWebDriver(seleniumGridURL, desiredCapabilities);

public enum DriverType implements DriverSetup {

FIREFOX {
    public DesiredCapabilities getDesiredCapabilities(Proxy proxySettings) {
        DesiredCapabilities capabilities = DesiredCapabilities.firefox();
        capabilities.setCapability("marionette", true);
        return addProxySettings(capabilities, proxySettings);
    }

    public WebDriver getWebDriverObject(DesiredCapabilities capabilities) {
        return new FirefoxDriver(capabilities);
    }
}}`

错误: driver.version: RemoteWebDriver at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:353) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:159) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:174) at com.website.selenium.config.DriverFactory.instantiateWebDriver(DriverFactory.java:86) at com.website.selenium.config.DriverFactory.getDriver(DriverFactory.java:42) at com.website.selenium.DriverBase.getDriver(DriverBase.java:34) at com.website.selenium.listeners.ScreenshotListener.onTestFailure(ScreenshotListener.java:51) at org.testng.internal.Invoker.runTestListeners(Invoker.java:1716) at org.testng.internal.Invoker.runTestListeners(Invoker.java:1699) at org.testng.internal.Invoker.invokeMethod(Invoker.java:703) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

org.openqa.selenium.WebDriverException: Unable to parse remote response: Cannot POST /wd/hub/session

尝试按照建议启用调试:
java -jar selenium-server-standalone-3.4.0.jar -debug -log c:\selenium_grid\grid.log -role node -port 5555 -hub http://127.0.0.1:4444/grid/register -browser "browserName=firefox,platform=WINDOWS" -browser "browserName=opera,platform=WINDOWS" -browser "browserName=safari,platform=WINDOWS" -browser "browserName=internet explorer,platform=WINDOWS" -browser "browserName=chrome,platform=WINDOWS"

Exception in thread "main" com.beust.jcommander.ParameterException: "-debug": couldn't convert "-log" to a boolean

1 个答案:

答案 0 :(得分:1)

这是aws VPC和私有IP的网络问题,并且在EC2实例中打开Windows防火墙+修改sec组(Windows机器的传入端口)中的TCP和UDP端口。