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

Class Selenium

rb/spec/integration/selenium/server_spec.rb:25–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23require_relative 'webdriver/spec_support/test_environment'
24
25module Selenium
26 describe Server do
27 let!(:environment) { WebDriver::SpecSupport::TestEnvironment.new }
28
29 before(:all) { ENV['SE_CACHE_PATH'] = Dir.mktmpdir('selenium-server') }
30
31 after(:all) { FileUtils.rm_rf(ENV.delete('SE_CACHE_PATH')) }
32
33 after do
34 File.delete(@location) if @location && File.exist?(@location)
35 end
36
37 it 'downloads latest version' do
38 @location = described_class.download
39
40 expect(File.exist?(@location)).to be true
41 expect(@location).to match(/\Aselenium-server-\d+\.\d+\.\d+\.jar\z/)
42 end
43
44 it 'reports the latest version' do
45 version = described_class.latest
46 @location = "selenium-server-#{version}.jar"
47
48 expect(version).to match(/\A\d+\.\d+\.\d+\z/)
49 expect(File.exist?(@location)).to be true
50 end
51
52 it 'downloads specified version' do
53 @location = described_class.download('4.9.0')
54
55 expect(File.exist?(@location)).to be true
56 expect(@location).to eq('selenium-server-4.9.0.jar')
57 expect(Dir.exist?(File.join(ENV.fetch('SE_CACHE_PATH'), 'grid', '4.9.0'))).to be true
58 end
59
60 it 'raises Selenium::Server::Error for a version that does not exist' do
61 Dir.mktmpdir('selenium-server-empty') do |empty_cache|
62 cache = ENV.fetch('SE_CACHE_PATH')
63 ENV['SE_CACHE_PATH'] = empty_cache
64
65 expect { described_class.download('99.99.99') }.to raise_error(described_class::Error, /99\.99\.99/)
66 ensure
67 ENV['SE_CACHE_PATH'] = cache
68 end
69 end
70
71 it 'starts and stops server' do
72 @location = described_class.download
73 chrome_slot = ['--driver-configuration', 'display-name=chrome', 'stereotype={"browserName":"chrome"}']
74 args = ['--detect-drivers', 'false', *chrome_slot]
75 @server = described_class.new(@location, background: true, java: environment.bazel_java, args: args)
76 @server.start
77 status = server_status("http://#{@server.host}:#{@server.port}")
78 expect(status.code).to eq 200
79
80 @server.stop
81 expect {
82 server_status("http://#{@server.host}:#{@server.port}")

Callers

nothing calls this directly

Calls 12

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

Tested by

no test coverage detected