Csharp/C#教程:显式等待Selenium Webdriver手中的元素分享


显式等待Selenium Webdriver手中的元素

我在C#上使用selenium webdriver,我正在使用页面对象模块。 现在我需要在显式等待中使用语法,因为我已经掌握了webelement。

[FindsBy(How = How.Id, Using = "Passwd")] public IWebElement Password {get;set;} [FindsBy(How = How.Id, Using = "signIn")] public IWebElement Signin { get; set; } 

我需要等到找到Element Password。

在使用这个模块之前我使用的是:

 WebDriverWait wait = new WebDriverWait(driver.driver, TimeSpan.FromSeconds(Time)); wait.Until(ExpectedConditions.ElementExists(by)); 

现在我需要手中使用Element。

您应该尝试使用ExpectedConditions.ElementToBeClickable接受IWebElement和输入,并等待元素可见并启用如下: –

 WebDriverWait wait = new WebDriverWait(driver.driver, TimeSpan.FromSeconds(Time)); wait.Until(ExpectedConditions.ElementToBeClickable(Password)); 

请检查这是否有帮助

 WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); wait.Until(driver => Password.Displayed); 

添加显式等待并等待Password.Displayed为true:

 [FindsBy(How = How.Id, Using = "Passwd")] public IWebElement Password {get;set;} [FindsBy(How = How.Id, Using = "signIn")] public IWebElement Signin { get; set; } WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); wait.Until(Password.Displayed); 

完全披露,我在这里找到答案: https : //groups.google.com/forum/#!topic /webdriver / xdFsocNMSNc

预期的条件方法采用By作为他们的参数,并且您想要使用ElementIsVisible ,即下面应该工作:

上述就是C#学习教程:显式等待Selenium Webdriver手中的元素分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

 WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); wait.Until(ExpectedConditions.ElementIsVisible(By.Id("Passwd"))); 

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/1000401.html

(0)
上一篇 2021年12月27日
下一篇 2021年12月27日

精彩推荐