Hopefully someone can help on this issue...
I keep receiving the above error message (see title) when interacting with cascading drop-downs. The only rudimentary fix I have successfully employed is "Thread.Sleep"... See code extract below:
Note I am passing the following parameters:
attribute: ID
attrval: e.g. ID123456 (ID of the drop-down)
parameter: Car (drop-down value we are wanting to select)
IWebElement element = findMyElement(attribute, attrval);
SelectElement selectElement = new SelectElement(element);
selectElement.SelectByText(parameter);
// dirty code - needs to be re-written
Thread.Sleep(500);
if (new SelectElement(findMyElement(attribute, attrval)).SelectedOption.Text.Equals(parameter))
{
return "pass";
}
Note2: findMyElement is a custom method (here is an extract):
public static IWebElement findMyElement(string attribute, string attrval)
{
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
switch (attribute.ToLower())
{
case "id":
wait.Until(ExpectedConditions.ElementExists(By.Id(attrval)));
wait.Until(ExpectedConditions.ElementIsVisible(By.Id(attrval)));
return driver.FindElement(By.Id(attrval));
As I have stated in my code comments is there anyway I can avoid using Thread.Sleep as I am aware that this is not a recommended approach.
Thanks in advance :)