当我尝试使用 Selenium Grid 在 "Linux/XP/etc" 平台上执行时,我的测试失败了

My test is getting failed when i try to execute on "Linux/XP/etc" platforms using Selenium Grid

我是这个 Selenium 网格的新手。我的节点默认在 Win10 平台上注册。因此它可以毫无问题地执行脚本。但是当我尝试在 Win10 以外的 运行 上时,它失败了。有人可以帮我解决这个问题吗?我查看了互联网上所有可用的解决方案,但我无法解决它。

代码

  baseURL = "http://demo.guru99.com/test/guru99home/";
         nodeURL = "http://192.168.1.4:4444/wd/hub";
         ChromeOptions options=new ChromeOptions();
         DesiredCapabilities cap=DesiredCapabilities.chrome();
         cap.setPlatform(Platform.LINUX);
         options.merge(cap);
         driver = new RemoteWebDriver(new URL(nodeURL), options);

错误

15:02:08.893 INFO [RequestHandler.process] - Got a request to create a new session: Capabilities {browserName: chrome, goog:chromeOptions: {args: [], extensions: []}, platform: LINUX, version: }
15:02:08.912 INFO [RequestHandler.process] - Error forwarding the new session cannot find : Capabilities {browserName: chrome, goog:chromeOptions: {args: [], extensions: []}, platform: LINUX, version: }
org.openqa.grid.common.exception.CapabilityNotPresentOnTheGridException: cannot find : Capabilities {browserName: chrome, goog:chromeOptions: {args: [], extensions: []}, platform: LINUX, version: }
        at org.openqa.grid.internal.ProxySet.verifyAbilityToHandleDesiredCapabilities(ProxySet.java:153)
        at org.openqa.grid.internal.DefaultGridRegistry.addNewSessionRequest(DefaultGridRegistry.java:217)
        at org.openqa.grid.web.servlet.handler.RequestHandler.process(RequestHandler.java:111)
        at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:85)
        at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:69)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:865)
        at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:535)
        at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
        at org.seleniumhq.jetty9.security.SecurityHandler.handle(SecurityHandler.java:548)
        at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
        at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
        at org.seleniumhq.jetty9.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
        at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
        at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1340)
        at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
        at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:473)
        at org.seleniumhq.jetty9.server.session.SessionHandler.doScope(SessionHandler.java:1564)
        at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
        at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1242)
        at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
        at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
        at org.seleniumhq.jetty9.server.Server.handle(Server.java:503)
        at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:364)
        at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:260)
        at org.seleniumhq.jetty9.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
        at org.seleniumhq.jetty9.io.FillInterest.fillable(FillInterest.java:103)
        at org.seleniumhq.jetty9.io.ChannelEndPoint.run(ChannelEndPoint.java:118)
        at org.seleniumhq.jetty9.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
        at org.seleniumhq.jetty9.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
        at org.seleniumhq.jetty9.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
        at org.seleniumhq.jetty9.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
        at org.seleniumhq.jetty9.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
        at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
        at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:683)
        at java.lang.Thread.run(Unknown Source)

Node.Json 文件

{
  "capabilities":
  [
    {
      "browserName": "firefox",
      "maxInstances": 5,
      "seleniumProtocol": "WebDriver"
    },
    {
      "browserName": "chrome",
      "maxInstances": 5,
      "seleniumProtocol": "WebDriver"
    },
    {
      "browserName": "internet explorer",
      "maxInstances": 1,
      "seleniumProtocol": "WebDriver"
    }
  ],
  "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
  "maxSession": 5,
  "port": 5555,
  "register": true,
  "registerCycle": 5000,
  "hub": "http://localhost:4444",
  "nodeStatusCheckTimeout": 5000,
  "nodePolling": 5000,
  "role": "node",
  "unregisterIfStillDownAfter": 60000,
  "downPollingLimit": 2,
  "debug": false,
  "servlets" : [],
  "withoutServlets": [],
  "custom": {}
}

如果我需要为必须添加这些功能的其他平台添加功能。

这个解决了我的问题。

java -jar "C:\Users\DELL\Desktop\Selenium Grid\selenium-server-standalone-3.141.5.jar" -role node -hub http://*.*.*.*:PortNumber/grid/register -port 5557 -browser "browserName=chrome,platform=LINUX"

注意:请将您的 IP 地址替换为“*”

并检查节点 URL 端口号。