以下 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'
以前有人见过这种超时吗?该网站(谷歌)显然是。也许测试环境中配置错误?