0

以下 selenium-client (1.2.18) 脚本在我们的测试环境中超时。该脚本在本地工作,但不在我们的测试环境中。我只包含了重现超时所需的最少代码(这就是我直接执行 http.post 的原因)。

在测试环境中,我查看了 firefox sessionstore.js 并看到浏览器正在访问该站点,但它似乎永远不会与节点通信。

编辑: curl 'www.google.com' 在测试环境中工作。

require 'selenium/client'
require 'net/http'

@browser = Selenium::Client::Driver.new(:host => 'localhost',
                                            :port => 4445,
                                            :browser => '*firefox',
                                            :url => 'http://www.google.com/',
                                            :timeout_in_second => 60)
@browser.start_new_browser_session
session_id = @browser.session_id
p "SESSION ID: #{session_id}"

http = Net::HTTP.new('localhost', 4445)

begin
  response = http.post('/selenium-server/driver/',"cmd=open&1=landing/summer/index.html&2=true&sessionId=#{session_id}")
  p "RESPONSE: #{response}"
ensure
  p "CLOSING SESSION..."
  @browser.close_current_browser_session
end

Grid hub 开始于以下内容:

selenium-server-standalone-2.25.0.jar -port 4445 -timeout 180 -singleWindow -role hub -browserTimeout 300 -newSessionMaxWaitTimeInSeconds 300 -newSessionWaitTimeout 300 -firefoxProfileTemplate /var/tmp/selenium-grid-start-stop/releases/20130802031034/firefox_profile -trustAllSSLCertificates

节点以以下内容开头:

selenium-server-standalone-2.25.0.jar -role node -port 6666 -hub http://localhost:4445/grid/register -maxSession 1 -firefoxProfileTemplate /var/tmp/selenium-grid-start-stop/releases/20130802031034/firefox_profile -browser browserName=*firefox,seleniumProtocol=Selenium

并运行测试脚本...

$ruby test2.rb 
"SESSION ID: 18609e43667a4aa094fe81ef30551b84"
"CLOSING SESSION..."
/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/protocol.rb:140:in `rescue in     rbuf_fill': Timeout::Error (Timeout::Error)
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/protocol.rb:134:in     `rbuf_fill'
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/protocol.rb:116:in `readuntil'
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/protocol.rb:126:in `readline'
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:2219:in `read_status_line'
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:2208:in `read_new'
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:1191:in `transport_request'
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:1177:in `request'
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:1170:in `block in request'
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:627:in `start'
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:1168:in `request'
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:978:in `post'

以前有人见过这种超时吗?该网站(谷歌)显然是。也许测试环境中配置错误?

4

1 回答 1

0

我找到了解决方案。我们不小心将测试环境中的 Firefox 从 10 升级到了 17。

我们的 Grid 节点提供的 Firefox prefs.js 不适用于 Firefox 17。这允许浏览器启动并成功连接到站点,但无法(无论出于何种原因)响应节点。

解决方案是提供适用于 FF 17 的更新 prefs.js。我们通过运行测试而不自己提供首选项来获得它。这迫使 Firefox 创建一个我们复制和编辑的默认首选项文件。

于 2013-08-07T02:24:47.457 回答