selenium - [ Selenium 网格] : Unable to launch Robot tests on remote machine

标签 selenium selenium-webdriver robotframework selenium-grid

我已经在本地计算机上设置了 Selenium 网格,并在远程计算机上设置了一个节点。

节点正在运行

java -jar selenium-server-standalone-3.8.1.jar -role node  -hub http://<hub_machine>:4444/grid/register

现在我已经编写了机器人测试来在远程计算机上运行脚本,如下所示:

Open Browser   google.com   chrome  None  http://<hub_machine>:4444/wd/hub  desired_capabilities=browserName:chrome,platform:WINDOWS

我还尝试使用远程 Webdriver,如下所示:

${executor}=    Evaluate    str('http://<hub_machine>:4444/wd/hub')
    ${desired capabilities}=    Evaluate    { "browserName": "chrome", "version": "", "platform": "VISTA", "javascriptEnabled": True}
    Create Webdriver    Remote    desired_capabilities=${desired capabilities}    command_executor=${executor} 

但是代码会抛出如下错误:

2018-02-20 13:33:41.655:WARN:osjs.HttpChannel:qtp662736689-13: /wd/hub/session java.io.IOException: org.openqa.grid.common.exception.GridException: Cannot extract a capabilities from the request: {"capabilities": {"alwaysMatch": {"version": "", "platform": "VISTA", "browserName": "chrome", "javascriptEnabled": true}, "firstMatch": []}, "desiredCapabilities": {"version": "", "platform": "VISTA", "browserName": "chrome", "javascriptEnabled": true}}

请建议如何解决此问题。

最佳答案

错误说明了一切:

/wd/hub/session java.io.IOException: org.openqa.grid.common.exception.GridException: Cannot extract a capabilities from the request: {"capabilities": {"alwaysMatch": {"version": "", "platform": "VISTA", "browserName": "chrome", "javascriptEnabled": true}, "firstMatch": []}, "desiredCapabilities": {"version": "", "platform": "VISTA", "browserName": "chrome", "javascriptEnabled": true}}

要启动Selenium 网格节点,您应该提供WebDriver 变体作为参数,如下所示:

  • Mozilla Firefox :

    java -Dwebdriver.gecko.driver=geckodriver.exe -jar selenium-server-standalone-3.8.1.jar -role node -hub http://<hub_machine>:4444/grid/register
    
  • Chrome :

    java -Dwebdriver.chrome.driver=chromedriver.exe -jar selenium-server-standalone-3.8.1.jar -role node -hub http://<hub_machine>:4444/grid/register
    
  • Internet Explorer :

    java -Dwebdriver.ie.driver=IEDriverServer.exe -jar selenium-server-standalone-3.8.1.jar -role node -hub http://<hub_machine>:4444/grid/register
    

更新

由于您仍然看到相同的错误,因此您需要:

  • 提供完整的url包括协议(protocol) https://www.google.com (而不仅仅是 google.com )
  • IDE 中清理项目
  • 使用CCleaner清除所有操作系统杂务的工具。
  • 执行您的测试

关于selenium - [ Selenium 网格] : Unable to launch Robot tests on remote machine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48880580/

相关文章:

selenium - 如何使用 Selenium 在 Firefox 中单击 "Launch Application"对话框?

selenium - Protractor getText 为非空元素返回空字符串

selenium-webdriver - RobotFramework:关键字 'Selenium2Library.Input Text' 需要 2 个参数,得到 1 个

robotframework - 有没有办法在字典键中生成随机字符串?

robotframework - 如何使用 Robot Framework 获取列表中的项目数?

java - 在 selenium webdriver 中执行 javascript 时发生错误

java - 如何从性能日志计算页面加载时间、domContentLoaded 时间(即公式)?

java - 在公司代理后面使用 Selenium RemoteWebDriver

eclipse - Robot Framework - 如何在 Eclipse 中导入 SeleniumLibrary 关键字实现/文档

java - 在 Eclipse 中运行 Selenium 时在哪里可以找到 System.out.println 输出?