如何使用Selenium C#创建包含display:Block display:none的加载微调器方法? [英] How to create a loading spinner method that include display:Block display: none using Selenium C#?

查看:97
本文介绍了如何使用Selenium C#创建包含display:Block display:none的加载微调器方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在测试中抓住装载机.我需要创建一个方法来帮助我查看加载器何时不再可见.由于此问题,我无法选择任何页面元素.

I can not catch the loader in my test. I need to create a method that will help me to see when the loader is no longer visible. I can not select any of the page elements because of this problem.

尝试输入代码:

public static void SeeNoLoaderInQD() 
{ 
    Actor.Wait.UntilElementIsNotDisplayed(Elements.QDLoader); 
    Assert.IsTrue(Elements.SeeException.Count == 0); 
} 

推荐答案

我会尝试这样的事情:

public static void WaitForElementAttributeValue(this IWebDriver driver, By by, string attribute, string value)
{
    var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
    wait.Until(d => d.FindElement(by).GetAttribute(attribute).Contains(value));
}

您可以针对您的情况调用此方法,如下所示:

You can call this method for your scenario like this:

driver.WaitForElementAttributeValue(By.Id("line-scale-loader"), "style", "display: none;");

调用此方法时,您要告诉WebDriver等待,直到WebElement的style属性值等于display: none;为止,这意味着加载程序不再可见.

When calling this method, you are telling WebDriver to wait until the WebElement's style attribute value is equal to display: none; meaning the loader is no longer visible.

这篇关于如何使用Selenium C#创建包含display:Block display:none的加载微调器方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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