我没有设法让ie webdriver与Selenium和IE 11一起使用。
webdriver启动,从我的测试运行器接收json请求然后崩溃。
我正在使用:
我使用以下选项实例化RemoteWebDriver:
http://localhost:5555
以下是我所做的:
我尝试直接使用iewebdriver但没有成功。
感谢任何帮助/建议。
以下是服务器的堆栈跟踪(log level = TRACE)
C:\iedriverserver /log-level=trace
I 2014-11-10 17:19:56:045 server.cc(72) Starting WebDriver server on port: '5555' on host: ''
T 2014-11-10 17:19:56:045 server.cc(592) Entering Server::PopulateCommandRepository
T 2014-11-10 17:19:56:045 IEServer.cpp(26) Entering IEServer::IEServer
T 2014-11-10 17:19:56:045 server.cc(88) Entering Server::Start
D 2014-11-10 17:19:56:045 server.cc(110) Civetweb ACL is -0.0.0.0/0,+127.0.0.1
Started InternetExplorerDriver server (64-bit)
2.44.0.0
Listening on port 5555
Log level is set to TRACE
T 2014-11-10 17:20:15:745 server.cc(136) Entering Server::ProcessRequest
T 2014-11-10 17:20:15:745 server.cc(200) Entering Server::ReadRequestBody
T 2014-11-10 17:20:15:776 server.cc(145) Process request with: URI: /session HTTP verb: POST body: {"desiredCapabilities":{"browserName":"internet explorer","version":"11","platform":"WINDOWS","ignoreProtectedModeSettings":"false"}}
T 2014-11-10 17:20:15:776 server.cc(234) Entering Server::DispatchCommand
T 2014-11-10 17:20:15:776 server.cc(541) Entering Server::LookupCommand
D 2014-11-10 17:20:15:776 server.cc(243) Command: POST /session {"desiredCapabil
ities":{"browserName":"internet explorer","version":"11","platform":"WINDOWS","ignoreProtectedModeSettings":"false"}}
T 2014-11-10 17:20:15:776 IEServer.cpp(36) Entering IEServer::InitializeSession
T 2014-11-10 17:20:15:776 IESession.cpp(34) Entering IESession::Initialize
D 2014-11-10 17:20:15:776 IESession.cpp(49) Mutex acquired for session initalization
D 2014-11-10 17:20:15:776 IESession.cpp(94) Using legacy driver implementation per user request
T 2014-11-10 17:20:15:776 IECommandExecutor.cpp(396) Entering IECommandExecutor::ThreadProc
T 2014-11-10 17:20:15:854 IECommandExecutor.cpp(90) Entering IECommandExecutor::OnCreate
T 2014-11-10 17:20:15:854 IECommandExecutor.cpp(768) Entering IECommandExecutor::PopulateCommandHandlers
T 2014-11-10 17:20:15:854 IECommandExecutor.cpp(755) Entering IECommandExecutor::PopulateElementFinderMethods
T 2014-11-10 17:20:15:854 InputManager.cpp(34) Entering InputManager::InputManager
T 2014-11-10 17:20:15:854 InputManager.cpp(57) Entering InputManager::Initialize
T 2014-11-10 17:20:15:854 BrowserFactory.cpp(885) Entering BrowserFactory::GetExecutableLocation
T 2014-11-10 17:20:15:854 BrowserFactory.cpp(926) Entering BrowserFactory::GetIEVersion
T 2014-11-10 17:20:15:886 BrowserFactory.cpp(977) Entering BrowserFactory::GetOSVersion
T 2014-11-10 17:20:15:901 IESession.cpp(118) Created thread for command executor returns HWND: '0000000000050500'
T 2014-11-10 17:20:15:901 IESession.cpp(122) Session id is retrived from command executor window: '52217b4d-06ed-4832-b91c-8acf59e631e2'
D 2014-11-10 17:20:15:901 IESession.cpp(128) Releasing session initialization mutex
T 2014-11-10 17:20:15:901 IESession.cpp(212) Entering IESession::ExecuteCommand
T 2014-11-10 17:20:15:901 IECommandExecutor.cpp(157) Entering IECommandExecutor::OnSetCommand
T 2014-11-10 17:20:15:901 command.cc(28) Entering Command::Deserialize
D 2014-11-10 17:20:15:901 command.cc(33) Raw JSON command: { "name" : "newSession", "locator" : { }, "parameters" : {"desiredCapabilities":{"browserName":"inter
net explorer","version":"11","platform":"WINDOWS","ignoreProtectedModeSettings":"false"}} }
T 2014-11-10 17:20:15:917 IECommandExecutor.cpp(168) Entering IECommandExecutor::OnExecCommand
T 2014-11-10 17:20:15:917 IESession.cpp(233) Beginning wait for response length to be not zero
T 2014-11-10 17:20:15:917 IECommandExecutor.cpp(464) Entering IECommandExecutor::DispatchCommand
这是我的代码运行者的Stack Trace:
Errors and Failures:
1) TearDown Error : ConsoleApplication1.Features.SubscriptionFeature.Displ
criptionForm with IE,UK
Autofac.Core.DependencyResolutionException : An exception was thrown wh
voking the constructor 'Void .ctor(System.String, System.String, System.Co
ons.Generic.Dictionary`2[System.String,System.String])' on type 'RemoteWeb
'. ---> A exception with a null response was thrown sending an HTTP reques
he remote WebDriver server for URL http://localhost:5555/session. The stat
the exception was ReceiveFailure, and the message was: The underlying conn
was closed: An unexpected error occurred on a receive. (See inner excepti
details.)
----> OpenQA.Selenium.WebDriverException : A exception with a null respo
s thrown sending an HTTP request to the remote WebDriver server for URL ht
ocalhost:5555/session. The status of the exception was ReceiveFailure, and
essage was: The underlying connection was closed: An unexpected error occu
n a receive.
----> System.Net.WebException : The underlying connection was closed: An
ected error occurred on a receive.
----> System.IO.IOException : Unable to read data from the transport con
n: An existing connection was forcibly closed by the remote host.
----> System.Net.Sockets.SocketException : An existing connection was fo
closed by the remote host
TearDown : System.NullReferenceException : Object reference not set to an
ce of an object.
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Insta
()
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInsta
omponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 paramet
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharing
meScope currentOperationScope, IComponentRegistration registration, IEnume
1 parameters)
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistrati
istration, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext con
Service service, IEnumerable`1 parameters, Object& instance)
at Autofac.ResolutionExtensions.ResolveNamed[TService](IComponentContex
ext, String serviceName, IEnumerable`1 parameters)
at ConsoleApplication1.Features.SubscriptionFeature.DisplaySubscription
tring browser, String language)
--WebDriverException
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest
st)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandT
te, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor comman
tor, ICapabilities desiredCapabilities)
at lambda_method(Closure , Object[] )
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Insta
()
--WebException
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest
st)
--IOException
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, I
ize)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userR
edStream, Boolean probeRead)
--SocketException
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, I
ize)
--TearDown
at lambda_method(Closure , IContextManager )
at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding bin
IContextManager contextManager, Object[] arguments, ITestTracer testTracer
Span& duration)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireEvents(Hook
indingEvent)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnScenarioEnd()
at ConsoleApplication1.Features.SubscriptionFeature.ScenarioTearDown()
2) TearDown Error : ConsoleApplication1.Features.SubscriptionFeature.Displ
criptionForm with IE,FR
Autofac.Core.DependencyResolutionException : An exception was thrown wh
voking the constructor 'Void .ctor(System.String, System.String, System.Co
ons.Generic.Dictionary`2[System.String,System.String])' on type 'RemoteWeb
'. ---> Unexpected error. System.Net.WebException: Unable to connect to th
te server ---> System.Net.Sockets.SocketException: No connection could be
ecause the target machine actively refused it 127.0.0.1:5555
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, Socke
ss socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure
et s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState s
IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context
at System.Net.HttpWebRequest.GetRequestStream()
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandTo
e)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandT
te, Dictionary`2 parameters) (See inner exception for details.)
----> OpenQA.Selenium.WebDriverException : Unexpected error. System.Net.
eption: Unable to connect to the remote server ---> System.Net.Sockets.Soc
eption: No connection could be made because the target machine actively re
it 127.0.0.1:5555
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, Socke
ss socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure
et s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState s
IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context
at System.Net.HttpWebRequest.GetRequestStream()
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandTo
e)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandT
te, Dictionary`2 parameters)
TearDown : System.NullReferenceException : Object reference not set to an
ce of an object.
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Insta
()
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInsta
omponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 paramet
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharing
meScope currentOperationScope, IComponentRegistration registration, IEnume
1 parameters)
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistrati
istration, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext con
Service service, IEnumerable`1 parameters, Object& instance)
at Autofac.ResolutionExtensions.ResolveNamed[TService](IComponentContex
ext, String serviceName, IEnumerable`1 parameters)
at ConsoleApplication1.Features.SubscriptionFeature.DisplaySubscription
tring browser, String language)
--WebDriverException
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Respons
rResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandT
te, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor comman
tor, ICapabilities desiredCapabilities)
at lambda_method(Closure , Object[] )
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Insta
()
编辑:根据请求,这里是实例化代码的详细信息。 我正在使用C#和Baseclass.Contrib.SpecFlow.Selenium.NUnit来抽象Web服务器的实例化。它使用Autofac进行IoC。这是autofac conf:
<component
name="IE"
type="Baseclass.Contrib.SpecFlow.Selenium.NUnit.RemoteWebDriver, Baseclass.Contrib.SpecFlow.Selenium.NUnit.SpecFlowPlugin"
service="OpenQA.Selenium.IWebDriver, WebDriver"
instance-scope="per-dependency">
<parameters>
<parameter name="url" value="http://localhost:5555" />
<parameter name="browser" value="InternetExplorer"></parameter>
<parameter name="capabilities">
<dictionary>
<item key="ignoreProtectedModeSettings" value="false"/>
</dictionary>
</parameter>
</parameters>
</component>
这是获取IE webdriver的C#
this.driver = this.container.ResolveNamed<OpenQA.Selenium.IWebDriver>(browser);
this.driver.Manage().Window.Maximize();
this.driver.Navigate().GoToUrl(uri);
//Stuffs
为了解决这个问题,我会尝试更简单的设置。
答案 0 :(得分:1)
没关系,我为IoC设置的参数是错误的。 似乎没有带url,浏览器和功能的构造函数。
正确的配置是:
<component
name="IE"
type="Baseclass.Contrib.SpecFlow.Selenium.NUnit.RemoteWebDriver, Baseclass.Contrib.SpecFlow.Selenium.NUnit.SpecFlowPlugin"
service="OpenQA.Selenium.IWebDriver, WebDriver"
instance-scope="per-dependency">
<parameters>
<parameter name="url" value="http://localhost:5555/" />
<parameter name="browser" value="InternetExplorer"></parameter>
</parameters>
</component>
我也从IE 64位切换到IE 32位(出于性能原因),一切都运行得很好。
感谢您的时间扎克。