【问题标题】:static Selenium client with testng parallelization具有 testng 并行化的静态 Selenium 客户端
【发布时间】:2012-09-06 19:32:57
【问题描述】:

有人告诉我通过以下约定使用使用 selenium 的框架:

public static SeleniumClient instance() {



if (_instance == null) {

  _instance = new SeleniumClient();

  LogHelper.instance().setInfo("SeleniumClient::instance(): Singleton created.");

}

return _instance;

}

所有测试都以类似的方式编写。例如,如果我要创建一个新测试,我会编写一个辅助类,这就是它的使用方式:

public static PropertyManagerHelper instance() {

if (_instance == null) {

  _instance = new PropertyManagerHelper();

  LogHelper.instance().setInfo("PropertyManagerHelper::instance(): Singleton created.");

}

return _instance;

}

我有一个硒网格,我也打算发送这些测试。在我深入兔子洞之前,我有以下问题:

Selenium 如何将测试发送到网格?它是发送整个类/测试还是将每个操作作为单独的请求发送?

这可能会被前面的问题回答,但是这种静态用法会阻止 testng 运行多个并行测试吗?

【问题讨论】:

    标签: java selenium testng selenium-grid


    【解决方案1】:

    为什么是单例模式?

    在当前状态下它不是线程安全的:

    http://csharpindepth.com/Articles/General/Singleton.aspx

    我不建议使用单例模式。

    【讨论】:

    • 是的,我也不会。我正在收集数据点来帮助我证明它不适合这里。
    【解决方案2】:

    它发送每个命令。 Selenium 不知道它是一个测试用例还是一个类。 Hub 将获取命令并在遥控器上分发。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-22
      相关资源
      最近更新 更多