【问题标题】:Unable to create new remote session无法创建新的远程会话
【发布时间】:2017-03-03 12:53:47
【问题描述】:

如何解决此问题。早些时候我的代码可以工作,但是 IE 设置被某人重置了。现在我得到了这个异常。

Started InternetExplorerDriver server (32-bit)
2.53.1.0
Listening on port 16183
Only local connections are allowed
Oct 21, 2016 10:14:12 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Oct 21, 2016 10:14:12 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to straight W3C remote end connection
Oct 21, 2016 10:14:12 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}], required capabilities = null
Build info: version: 'unknown', revision: '3169782', time: '2016-09-29 10:24:50 -0700'
System info: host: 'BWT12654001', ip: '10.52.132.157', os.name: 'Windows Server 2008 R2', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_101'
Driver info: driver.version: InternetExplorerDriver
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:80)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:602)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:228)
    at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:180)
    at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:172)
    at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:144)
    at mypackage.TestIEBrowser.main(TestIEBrowser.java:33)

【问题讨论】:

  • 您使用的是什么selenium webdriver 版本?本周我测试了webdriver 版本3.0.1 并在远程执行时遇到了同样的异常。在我的本地机器上它仍在工作。还没来得及调查。我工作的webdriver 版本是2.53

标签: selenium-webdriver remotewebdriver


【解决方案1】:

这可以在没有所需功能设置的情况下开箱即用。转到互联网选项>>安全,点击:'将所有区域重置为默认级别,然后确保所有四个区域的'启用保护模式'复选框都被勾选。

【讨论】:

  • 这无助于解决 Mozilla firefox 中的相同问题
  • @ChandraShekhar,这是专门针对 IE 而不是 Firefox 的解决方案
【解决方案2】:

首先,检查 Internet Explorer 中的默认缩放级别。如果不是 100%,请执行以下步骤:

  • 打开 Internet Explorer。

  • 按 Alt + X,然后单击 Internet 选项。

  • 单击“高级”选项卡。

  • 勾选“重置新窗口和标签的缩放级别”

  • 按应用并确定。

  • 关闭并打开 Internet Explorer 窗口并检查默认缩放 设置为 100 %。

完成上述步骤后,在代码中添加以下行:

DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);

现在运行你的程序,它应该可以工作了。

希望对你有帮助!!

【讨论】:

    【解决方案3】:

    这个问题在Selenium project on Github讨论

    这是帮助我解决问题的最相关/信息最丰富的部分的引用:

    好消息是它看起来像 IE 驱动程序大部分适用于 IE11,前提是 (a) 所有安全区域都设置为相同的保护模式设置和 (b) 增强 保护模式已关闭。请注意,标准注册表会检查 IE 驱动程序 用于测试 IE7-10 中的保护模式设置在 IE11 中被破坏,我们从来没有 尝试检查增强保护模式,所以没有警告(还) 如果您没有正确设置这些设置。

    坏消息是 cookie 操作被破坏了。很糟糕。如果您尝试设置或 检索 cookie,您可能会遇到“无法获取浏览器” 之前遇到的错误。目前,没有解决方法。

    【讨论】:

      【解决方案4】:

      我遇到了同样的问题(在我的情况下是 Firefox):

       Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, browserName=firefox, moz:firefoxOptions={binary=Optional.empty, args=[], legacy=null, logLevel=null, prefs={}, profile=null}, version=, platform=ANY}], required capabilities = Capabilities [{moz:firefoxOptions={binary=Optional.empty, args=[], legacy=null, logLevel=null, prefs={}, profile=null}}]
      

      使用 Selenium 驱动程序 3.3.1:

      <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.3.1</version>
      </dependency>
      

      并通过另一个版本如3.4+ 解决。

      <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.4.0</version>
      </dependency>
      

      【讨论】:

        猜你喜欢
        • 2017-09-10
        • 2017-05-26
        • 2021-04-05
        • 2017-06-03
        • 1970-01-01
        • 1970-01-01
        • 2022-01-16
        • 2017-12-19
        • 2017-08-01
        相关资源
        最近更新 更多