码迷,mamicode.com
首页 > Web开发 > 详细

waitUntilAllAjaxRequestCompletes

时间:2015-06-04 11:17:57      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:

private static final String JQUERY_ACTIVE_CONNECTIONS_QUERY = "return $.active == 0;";

private static ExpectedCondition<Boolean> noActiveConnections = new ExpectedCondition<Boolean>() {
  @Override
  public Boolean apply(WebDriver driver) {
    JavascriptExecutor jsExec = (JavascriptExecutor) driver;
    return (Boolean) jsExec.executeScript(JQUERY_ACTIVE_CONNECTIONS_QUERY);
   }
};

public static boolean waitUntilAllAjaxRequestCompletes(WebDriver driver) {
  Boolean status = false;
  try {
    status = SeleniumUtil.createWait(driver).until(noActiveConnections);
  } catch (Exception e) {
    status = false;
  }
  return status;
}

 

public static boolean waitUntilAllAjaxRequestCompletes(WebDriver driver, int seconds) {
  Boolean status = false;
  try {
    status = SeleniumUtil.createWait(driver, seconds).until(noActiveConnections);
  } catch (Exception e) {
    status = false;
  }
  return status;
}

waitUntilAllAjaxRequestCompletes

标签:

原文地址:http://www.cnblogs.com/feifeidxl/p/4551007.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!