java - 带有 webdriver 和 testNG 的 Selenium 网格

标签 java selenium-webdriver testng selenium-grid

我遇到了以下问题。我设置了一个包含 2 个节点的网格,以便并行运行测试。我的 suite.xml 文件有两组,每个节点一组:

<suite name="testSuites"  configfailurepolicy="continue"   thread-count="2" parallel="tests">
 test name="testSuite1" preserve-order="true">
 <classes>
    <class name="testA1" />
    <class name="testB1" />
    <class name="testC1" /> 
</classes>
 </test>
 <test name="testSuite2" preserve-order="true">
 <classes>
    <class name="testA2" />
    <class name="testB2" />
    <class name="testC2" /> 
</classes>
 </test>

每个类,例如 testA1 都有以下 testNG 配置:

 @BeforeClass(alwaysRun = true)
    public void createInitialData()  {  
}

    @Test(alwaysRun = true, description = "bla bla")
    public void testStep_1() throws Exception{

    }

    @Test(alwaysRun = true, description = "bla bla ", dependsOnMethods ="testStep_1" )
    public void testStep_2() {
    }

运行时我注意到在执行过程中,测试按测试步骤顺序执行,这意味着:

testA1-testStep_1, testB1-testStep_1, testC1-testStep_1, testA1-testStep_2, testB1-testStep_2, testC1-testStep_2

本来应该是:

testA1-testStep_1, testA1-testStep_2, and then testB1-testStep_1, testB1-testStep_2, testC1-testStep_1, testC1-testStep_2

有什么建议吗?

最佳答案

尝试在 xml 中设置按实例分组

<suite  group-by-instances="true">

<test group-by-instances="true">

关于java - 带有 webdriver 和 testNG 的 Selenium 网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29622365/

相关文章:

java - 尝试从主方法运行 TestNG 时无法在类路径中找到类

xml - 通过 XML 在 TestNG 中的套件之前运行方法

java - 是否可以让你添加到java中的组件的代码变得更小?

java - 从 Java Applet 获取 PDF 文件

java - 为什么 java 9 用户应该切换到 java 10?

java - Selenium:元素未通过 LINK_TEXT 或 PARTIAL_LINK_TEXT 定位

java - 您如何知道何时需要添加单独的类?

Selenium WebDriverException : Session [null] not available and is not among the last 1000 terminated sessions

python - 如何在 Webdriver Chrome 配置文件中禁用文件下载

java - 我创建了一个页面对象模型,但我的登录页面为空。我该如何解决这个问题?