【问题标题】:selenium.waitForPageToLoad("3000") timing out after 3000 msselenium.waitForPageToLoad("3000") 在 3000 毫秒后超时
【发布时间】:2011-06-21 07:04:58
【问题描述】:

我正在使用 selenium 运行一些非常简单的测试,一些测试在我的慢速构建机器上随机失败并出现此错误:

com.thoughtworks.selenium.SeleniumException: 3000 毫秒后超时

针对此代码:

seleniumStart();
selenium.open("*****");
selenium.waitForPageToLoad("3000");     
selenium.type("j_username", LoginTest.DEFAULT_ADMIN_USERNAME );
selenium.type("j_password", LoginTest.DEFAULT_ADMIN_PASSWORD );
selenium.click("loginbutton");
selenium.waitForPageToLoad("3000");
selenium.click("nav_form:managepatients");

它使用spring security,jsf作为前端。有谁知道为什么会这样?我已经坚持了 2 天。

提前致谢。

【问题讨论】:

    标签: java unit-testing spring automation selenium


    【解决方案1】:

    3000 毫秒只有 3 秒,有时可能不足以加载页面,所以也许你只需要提高超时时间? 30000 毫秒 waitForPageToLoad 似乎更合适。

    【讨论】:

    • LOL 30 秒,我认为 10 秒就足够了,但是你是对的
    【解决方案2】:

    selenium.waitForPageToLoad("xxxxxx"); 更强大的方式对我有用的是-

    while (!(selenium.isElementPresent("any element on page")==true)) {
         selenium.setSpeed("10");
         Thread.sleep(10);
        }
    

    这使您可以等到某些预先确定的元素加载,然后执行后续操作。测量响应时间也很好......

    【讨论】:

      【解决方案3】:

      可能页面在那个时间没有加载,如果这不起作用,您是否尝试过将超时时间提高到 30000,您最好的选择是在 selenium 运行时观看浏览器

      【讨论】:

        【解决方案4】:

        您可以增加等待页面加载的时间。 要么 使用:selenium.setSpeed("2000"); - 将等待 2 秒它在 setSpeed 延迟后运行每个命令,延迟时间为 setSpeed 中提到的毫秒数。所以在这种情况下,每次操作后会有 2 秒的时间间隔,这将有助于操作完成,然后切换到下一个操作。

        【讨论】:

          猜你喜欢
          • 2021-12-31
          • 1970-01-01
          • 1970-01-01
          • 2020-08-16
          • 1970-01-01
          • 1970-01-01
          • 2014-04-24
          • 2021-11-14
          • 2014-09-17
          相关资源
          最近更新 更多