Reputation: 11
I am using selenium webdriver over C# and I am using page object module. Now I need a syntax to use in explicit wait given that I already have the webelement in hand.
[FindsBy(How = How.Id, Using = "Passwd")]
public IWebElement Password {get;set;}
[FindsBy(How = How.Id, Using = "signIn")]
public IWebElement Signin { get; set; }
I need to wait until I find the Element Password.
Before using this module I was using :
WebDriverWait wait = new WebDriverWait(driver.driver, TimeSpan.FromSeconds(Time));
wait.Until(ExpectedConditions.ElementExists(by));
Now I need to use the Element in hand.
Upvotes: 1
Views: 21033
Reputation: 31
Please check if this helps
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until(driver => Password.Displayed);
Upvotes: 1
Reputation: 23805
You should try using ExpectedConditions.ElementToBeClickable
which would accept IWebElement
as well as input and would wait until element is visible and enable as below :-
WebDriverWait wait = new WebDriverWait(driver.driver, TimeSpan.FromSeconds(Time));
wait.Until(ExpectedConditions.ElementToBeClickable(Password));
Upvotes: 5
Reputation: 697
The expected conditions methods take By
as their argument and you want to use ElementIsVisible
, i.e. the below should work:
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until(ExpectedConditions.ElementIsVisible(By.Id("Passwd")));
Upvotes: 0
Reputation: 2221
Add an explicit wait and wait for Password.Displayed
to be true:
[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, TimeSpan.FromSeconds(10));
wait.Until(Password.Displayed);
Full disclosure, I found the answer here: https://groups.google.com/forum/#!topic/webdriver/xdFsocNMSNc
Upvotes: 0