【问题标题】:Unable to connect to selenium grid node无法连接到 selenium 网格节点
【发布时间】:2017-10-11 19:06:14
【问题描述】:

我正在尝试使用 RemoteWebDriver 连接到 Linux 机器上的 no,但没有成功。这是代码:

public WebDriver googlechrome(){ /*Method to start Google Chrome.*/

    WebDriver driver = null;
    ChromeOptions options = new ChromeOptions(); /*ChromeOptions is for firing Chrome with additional settings.*/
    options.addArguments("--allow-file-access-from-files"); /*Allow Chrome to access files*/
    options.addArguments("user-data-dir="+System.getProperty("user.dir")+pathChrome);
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    capabilities.setBrowserName("chrome");
    capabilities.setPlatform(Platform.LINUX);
    try { //            driver = new RemoteWebDriver(new URL("http://localhost:9515"), capabilities);
         driver = new RemoteWebDriver(new URL("http://jenkins.bgr.ionidea.com:4444/grid/console"),capabilities);
         Chatterbox.chatterinfo("Connected to Chromedriver");
    } catch (Exception e) {
        Chatterbox.chattererror("Could not connect to Chromedriver. Here is the stacktrace:", e); //           
        e.printStackTrace();
    }
    return driver;
}

当我在本地机器上运行这段代码时,它运行良好。但是,当我尝试通过 Grid 运行它时,遇到以下错误。

org.openqa.selenium.WebDriverException:无法解析远程 响应:网格 Console.busy { 不透明度:0.4;过滤器:alpha(opacity=40);}

网格控制台 v.3.1.0

https://github.com/SeleniumHQ/selenium/wiki/Grid2'>HelpDefaultRemoteProxy(版本:3.4.0)id:http://proxyhost:port,操作系统:LINUX
    BrowsersConfiguration
WebDriver

v:

v:

浏览器超时:0

调试: 假的

帮助:错误

端口:5555

作用: 节点

超时:1800

清理周期:5000

主持人: 10.91.3.204

最大会话数:5

功能:功能 [{seleniumProtocol=WebDriver, browserName=firefox, maxInstances=5, 平台=LINUX}]

能力:能力 [{seleniumProtocol=WebDriver, browserName=chrome, maxInstances=5, 平台=LINUX}]

downPollingLimit: 2

集线器: http://jenkinshost:jenkins 端口

标识: http://node ip:节点端口

集线器主机: jenkins.bgr.ionidea.com

集线器端口:4444

节点轮询: 5000

nodeStatusCheckTimeout:5000

代理: org.openqa.grid.selenium.proxy.DefaultRemoteProxy

注册: 真的

注册周期:5000

远程主机: http://node ip:节点端口

注销IfStillDownAfter: 60000

    查看 配置构建信息:版本:'3.4.0',修订: '未知',时间:'未知'系统信息:主机: 'Brindalas-MacBook-Air-2.local', ip: '10.91.17.123', os.name: 'Mac OS X',os.arch:'x86_64',os.version:'10.11.5',java.version: '1.8.0_121' 驱动程序信息:driver.version:RemoteWebDriver at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:353) 在 org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:159) 在 org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142) 在 org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637) 在 org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250) 在 org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236) 在 org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:137) 在 org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:174) 在 core.drivers.Browsers.googlechrome(Browsers.java:45) 在 core.drivers.Selenium.startBrowser(Selenium.java:18) 在 tryFireBrowser.fireBrowser(tryFireBrowser.java:13) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:498) 在 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108) 在 org.testng.internal.Invoker.invokeMethod(Invoker.java:661) 在 org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869) 在 org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193) 在 org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126) 在 org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) 在 org.testng.TestRunner.privateRun(TestRunner.java:744) 在 org.testng.TestRunner.run(TestRunner.java:602) 在 org.testng.SuiteRunner.runTest(SuiteRunner.java:380) 在 org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375) 在 org.testng.SuiteRunner.privateRun(SuiteRunner.java:340) 在 org.testng.SuiteRunner.run(SuiteRunner.java:289) 在 org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) 在 org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) 在 org.testng.TestNG.runSuitesSequentially(TestNG.java:1301) 在 org.testng.TestNG.runSuitesLocally(TestNG.java:1226) 在 org.testng.TestNG.runSuites(TestNG.java:1144) 在 org.testng.TestNG.run(TestNG.java:1115) 在 org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72) 在 org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:127) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:498) 在 com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

    异常的第一行说它无法解析某些东西,但我看不懂是什么?

    我错过了什么吗?我是第一次做网格设置。

    【问题讨论】:

    • 您可以从浏览器连接到节点 URL 吗?
    • 是的,我可以连接到节点 url

    标签: java selenium-grid selenium3


    【解决方案1】:

    问题出在下面一行

    driver = new RemoteWebDriver(new URL("http://jenkins.bgr.ionidea.com:4444/grid/console"),capabilities);

    您正在连接到控制台 servlet,而不是连接到负责处理新会话的 servlet。

    请将以上行改为

    driver = new RemoteWebDriver(new URL("http://jenkins.bgr.ionidea.com:4444/wd/hub"),capabilities);

    然后再试一次。你应该没事。

    【讨论】:

      猜你喜欢
      • 2016-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-21
      • 2013-09-13
      • 2015-07-17
      • 2016-12-10
      相关资源
      最近更新 更多