【问题标题】:testNG/selenium webdriver limited to 5 parallel teststestNG/selenium webdriver 限制为 5 个并行测试
【发布时间】:2014-09-01 01:19:26
【问题描述】:

我正在使用 maven surefire 插件运行 selenium webDriver 并使用 testNG,并且能够并行化我的测试,重用一个 JVM 实例。由于某种原因,我不确定如何运行超过 5 个。我尝试设置

<threadCountMethods> 10</threadCountMethods>

希望它一次运行 10 个线程,而不是我认为可能是默认值的 5 个。

我正在对方法进行并行化,如下所示:

` org.apache.maven.plugins maven-surefire-插件 2.17

        <configuration>
            <useUnlimitedThreads>true</useUnlimitedThreads>
            <threadCountMethods>10</threadCountMethods>
            <parallel>methods</parallel>
            <forkCount>0</forkCount>
            <reuseForks>true</reuseForks>
             <suiteXmlFiles>
                <suiteXmlFile>kingHenry.xml</suiteXmlFile>
            </suiteXmlFiles>
        </configuration>
      </plugin>`

套件文件配置如下:

<suite name="Suite" parallel="methods" >
<parameter name="seleniumHost" value="192.168.1.74" />
<parameter name="seleniumPort" value="4444" />

<parameter name="logHost" value="localhost" />
<parameter name="logPort" value="5000" />
<parameter name="networklogging" value="false" />

<test name="Showdme">
    <parameter name="browser" value="phantomjs" />
    <classes>
        <class name="com.something.suites.kingHenry" />
        <methods>
            <include name="testScenario1" />
            <include name="testScenario2" />
            <include name="testScenario3" />
            <include name="testScenario4" />
            <include name="testScenario5" />
            <include name="testScenario6" />
        </methods>
    </classes>
</test>

</suite>

这里我展示了列出 6 种并行化方法,但在附加的图像中,一次只运行 5 个浏览器实例。我想知道是否需要在我的 pom.xml 文件中编辑或添加配置属性,或者是否有正在使用的 selenium 网格设置限制 chromedriver 的 5 个实例。任何帮助将不胜感激......关于surefire插件的线程/分叉的一些文档有点令人困惑。

【问题讨论】:

    标签: java multithreading maven selenium parallel-processing


    【解决方案1】:

    如果您使用的是 Selenium Grid,那么您的测试一次限制为 5 个是有道理的。工厂 Selenium Grid 属性允许网格运行:

    网络驱动程序: - 5 谷歌浏览器 - 5 火狐 - 1 个 IE

    旧版 (RC): - 5 谷歌浏览器 - 5 火狐 - 1 个 IE

    您可以使用节点配置 json 文件更改这些值。

    nodeConfig.json

    {
      "capabilities":
          [
            {
              "browserName": "*chrome",
              "maxInstances": 2,
              "seleniumProtocol": "Selenium"
            }
            ... (any other browser capabilities here)
          ],
      "configuration":
      {
        "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
        "maxSession": 10,
        "port": 5555,
        "register": true,
        "registerCycle": 5000,
        "hubPort": 4444
      }
    }
    

    然后在运行节点时:

    java -jar selenium-server-standalone.jar -role node -nodeConfig nodeConfig.json ...

    【讨论】:

    • 谢谢.. 我会尽快实施,看看是否适合我。
    • 我能够在我的 maven 文件结构中找到这个配置文件。看起来它的结构完全相同,所以我对其进行了编辑,但我似乎无法在文件结构中找到启动网格的位置。 (该框架是由不再与我们合作的员工制作的)......所以我想我会在我努力寻找可以调用它的地方时将其标记为正确...... facepalm跨度>
    • 嘿@kinghenry14 这回答了你的问题吗?如果是这样,请继续并通过单击评级下的复选框来关闭它
    猜你喜欢
    • 2016-04-25
    • 1970-01-01
    • 2017-01-17
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多