【问题标题】:Setting timeout with testNG and Selenium in Java在 Java 中使用 testNG 和 Selenium 设置超时
【发布时间】:2013-11-29 14:43:43
【问题描述】:

我在使用 Java 进行测试时遇到了问题。我正在使用 TestNG 和 Selenium。我想长时间运行带有注释 @Test 的方法,但它在大约 5000 秒后停止。我试图设置属性超时,但它对我不起作用。如何控制测试方法的执行时间?

有时我注意到我的测试方法在大约 5000 秒后停止之前抛出异常“org.openqa.selenium.remote.SessionNotFoundException: Session ID is null”。

【问题讨论】:

    标签: java selenium testng


    【解决方案1】:

    在对任何元素执行任何操作之前,使用 WebDriver 等待等待预期条件,这样测试用例就不会因时间问题而失败

        WebDriverWait wait = new WebDriverWait(driver, 80);// Maximum TimeOut
        PageUtil.refreshObject(driver, By.linkText("Link_yu_want_to_click"));
        wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Link_yu_want_to_click")));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-11
      • 2020-05-21
      • 1970-01-01
      相关资源
      最近更新 更多