以下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
使用以下内容启动了网格集线器:
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'
之前有人见过这种超时吗?该网站(谷歌)明显上升。也许在测试环境中出现了错误的配置?
答案 0 :(得分:0)
我找到了解决方案。我们在测试环境中意外地将Firefox升级为10 - > 17。
我们的Grid节点提供的Firefox prefs.js无法与Firefox 17一起使用。这使浏览器能够成功启动并连接到站点,但无法(无论出于何种原因)响应节点。 / p>
解决方案是提供适用于FF 17的更新的prefs.js。我们通过运行测试而不自行提供偏好来获得此结果。这迫使Firefox创建了我们复制和编辑的默认首选项文件。