Selenium webdriver 如何为TestNG设置超时';s@BeforeSuite方法通过侦听器类
我想通过侦听器类为BeforeSuite方法设置一些超时。我找不到这方面的帮助。(Am使用Selenium WebDriver) 我有这么多的测试套件,我们已经为每个测试设置了超时时间&我也想限制BeforeSuite方法的时间。 我希望通过侦听器设置它,而不是在每个套件中添加它Selenium webdriver 如何为TestNG设置超时';s@BeforeSuite方法通过侦听器类,selenium-webdriver,testng,Selenium Webdriver,Testng,我想通过侦听器类为BeforeSuite方法设置一些超时。我找不到这方面的帮助。(Am使用Selenium WebDriver) 我有这么多的测试套件,我们已经为每个测试设置了超时时间&我也想限制BeforeSuite方法的时间。 我希望通过侦听器设置它,而不是在每个套件中添加它 @BeforeSuite(groups = {"aa-bb-cc"}) public void abcdef(ITestContext context) throws Exception { .
@BeforeSuite(groups = {"aa-bb-cc"})
public void abcdef(ITestContext context) throws Exception {
....}
@AfterSuite(groups = {"aa-bb-cc"})
public void cleanup() {
quitDriver();
}
如何使用上述2种方法的侦听器设置超时(而不是像@BeforeSuite(groups={“aa bb cc”},timeout=600000)那样硬编码超时)您可以使用org.testng.IAnnotationTransformer2 ,, 如果需要,请使用此接口而不是iAnotationTransformer 修改@Test之外的任何TestNGannotation 您需要重写具有参数IConfigurationAnnotation的方法
@Override
public void transform(IConfigurationAnnotation annotation, Class testClass,
Constructor testConstructor, Method testMethod) {
annotation.setTimeOut(10);
}