【问题标题】:Unable to open multiple instance of broswer using selenium grid无法使用硒网格打开多个浏览器实例
【发布时间】:2013-10-29 17:04:53
【问题描述】:

我正在使用 selenium grid(JUNIT, Java) 在浏览器的 mutli 实例上运行我的测试用例。 我使用“java -jar selenium-server-standalone-2.20.0.jar -role hub”来运行集线器。 和“java -jar selenium-server-standalone-2.20.0.jar -role webdriver -hub http://machineip:4444/grid/register -port 5566”运行节点。

我确认两者都运行良好。

但是当我通过 Eclipse 运行测试用例时,只打开了一个浏览器实例。

我使用了这段代码。

    @Test
public void method() throws MalformedURLException {
    baseUrl = "https://www.google.co.in";
    nodeUrl = "http://`machinip`:5566/wd/hub";
    DesiredCapabilities capability = DesiredCapabilities.firefox();
    capability.setBrowserName("firefox");
    capability.setPlatform(Platform.WINDOWS);
    driver = new RemoteWebDriver(new URL(nodeUrl), capability);
    // WebDriver driver = new FirefoxDriver();
    driver.get(baseUrl);
    driver.findElement(By.xpath("//td/div/input")).sendKeys("lucky");
}

请有人建议我如何为单个测试打开多个实例。

提前感谢您的帮助。

【问题讨论】:

  • 看起来您只在那里创建了 1 个驱动程序。我看不出这两个司机是从哪里来的。
  • 你的意思是如果我必须运行 10 个实例我已经创建了 10 个驱动程序?请提供代码。
  • 你为什么不试试TestNG呢?做这样的工作更容易;)
  • 感谢 Prashanth。我会用它。但是是否有任何更改代码的要求??

标签: selenium


【解决方案1】:

您的测试代码总体上看起来不错 - 对于单个测试) 我认为您缺少运行测试的方式-如果您单次运行它将打开一个实例。 在 testNg 中,您可以使用 dataprovider(参数化)多次运行它,并在 testing.xml 中指定您想要“parallel=methods”,这样您的所有“参数化”测试实例将一起运行。 还要确保你有 -browser maxInstances=5,在节点起始行(或任何你想要的数字)。

efficient selenium testing lab

[披露:我在 Ravello 工作]

【讨论】:

    【解决方案2】:

    尝试在启动服务器时添加此标记 -browser maxInstances=5

    【讨论】:

      猜你喜欢
      • 2016-07-16
      • 2023-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-22
      • 2021-06-24
      • 1970-01-01
      相关资源
      最近更新 更多