我正在使用 TestNg + Selenium (JAVA) Grid 来执行并行执行。
我的机器\服务器配置是
- 处理器:Intel Xeon,CPU E5-2603 v4,2.20 GHz(8 个处理器)
- 内存:64GB
- 系统类型:64 位
- 操作系统:Window Server 2012 R2 Standard
我在同一台机器上有 HUB 和 3 个节点
- HUb 命令:java -jar selenium-server-standalone-3.1.0.jar -role hub
- 节点命令:java -Dwebdriver.chrome.driver=./chromedriver.exe -jar selenium-server-standalone-3.1.0.jar -role node -hub http://localhost:4444/grid/register -浏览器 browserName=chrome,maxInstances=20 -port 6661
(3 个不同节点的端口号为 6661、6662 和 6663。)
我有 100 多个带有 @Test TAG 的测试用例,但一次只有 10 个测试用例并行执行。我想同时执行 50+ 测试。我错过了什么?
提前致谢。
最佳答案
您可以在 xml 中使用以下配置设置并行线程的数量。例如:
如果你想并行运行你的测试方法(在这个例子中MyTest类包含多个@Test方法)
<suite name="mySuite" parallel="methods" thread-count="50">
<test name="myTests">
<classes>
<class name="test.sample.MyTest1" />
</classes>
</test>
</suite>
或
<suite name="mySuite" parallel="methods" thread-count="50">
<test name="myTests">
<packages>
<package name="test.sample" />
</packages>
</test>
</suite>
如果您想为 50 个测试类运行 50 个线程(对于此示例,1 个类 = 1 个测试)。
<suite name="mySuite" parallel="tests" thread-count="50">
<test name="thread 1">
<classes>
<class name="test.sample.MyTest1" />
</classes>
</test>
<test name="thread 2">
<classes>
<class name="test.sample.MyTest2" />
</classes>
</test>
...
<test name="thread 50">
<classes>
<class name="test.sample.MyTest50" />
</classes>
</test>
</suite>
对于其他选项,您可以查看 TestNG 文档:https://testng.org/doc/documentation-main.html#parallel-tests
关于java - Selenium(JAVA) 网格仅在 Windows 中同时启动 10 个浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52886310/