简体   繁体   English

SeleniumExtras.WaitHelpers.ExpectedConditions

[英]SeleniumExtras.WaitHelpers.ExpectedConditions

I've written the following:我写了以下内容:

double waitTime = 10;

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

The error I'm getting for the above code is 'TimeSpan' does not contain a definition for 'until'.. I was under the impression that 'until' was a part of the 'SeleniumExtras.WaitHelpers' library ?我在上面的代码中得到的错误是“TimeSpan”不包含“直到”的定义。我的印象是“直到”是“SeleniumExtras.WaitHelpers”库的一部分?

If you're using c#, I think you just need a couple typographical fixes. 如果您使用的是c#,我认为您只需要几个印刷修正即可。 As @Guy mentioned, you are missing a closing parenthesis before until; 正如@Guy所提到的,直到之前您都缺少右括号。 Also the methods Until and SendKeys need to start with a capital letter in C#. 同样,方法UntilSendKeys需要以C#中的大写字母开头。 So I think it should be 所以我认为应该

double waitTime = 10;

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

or I think it's a little more clear if you split your wait into two lines: 或者我认为将等待时间分成两行会更加清楚:

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"));

My one outstanding question is about your wait time--10 milliseconds? 我的一个悬而未决的问题是关于您的等待时间-10毫秒? That will make it so that it will wait AT MOST 10 ms, is this what you want? 这样就可以等待最多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