如何以编程方式在同一个selenium hub上运行2个或更多节点(不使用控制台)

时间:2014-04-13 14:19:47

标签: java selenium selenium-webdriver selenium-grid

我可以在selenium grid hub上运行1个节点。

以下是我的代码片段。

        GridHubConfiguration config = new GridHubConfiguration()
        config.setHost("localhost")
        config.setTimeout(60000000)
        Hub hub = new Hub(config)
        hub.start()

        RegistrationRequest req = new RegistrationRequest()
        req.setRole(GridRole.NODE)


        Map<String, Object> nodeConfiguration = new HashMap<String, Object>();

        nodeConfiguration.put(RegistrationRequest.PROXY_CLASS, "org.openqa.grid.selenium.proxy.DefaultRemoteProxy")
        nodeConfiguration.put(RegistrationRequest.MAX_SESSION, 25)
        nodeConfiguration.put(RegistrationRequest.PORT, 5555)
        nodeConfiguration.put(RegistrationRequest.HOST, hub.getHost())
        nodeConfiguration.put(RegistrationRequest.AUTO_REGISTER, true)
        nodeConfiguration.put(RegistrationRequest.REGISTER_CYCLE, 5000)
        nodeConfiguration.put(RegistrationRequest.HUB_HOST, hub.getHost())
        nodeConfiguration.put(RegistrationRequest.HUB_PORT, hub.getPort())
        URL remoteURL = new URL("http://" + hub.getHost() + ":" + 5555)
        nodeConfiguration.put(RegistrationRequest.REMOTE_HOST, remoteURL)

        req.setConfiguration(nodeConfiguration)

        DesiredCapabilities capabilities = DesiredCapabilities.chrome()
        capabilities.setCapability("browserName","chrome")
        capabilities.setCapability("maxInstances",25)
        capabilities.setCapability("seleniumProtocol","Selenium")

        req.setCapabilities([capabilities]);

        SelfRegisteringRemote remote = new SelfRegisteringRemote(req)
        remote.startRemoteServer()
        remote.startRegistrationProcess()

我有3个问题..

  1. 正如您所看到的,我将MAX_SESSION和maxInstances设置为25,虽然我无法运行超过10个Chrome驱动程序实例,但也许我做错了或者它可能是个错误?
  2. 如何以编程方式(不使用控制台)在同一个selenium hub上运行2个或更多节点?
  3. 如何在无头模式下运行网络驱动程序?有一个非常有用的链接 Headless tests with Firefox and Chrome WebDriver,但我无法找到它对Selenium网格的影响。
  4. 我正在使用 selenium-server-standalone-2.40.0.jar

0 个答案:

没有答案