http://uniquepig.iteye.com/blog/1568208

	public static boolean waitPageRefresh(WebElement trigger) {
		int refreshTime = 0;
		boolean isRefresh = false;
		try {
			for (int i = 1; i < 60; i++) {
				refreshTime = i;
				trigger.getTagName();
				Thread.sleep(1000);
			}
		} catch (StaleElementReferenceException e) {
			isRefresh = true;
			System.out.println("Page refresh time is:" + refreshTime + " seconds!");
			return isRefresh;
		} catch (WebDriverException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("Page didnt refresh in 60 seconds!");
		return isRefresh;
	}}

  说明: 从selenium 2.16开始 增加了StaleElementReferenceException异常。在页面元素进行刷新后,再次对此元素进行操作则会抛出这个异常。所以可以根据这个作为标识判断页面是否刷新。或者是否跳转到下一个页面。能灵活设定等待时间。并且能够统计刷新时间。

相关文章:

  • 2021-12-19
  • 2022-12-23
  • 2022-01-15
  • 2022-12-23
  • 2021-07-28
  • 2021-05-29
  • 2021-12-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-10
  • 2021-11-12
  • 2021-12-26
  • 2022-12-23
相关资源
相似解决方案