等待“加载"图标从页面上消失 [英] wait for "loading" icon to disappear from the page

查看:82
本文介绍了等待“加载"图标从页面上消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在为Web应用程序自动化,大多数情况下正在加载图标将显示在页面的中心..我们需要等待dis加载图标出现

we are doing automation for web application and most of the scenario getting loading icon will appear at center of the page .. we need to wait for dis appear to loading icon

<div id="loading" style="display: none; visibility: hidden;">
<div></div>
<div></div> 

示例:在大多数情况下,我们都具有搜索功能,我们将获得此加载图标.

Example : we are having search functionality their in most of scenario we are getting this loading icon.

我们正在使用的硒webdriver:id我们要完成加载的id是id ="loading".请为上述问题提供解决方案.

selenium webdriver we are using: id we are getting for loading to complete is id= "loading"..please any give the solutions for the above issues am facing.

我们具有不同的功能,例如click& sendkeys

we have different functionality like click & sendkeys

推荐答案

显式等待应该有所帮助:

Explicit Wait should help:

public static String waitForElementNotVisible(int timeOutInSeconds, WebDriver driver, String elementXPath) {
    if ((driver == null) || (elementXPath == null) || elementXPath.isEmpty()) {

        return "Wrong usage of WaitforElementNotVisible()";
    }
    try {
        (new WebDriverWait(driver, timeOutInSeconds)).until(ExpectedConditions.invisibilityOfElementLocated(By
                .xpath(elementXPath)));
        return null;
    } catch (TimeoutException e) {
        return "Build your own errormessage...";
    }
}

这篇关于等待“加载"图标从页面上消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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