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 ?
If you're using c#, I think you just need a couple typographical fixes. As @Guy mentioned, you are missing a closing parenthesis before until; Also the methods Until
and SendKeys
need to start with a capital letter in 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? That will make it so that it will wait AT MOST 10 ms, is this what you want?
wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.XPath("//input[@id='usernameOrEmail']"))).SendKeys("John Doe"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.