我已经在本地计算机上设置了 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/