Skip to content

Commit

Permalink
rb: Share method to communicate to running service
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed May 31, 2016
1 parent a60cd4d commit 5c63343
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 24 deletions.
7 changes: 1 addition & 6 deletions rb/lib/selenium/webdriver/chrome/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ def start_process
end

def stop_server
Net::HTTP.start(@host, @port) do |http|
http.open_timeout = STOP_TIMEOUT / 2
http.read_timeout = STOP_TIMEOUT / 2

http.get("/shutdown")
end
connect_to_server { |http| http.get("/shutdown") }
end

def connect_until_stable
Expand Down
9 changes: 9 additions & 0 deletions rb/lib/selenium/webdriver/common/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ def uri

private

def connect_to_server
Net::HTTP.start(@host, @port) do |http|
http.open_timeout = STOP_TIMEOUT / 2
http.read_timeout = STOP_TIMEOUT / 2

yield http
end
end

def find_free_port
@port = PortProber.above(@port)
end
Expand Down
7 changes: 1 addition & 6 deletions rb/lib/selenium/webdriver/edge/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@ def self.default_service(*extra_args)
private

def stop_server
Net::HTTP.start(@host, @port) do |http|
http.open_timeout = STOP_TIMEOUT / 2
http.read_timeout = STOP_TIMEOUT / 2

http.head("/shutdown")
end
connect_to_server { |http| http.head("/shutdown") }
end

def start_process
Expand Down
7 changes: 1 addition & 6 deletions rb/lib/selenium/webdriver/firefox/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,7 @@ def stop_process
end

def stop_server
Net::HTTP.start(@host, @port) do |http|
http.open_timeout = STOP_TIMEOUT / 2
http.read_timeout = STOP_TIMEOUT / 2

http.head("/shutdown")
end
connect_to_server { |http| http.head("/shutdown") }
end

def connect_until_stable
Expand Down
7 changes: 1 addition & 6 deletions rb/lib/selenium/webdriver/phantomjs/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,7 @@ def stop_process
end

def stop_server
Net::HTTP.start(@host, @port) do |http|
http.open_timeout = STOP_TIMEOUT / 2
http.read_timeout = STOP_TIMEOUT / 2

http.get("/shutdown")
end
connect_to_server { |http| http.get("/shutdown") }
end

def connect_until_stable
Expand Down

0 comments on commit 5c63343

Please sign in to comment.