Selenium Grid Session 多次运行后无法自动关闭并变得无响应

Selenium Grid Session can not close automatically and become non-responsive after several runs

我不知道这是否是设计使然,只是注意到我是这样设置 testNG 的:

<suite name="Suite" parallel="classes" thread-count="4">
    <test name="Test">
        <classes>
            <class name="Test2"/>
            <class name="Test1"/>
            <class name="Test3"/>
            <class name="Test4"/>
        </classes>
    </test> <!-- Test -->
</suite> <!-- Suite -->

然后在我的测试中,

public class BaseTest {

    @AfterTest
    public void afterAll() {
        System.out.println("tear down webdriver here ");
        this.webDriver.quit();
    }
}

Test1到Test 4都在扩展这个基础测试。

但是我注意到,selenium hub 刷新启动后,有两个节点,前几个 运行 都很好,但是当查看控制台时,可用资源越来越少,经过几次 运行,没有可用的资源了,所有的测试都在等待。实际上,每次调用 webdriver.quit() 时,它只会关闭一个会话,而所有其他会话仍处于打开状态。

这使得 Selenium Grid 解决方案一点也不优雅,我们不得不借用很多额外的解决方案,例如每当我们开始新的测试工作时重新启动 selenium grid 等

那么,为什么 driver.quit() 不能关闭所有网格会话,而是只关闭一个会话?驱动程序已经是单例,并且已经在所有测试用例之间共享。

希望听到您的意见。

谢谢

我相信您也必须查看以下实用程序。它可以根据收到的请求动态增加和减少节点。现在让我们来回答你的问题。根据你的问题,我能够理解 webdriver 实例是单例的。问题是,如果您的主要 objective 是为了实现并行测试,请不要让您的 webdriver 成为单例。也请查看最佳实践。 https://docs.experitest.com/display/TE/Parallel+Tests+-+Best+Practices

https://github.com/frostyaxe/Talongrid/tree/master