我们有一个虚拟的 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虚拟机没有这样的问题。