Reputation: 1
I am new to Selenium in C#. I tried to use
wait.Until(ExpectedConditions.ElementIsVisible(By.Id("someId")));
new SelectElement(driver.FindElement(By.Id("someId"))).SelectByText("someText");
I got error like this in my NUnit output:
OpenQA.Selenium.NoSuchElementException : Cannot locate element with text: someText
But when I replace wait.Unitil statement with Tread.Sleep(3000), my test could pass without error.
Need some help. Please advise.
Upvotes: 0
Views: 1294
Reputation: 145
It will work:
wait.Until(d => d.FindElement(By.XPath("//*[@id='someId']//*[text()='someText']")));
new SelectElement(driver.FindElement(By.Id("someId"))).SelectByText("someText");
But will be good to refactor this into single until, something like:
wait.Until(d =>
{
new SelectElement(d.FindElement(By.Id("someId"))).SelectByText("someText");
return d;
});
Upvotes: 1