显式等待Selenium Webdriver中的元素在手

1 c# selenium

我正在通过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; }
Run Code Online (Sandbox Code Playgroud)

我需要等到找到元素密码。

在使用此模块之前,我使用了:

WebDriverWait wait = new WebDriverWait(driver.driver, TimeSpan.FromSeconds(Time));
wait.Until(ExpectedConditions.ElementExists(by));
Run Code Online (Sandbox Code Playgroud)

现在,我需要使用元素。

Sau*_*aur 5

您应该尝试使用ExpectedConditions.ElementToBeClickablewhich既可以接受IWebElement也可以输入,并等待直到元素可见并按如下所示启用:-

WebDriverWait wait = new WebDriverWait(driver.driver, TimeSpan.FromSeconds(Time));
wait.Until(ExpectedConditions.ElementToBeClickable(Password));
Run Code Online (Sandbox Code Playgroud)