2016-10-11 81 views
0

我使用的是C#上的硒webdriver,我正在使用页面对象模块。现在我需要一个语法来明确地等待,因为我已经拥有了webelement。显式等待Selenium Webdriver用于手动元素

[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.driver, TimeSpan.FromSeconds(Time)); 
wait.Until(ExpectedConditions.ElementExists(by)); 

现在我需要使用该元素在手。

回答

4

您应该尝试使用ExpectedConditions.ElementToBeClickable这将接受IWebElement以及输入要等到元素是可见的,如下启用: -

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

在预期条件下不接受ElementToBeClickable。它给出.........'OpenQA.Selenium.Support.UI.ExpectedConditions'不包含'ElementToBeClickable –

+0

的定义你可以看到这个链接的c#文档,https://seleniumhq.github.io/ selenium/docs/api/dotnet/html/M_OpenQA_Selenium_Support_UI_ExpectedConditions_ElementToBeClickable_1.htm它由'ExpectedConditions'支持。我很奇怪你为什么会得到错误 –

+0

你使用什么版本的硒? –

0

预期状况的方法采取By当作它们的参数,你想使用ElementIsVisible,即下面应该工作:

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