C# Selenium Webdriver在IE 11上超时
在IE 11 windows 7上运行Selenium WEbdriver时遇到问题。发送键太慢了。我已经下载了IE的最新webdriver,但它仍然无法工作。以下是我一直收到的超时例外情况:C# Selenium Webdriver在IE 11上超时,c#,internet-explorer,selenium,C#,Internet Explorer,Selenium,在IE 11 windows 7上运行Selenium WEbdriver时遇到问题。发送键太慢了。我已经下载了IE的最新webdriver,但它仍然无法工作。以下是我一直收到的超时例外情况: Test Name: TestInInternetExplorer Test FullName: TravelTest_1.UnitTest1.TestInInternetExplorer Test Source: c:\Users\Documents\Visual Studio 2013\Pr
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
我的代码如下:
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");
}
下面是出现问题的代码:
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;
}
我再也不确定我能做些什么。顺便说一下,这实际上是在伊江运行的,它只是在发送密钥的中间停止。谢谢。在代码中添加了以下内容:
InternetExplorerOptions options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
options.RequireWindowFocus = true;
这加快了我的发送速度。RequiredWinDowFocus解决了我的问题。感谢@Kolichikov在代码中添加了以下内容:
InternetExplorerOptions options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
options.RequireWindowFocus = true;
这加快了我的发送速度。RequiredWinDowFocus解决了我的问题。感谢System.Net上的@Kolichikov。HttpWebRequest.GetResponse()超时表明它与发送密钥无关。很可能服务器在60W中没有响应这是什么意思@Steve?我已经增加了我的隐式等待,因为我认为这将解决问题。显然,这并不意味着这是您的Web服务器的问题。或者连接未正确设置。或者可能是Web服务器没有为localhost正确设置。没有代码/服务器日志,我不能肯定它也可能与。您使用的是什么版本的Selenium?我已经再次尝试了相同的代码,它正在工作,出于某种原因,我不得不减少测试字符串(例如,“testfromdatabase”是示例字符串,然后我使用了“test”)。我觉得这样做很奇怪,但我认为这只是一个字符串测试数据。这里可能有什么问题?我的Selenium版本是2at System.Net.HttpWebRequest.GetResponse()超时表明它与发送密钥无关。很可能服务器在60W中没有响应这是什么意思@Steve?我已经增加了我的隐式等待,因为我认为这将解决问题。显然,这并不意味着这是您的Web服务器的问题。或者连接未正确设置。或者可能是Web服务器没有为localhost正确设置。没有代码/服务器日志,我不能肯定它也可能与。您使用的是什么版本的Selenium?我已经再次尝试了相同的代码,它正在工作,出于某种原因,我不得不减少测试字符串(例如,“testfromdatabase”是示例字符串,然后我使用了“test”)。我觉得这样做很奇怪,但我认为这只是一个字符串测试数据。这里可能有什么问题?我的Selenium版本是2