dsxmwin86342 2013-04-12 14:03
浏览 51

如何使用Selenium 2驱动程序在Mink中为页面加载设置超时?

My application uses Mink with Selenium 2 driver. when i try to load the page with some resources that are loading slow (or not loading at all) the application waits infinitely until everything is loaded.

for i have several hundreds of iterations in my application - you can imagine how long the script is executed.

question: is there any possibility to set a timeout for page to load? and throw some exception if the page is not loaded during that period?

thanks in advance!

  • 写回答

4条回答 默认 最新

  • dt3358 2013-04-20 06:23
    关注

    To set timeout for loading for page in selenium ide follow these steps:

    1. Open selenium ide.

    2. Click on option menu.

    3. In general tab change defult timeout value for recorded command.

    ![Selenium ide image after click on option menu][1]

    In selenium 2 use this function

    WebDriver driver = new FirefoxDriver();
    driver.get("http://somedomain/url_that_delays_loading");
    WebElement myDynamicElement = (new WebDriverWait(driver, 10))
      .until(ExpectedConditions.presenceOfElementLocated(By.id("myDynamicElement")));
    

    Try this

     private $timeout = 60000;
    
    
    public function reload()
        {
            $this->browser
                ->refresh()
                ->waitForPageToLoad($this->timeout)
            ;
        }
    
    

    ttp://i.stack.imgur.com/0NKoC.png

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料