【问题标题】:Selenium iedriver IE 11 not startingSelenium iedriver IE 11 未启动
【发布时间】:2014-11-14 01:14:48
【问题描述】:

我没有设法让 ie webdriver 与 Selenium 和 IE 11 一起工作。

webdriver 启动,接收来自我的测试运行器的 json 请求,然后崩溃。

我正在使用:

  • Selenium Webdriver 2.44
  • IE Driver server 2.44 在我的会话中启动
  • C#,Nunit

我使用以下选项实例化 RemoteWebDriver:

  • 网址=http://localhost:5555
  • 浏览器 InternetExplore

这是我所做的:

我尝试直接使用iewebdriver没有成功。

感谢任何帮助/建议。

这是来自服务器的堆栈跟踪(日志级别 = 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

这是来自我的代码运行器的堆栈跟踪:

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

为了清楚这个问题,我将尝试更简单的设置。

【问题讨论】:

  • 您好,能否请您提供您的编码方式的 sn-p,并且还注意到您在堆栈跟踪上将请求发送到 localhost:5555/session?
  • 谢谢扎克,我加了。我将尝试提交更简单的设置来重现我的问题。

标签: selenium selenium-webdriver internet-explorer-11


【解决方案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 位(出于性能原因),一切都运行良好。

感谢您抽出时间 Zach。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-08
    • 2018-11-16
    • 1970-01-01
    • 1970-01-01
    • 2017-10-15
    • 1970-01-01
    • 2014-09-04
    相关资源
    最近更新 更多