我在 C# 上使用 selenium webdriver,我正在使用页面对象模块。现在我需要一个语法来显式等待,因为我已经有了 web 元素。
[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));
现在我需要使用手头的元素。
最佳答案
您应该尝试使用 ExpectedConditions.ElementToBeClickable
它将接受 IWebElement
以及输入,并会等到元素可见并启用,如下所示:-
WebDriverWait wait = new WebDriverWait(driver.driver, TimeSpan.FromSeconds(Time));
wait.Until(ExpectedConditions.ElementToBeClickable(Password));
关于c# - 显式等待 Selenium Webdriver 获取手中的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39975256/