MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / Selenium

Class Selenium

rb/spec/integration/selenium/server_spec.rb:23–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21require 'selenium/server'
22
23module Selenium
24 describe Server do
25 after do
26 File.delete(@location) if @location && File.exist?(@location)
27 end
28
29 it 'downloads latest version' do
30 @location = described_class.download
31
32 expect(File.exist?(@location)).to be true
33 expect(@location).to eq("selenium-server-#{current_version}.jar")
34 end
35
36 it 'downloads specified version' do
37 @location = described_class.download('4.9.0')
38
39 expect(File.exist?(@location)).to be true
40 expect(@location).to eq('selenium-server-4.9.0.jar')
41 end
42
43 it 'starts and stops server' do
44 @location = described_class.download
45 @server = described_class.new(@location, background: true)
46 @server.start
47 status = server_status("http://#{@server.host}:#{@server.port}")
48 expect(status.code).to eq 200
49
50 @server.stop
51 expect {
52 server_status("http://#{@server.host}:#{@server.port}")
53 }.to raise_error(Errno::ECONNREFUSED)
54 ensure
55 @server&.stop
56 end
57
58 def server_status(url)
59 client = WebDriver::Remote::Http::Default.new
60 client.server_url = URI.parse(url)
61 client.send(:request, :get, URI.parse("#{url}/status"), {}, nil)
62 end
63
64 # Ruby Selenium is tagged one version ahead of release to support nightly gem
65 def current_version
66 selenium_version = Gem::Version.new(Selenium::WebDriver::VERSION).segments
67 selenium_version[1] = selenium_version[1] - 1
68 selenium_version.join('.')
69 end
70 end
71end

Callers

nothing calls this directly

Calls 9

beFunction · 0.85
downloadMethod · 0.80
codeMethod · 0.80
toMethod · 0.65
startMethod · 0.65
stopMethod · 0.65
deleteMethod · 0.45
newMethod · 0.45
portMethod · 0.45

Tested by

no test coverage detected