簡體   English   中英

SeleniumExtras.WaitHelpers.ExpectedConditions

[英]SeleniumExtras.WaitHelpers.ExpectedConditions

我寫了以下內容:

double waitTime = 10;

new WebDriverWait(driver, TimeSpan.FromMilliseconds(waitTime).until
(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.XPath("//input[@id='usernameOrEmail']"))).sendKeys("John Doe"));

我在上面的代碼中得到的錯誤是“TimeSpan”不包含“直到”的定義。我的印象是“直到”是“SeleniumExtras.WaitHelpers”庫的一部分?

如果您使用的是c#,我認為您只需要幾個印刷修正即可。 正如@Guy所提到的,直到之前您都缺少右括號。 同樣,方法UntilSendKeys需要以C#中的大寫字母開頭。 所以我認為應該

double waitTime = 10;

new WebDriverWait(driver, TimeSpan.FromMilliseconds(waitTime)).Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.XPath("//input[@id='usernameOrEmail']"))).SendKeys("John Doe"));

或者我認為將等待時間分成兩行會更加清楚:

double waitTime = 10;

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromMilliseconds(waitTime));
wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.XPath("//input[@id='usernameOrEmail']"))).SendKeys("John Doe"));

我的一個懸而未決的問題是關於您的等待時間-10毫秒? 這樣就可以等待最多10毫秒,這是您想要的嗎?

wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.XPath("//input[@id='usernameOrEmail']"))).SendKeys("John Doe"));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM