Skip to content

Commit

Permalink
Correct server download location in Selenium::Server (thanks marekj).
Browse files Browse the repository at this point in the history
This fixes issue 7049.
  • Loading branch information
jarib committed Aug 29, 2014
1 parent 733ebe5 commit 7429633
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions rb/CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Make sure the browser process is properly killed if silent startup hangs (#7392)
* Loosen websocket dependency to ~> 1.0
* Add support for `switch_to.parent_frame` (thanks abotalov)
* Fix download location for Selenium::Server.{latest,get} (#7049 - thanks marekj)

2.42.0 (2014-05-23)
===================
Expand Down
12 changes: 7 additions & 5 deletions rb/lib/selenium/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ def self.download(required_version)

begin
open(download_file_name, "wb") do |destination|
net_http.start("selenium.googlecode.com") do |http|
resp = http.request_get("/files/#{download_file_name}") do |response|
net_http.start("selenium-release.storage.googleapis.com") do |http|
resp = http.request_get("/#{required_version[/(\d+\.\d+)\./, 1]}/#{download_file_name}") do |response|
total = response.content_length
progress = 0
segment_count = 0
Expand Down Expand Up @@ -95,9 +95,11 @@ def self.download(required_version)
#

def self.latest
net_http.start("code.google.com") do |http|
resp = http.get("/p/selenium/downloads/list")
resp.body.to_s[/selenium-server-standalone-(\d+.\d+.\d+).jar/, 1]
require 'rexml/document'
net_http.start("selenium-release.storage.googleapis.com") do |http|
REXML::Document.new(http.get("/").body).root.get_elements("//Contents/Key").map { |e|
e.text[/selenium-server-standalone-(\d+\.\d+\.\d+)\.jar/, 1]
}.compact.max
end
end

Expand Down
11 changes: 6 additions & 5 deletions rb/spec/unit/selenium/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
required_version = '10.2.0'
expected_download_file_name = "selenium-server-standalone-#{required_version}.jar"

stub_request(:get, "http://selenium.googlecode.com/files/#{expected_download_file_name}").to_return(:body => "this is pretending to be a jar file for testing purposes")
stub_request(:get, "http://selenium-release.storage.googleapis.com/10.2/selenium-server-standalone-10.2.0.jar").to_return(:body => "this is pretending to be a jar file for testing purposes")

begin
actual_download_file_name = Selenium::Server.download(required_version)
Expand Down Expand Up @@ -100,18 +100,19 @@
end

it "should know what the latest version available is" do
latest_version = '10.2.0'
stub_request(:get, "http://code.google.com/p/selenium/downloads/list").to_return(:body => "web page containing jar selenium-server-standalone-#{latest_version}.jar")
latest_version = '2.42.2'
example_xml ="<?xml version='1.0' encoding='UTF-8'?><ListBucketResult xmlns='http://doc.s3.amazonaws.com/2006-03-01'><Name>selenium-release</Name><Contents><Key>2.39/selenium-server-2.39.0.zip</Key></Contents><Contents><Key>2.42/selenium-server-standalone-#{latest_version}.jar</Key></Contents></ListBucketResult>"
stub_request(:get, "http://selenium-release.storage.googleapis.com/").to_return(:body => example_xml)

Selenium::Server.latest.should == latest_version
end

it "should download the latest version if that has been specified" do
required_version = '10.6.0'
required_version, minor_version = '2.42.2', '2.42'
expected_download_file_name = "selenium-server-standalone-#{required_version}.jar"

Selenium::Server.should_receive(:latest).and_return required_version
stub_request(:get, "http://selenium.googlecode.com/files/#{expected_download_file_name}").to_return(:body => "this is pretending to be a jar file for testing purposes")
stub_request(:get, "http://selenium-release.storage.googleapis.com/#{minor_version}/#{expected_download_file_name}").to_return(:body => "this is pretending to be a jar file for testing purposes")

begin
actual_download_file_name = Selenium::Server.download(:latest)
Expand Down

0 comments on commit 7429633

Please sign in to comment.