Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/spec/unit/selenium/webdriver/common/service_spec.rb
4103 views
1
# frozen_string_literal: true
2
3
# Licensed to the Software Freedom Conservancy (SFC) under one
4
# or more contributor license agreements. See the NOTICE file
5
# distributed with this work for additional information
6
# regarding copyright ownership. The SFC licenses this file
7
# to you under the Apache License, Version 2.0 (the
8
# "License"); you may not use this file except in compliance
9
# with the License. You may obtain a copy of the License at
10
#
11
# http://www.apache.org/licenses/LICENSE-2.0
12
#
13
# Unless required by applicable law or agreed to in writing,
14
# software distributed under the License is distributed on an
15
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
# KIND, either express or implied. See the License for the
17
# specific language governing permissions and limitations
18
# under the License.
19
20
require File.expand_path('../spec_helper', __dir__)
21
22
module Selenium
23
module WebDriver
24
describe Service do
25
let(:service_path) { '/path/to/service' }
26
27
before do
28
allow(Platform).to receive(:assert_executable)
29
allow(WebDriver.logger).to receive(:debug?).and_return(false)
30
stub_const('Selenium::WebDriver::Service::DEFAULT_PORT', 1234)
31
stub_const('Selenium::WebDriver::Service::EXECUTABLE', 'service')
32
end
33
34
describe 'browser shortcuts' do
35
let(:args) { %w[--foo --bar] }
36
37
it 'creates Chrome instance' do
38
service = described_class.chrome(args: args)
39
expect(service).to be_a(Chrome::Service)
40
expect(service.args).to eq args
41
end
42
43
it 'creates Edge instance' do
44
service = described_class.edge(args: args)
45
expect(service).to be_a(Edge::Service)
46
expect(service.args).to eq args
47
end
48
49
it 'creates Firefox instance' do
50
service = described_class.firefox(args: args)
51
expect(service).to be_a(Firefox::Service)
52
expect(service.args).to eq(args + %w[--websocket-port 0])
53
end
54
55
it 'creates IE instance' do
56
service = described_class.internet_explorer(args: args)
57
expect(service).to be_a(IE::Service)
58
expect(service.args).to eq args
59
end
60
61
it 'creates Safari instance' do
62
service = described_class.safari(args: args)
63
expect(service).to be_a(Safari::Service)
64
expect(service.args).to eq args
65
end
66
end
67
end
68
end # WebDriver
69
end # Selenium
70
71