首页 > 解决方案 > 使用相同的浏览器实例如何运行测试套件

问题描述

我有一个测试套件(4 个课程),所有课程都有共同的登录名。当我运行测试套件时,仅第一类具有登录功能并评论其余 3 个类的登录代码(重定向 url ),它只运行第一类,其余 3 个类都失败了!

 <classes>
 <class name="testcases.TestClass1"></class>
 <class name="testcases.TestClass2"></class>
 <class name="testcases.TestClass3"></class>
 <class name="testcases.TestClass4"></class>

</classes>

请帮忙

标签: seleniumselenium-webdrivertestngtestng.xml

解决方案


You can try using before suite annotation available in TestNG.

@BeforeSuite: The annotated method will be run before all tests in this suite have run.

Create the driver instance as part of before suite and access it across.

Refer to TestNG documentation for more information on the annotation.


推荐阅读