I search for a textbox and then try to fill it with a string . Here's the code :
var fname = _driver.FindElement(By.Name("iFirstName"), 50);
if(fname!=null)
{
do
{
System.Threading.Thread.Sleep(500);
} while (!fname.Displayed);
fname.SendKeys(myName);
}
The FindElement function is this :
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);
}
Some of the time the textbox is filled with the string, at other times I get this error :
System.InvalidOperationException: {"errorMessage":"'undefined' is not an object (evaluating '(y(a)?y(a).parentWindow||y(a).defaultView:window).getComputedStyle(a,null).MozTransform.match')","request":{"headers":{"Accept":"application/json, image/png","Connection":"Close","Host":"localhost:59868"},"httpVersion":"1.1","method":"GET","url":"/displayed","urlParsed":{"anchor":"","query":"","file":"displayed","directory":"/","path":"/displayed","relative":"/displayed","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/displayed","queryKey":{},"chunks":["displayed"]},"urlOriginal":"/session/af970250-310e-11e4-8996-210a8c2c5f2a/element/%3Awdc%3A1409489997045/displayed"}}
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) in c:\Projects\webdriver\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 1048
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) in c:\Projects\webdriver\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 865
at OpenQA.Selenium.Remote.RemoteWebElement.get_Displayed() in c:\Projects\webdriver\dotnet\src\webdriver\Remote\RemoteWebElement.cs:line 187
What's the issue here? I even make a printscreen before calling all the above functions and all the elements are drawn correctly therefore the page is correctly loaded.