0

I wait for an element to appear then I try to populate it with SendKeys. 40% of the time the element isn't populated even though the element is enabled and displayed. I put all kinds of Thread.Sleep with all kinds of values everywhere.

My issue is similar to this one but I'm using the PhantomJS driver instead of the Firefox one. Using the solutions from the link above didn't work, I just got undefined function exceptions.

public static IWebElement FindElement(this IWebDriver driver, By by, int timeoutInSeconds)
{
    if (timeoutInSeconds > 0)
    {
        var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds));
        return wait.Until(drv => drv.FindElement(by));
    }
    return driver.FindElement(by);
}    


zipcode = _driver.FindElement(By.Name("iZipCode"), 50);
while(!zipcode.Displayed)
{
    System.Threading.Thread.Sleep(3000);
}
zipcode.Click();
zipcode.Clear();        
System.Threading.Thread.Sleep(3000);
zipcode.SendKeys(OpenQA.Selenium.Keys.Backspace);
zipcode.SendKeys(text);

The element that I'm trying to populate is a textbox that appears upon a combobox selection. I click element in combobox -> textbox is displayed (it is hidden prior to selection of item in combobox).

Community
  • 1
  • 1
Xandarian
  • 191
  • 11

1 Answers1

-1

Using Enter fixed the issued:

zipcode.SendKeys(text);
zipcode.SendKeys(OpenQA.Selenium.Keys.Enter);
Xandarian
  • 191
  • 11