如何动态地等待直到进度条完全加载到Selenium Webdriver中? [英] How to wait dynamically until the progress bar to load completely in Selenium Webdriver?

查看:69
本文介绍了如何动态地等待直到进度条完全加载到Selenium Webdriver中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在自动化一个AJAX应用程序时,我遇到了以下问题.

While automating one AJAX application i came across a the below problem.

方案:我单击了一个元素,进度条继续加载..我想等待进度条停止.如何使用Java作为语言在Selenium Webdriver中进行此类AJAX元素处理.

Scenario: I clicked on an element and the progress bar keeps on loading..I want to wait for the progress bar to stop. How to go ahead this type AJAX elements in Selenium Webdriver using java as the language.

注意:当进度条正在加载时,在后台该元素为PRESENT ..否则,我将不得不等待一个元素,直到该元素出现为止.

NOTE: When the progress bar is loading, in the background the element is PRESENT..otherwise i would have been used the wait for an element until the element to appear.

有人可以帮我吗?

谢谢

苏丹汉

推荐答案

尝试以下逻辑.

int i=0;
while(isElementPresent(By.id("ajax_progressbar")))
{
    Thread.sleep(100);
    if(++i>200)
    {
       break;
    }
}

  • 检查循环中是否存在元素
  • 如果元素消失,则打破循环
  • 这篇关于如何动态地等待直到进度条完全加载到Selenium Webdriver中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆