I am looking for a text box and then try to fill it with a string. Here is 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 as follows:
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);
}
For some time, the text field is filled with a string, at another time 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 is the problem here? I even create a screen for printing before calling all of the above functions, and all the elements are drawn correctly, so the page is loaded correctly.