Reputation: 312
I am having troubles running Selenium WEbdriver on IE 11 windows 7. The Send Keys are so slow. I have already downloaded the latest webdriver for IE but it won't still work. Below is the time out exception I kept receiving:
Test Name: TestInInternetExplorer
Test FullName: TravelTest_1.UnitTest1.TestInInternetExplorer
Test Source: c:\Users\Documents\Visual Studio 2013\Projects\TravelTest_1\TravelTest_1\UnitTest1.cs : line 34
Test Outcome: Failed
Test Duration: 0:01:36.7213961
Result Message:
Test method TravelTest_1.UnitTest1.TestInInternetExplorer threw exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:14927/session/41c432de-a158-4a14-bbc0-38a21cd67582/element/c9da6f89-09e9-4da9-a84a-ea262762491d/value timed out after 60 seconds. ---> System.Net.WebException: The operation has timed out
Result StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
--- End of inner exception stack trace ---
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebElement.SendKeys(String text)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at OpenQA.Selenium.Support.PageObjects.WebDriverObjectProxy.InvokeMethod(IMethodCallMessage msg, Object representedValue)
at OpenQA.Selenium.Support.PageObjects.WebElementProxy.Invoke(IMessage msg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at OpenQA.Selenium.IWebElement.SendKeys(String text)
at TravelTest_1.CreateTANonProxy_Domestic.FillGeneralInfo() in c:\Users\Documents\Visual Studio 2013\Projects\TravelTest_1\TravelTest_1\CreateTANonProxy_Domestic.cs:line 112
at TravelTest_1.UnitTest1.CreateTADraft(IWebDriver driver) in c:\Users\Documents\Visual Studio 2013\Projects\TravelTest_1\TravelTest_1\UnitTest1.cs:line 123
at TravelTest_1.UnitTest1.TestInInternetExplorer() in c:\Users\Documents\Visual Studio 2013\Projects\TravelTest_1\TravelTest_1\UnitTest1.cs:line 44
My code is below:
InternetExplorerOptions options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
using (IWebDriver IEDriver = new InternetExplorerDriver(options))
{
Console.WriteLine("Executed in IE 11");
CreateTADraft(IEDriver);
Console.WriteLine("Draft saved in IE 11");
}
And below is the code that is having problems:
count = counter;
if (count.Equals(counter))
{
count = count + 1;
y = count;
}
try
{
using (var context = new MainDataContext(Properties.Settings.Default.ConnectionString))
{
foreach (var e in context.TARequestForm.Where(x => x.Id == y))
{
String contact = e.Phone;
String purpose = e.Purpose;
purposeBox.Clear();
purposeBox.SendKeys(purpose);
contactBox.Clear();
contactBox.SendKeys(contact);
}
}
}catch(WebDriverTimeoutException e)
{
Console.WriteLine(e);
throw e;
}
I am not sure anymore of whatever workaround I can do. Btw, this actually runs in IE, it just stops in the middle of sending keys. Thanks.
Upvotes: 0
Views: 1597
Reputation: 312
Added the following in code:
InternetExplorerOptions options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
options.RequireWindowFocus = true;
This sped up my sendkeys. The RequireWindowFocus resolved my issue. Thanks @Kolichikov
Upvotes: 3