【问题标题】:Webdriver causes "SocketError: getaddrinfo: No such host is known" on IE10/Win7Webdriver 在 IE10/Win7 上导致“SocketError: getaddrinfo: No such host is known”
【发布时间】:2013-08-19 10:35:24
【问题描述】:

我们有一个虚拟的 Windows 7 映像,我们的 CI 在 IE10 上运行我们的功能测试。功能测试是使用 Cucumber + Watir-Webdriver 用 Ruby 编写的。

大多数时候它工作正常,但时不时地每个测试开始失败,并出现以下异常:

EXCEPTION: SocketError:  getaddrinfo: No such host is known. 
       C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.34.0/lib/selenium/webdriver/common/platform.rb:169:in `getaddrinfo'
       C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.34.0/lib/selenium/webdriver/common/platform.rb:169:in `localhost'
       C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.34.0/lib/selenium/webdriver/remote/bridge.rb:48:in `block in initialize'
       C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.34.0/lib/selenium/webdriver/remote/bridge.rb:48:in `delete'
       C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.34.0/lib/selenium/webdriver/remote/bridge.rb:48:in `initialize'
       C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.34.0/lib/selenium/webdriver/common/driver.rb:35:in `new'
       C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.34.0/lib/selenium/webdriver/common/driver.rb:35:in `for'
       C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.34.0/lib/selenium/webdriver.rb:67:in `for'
       C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir-webdriver/browser.rb:46:in `initialize'
       C:/jenkins/workspace/TEST_IE10/server/cucumber/support/step_support/browsers.rb:212:in `new'
       C:/jenkins/workspace/TEST_IE10/server/cucumber/support/step_support/browsers.rb:212:in `new_ie_browser'
       C:/jenkins/workspace/TEST_IE10/server/cucumber/support/step_support/browsers.rb:99:in `new_browser'
       C:/jenkins/workspace/TEST_IE10/server/cucumber/support/step_support/browsers.rb:132:in `browser'
       C:/jenkins/workspace/TEST_IE10/server/cucumber/client/features/support/clients/client_support.rb:54:in `new_client'
       C:/jenkins/workspace/TEST_IE10/server/cucumber/client/features/support/clients/client_support.rb:72:in `client'
       C:/jenkins/workspace/TEST_IE10/server/cucumber/client/features/support/clients/client_steps.rb:14:in `Before'

在我重新启动虚拟机之前,通常不会进行进一步的测试运行,然后它会再次运行几天。

我检查了 selenium-webdriver 的代码,失败的行是:

info = Socket.getaddrinfo "localhost", 80, Socket::AF_INET, Socket::SOCK_STREAM

我们没有使用代理,只能在外部 Intranet 内进行通信。不过可以上网。 hosts 文件不包含 localhost 的任何条目。我们正在使用 selenium-webdriver 2.34.0。我们的Win7/IE9虚拟机配置相同,没有这样的问题。

【问题讨论】:

    标签: ruby selenium-webdriver watir-webdriver getaddrinfo


    【解决方案1】:

    hosts 文件不包含 localhost 的任何条目。

    嗯,这可能就是您的问题所在。如果您不在本地解析 localhost,则会使用默认域发送 DNS 查询,例如localhost.example.com。您的 DNS 服务器可能会或可能不会正确响应该查询。

    【讨论】:

    • windows 上的默认主机文件包含显式注释:“本地主机名称解析在 DNS 本身内处理”,并且定义“127.0.0.1 localhost”的行被注释。
    猜你喜欢
    • 2015-09-25
    • 2018-07-12
    • 2016-10-16
    • 2016-01-26
    • 1970-01-01
    • 2020-06-09
    • 2010-11-19
    • 2019-02-19
    • 1970-01-01
    相关资源
    最近更新 更多