Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/spec/integration/selenium/webdriver/chrome/options_spec.rb
4064 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_relative '../spec_helper'
21
22
module Selenium
23
module WebDriver
24
module Chrome
25
describe Options, exclusive: {browser: :chrome} do
26
it 'passes emulated device correctly' do
27
reset_driver!(emulation: {device_name: 'Nexus 5'}) do |driver|
28
ua = driver.execute_script 'return window.navigator.userAgent'
29
expect(ua).to include('Nexus 5')
30
end
31
end
32
33
it 'passes emulated user agent correctly' do
34
reset_driver!(emulation: {user_agent: 'foo;bar'}) do |driver|
35
ua = driver.execute_script 'return window.navigator.userAgent'
36
expect(ua).to eq('foo;bar')
37
end
38
end
39
40
it 'passes args correctly' do
41
reset_driver!(args: ['--user-agent=foo;bar']) do |driver|
42
ua = driver.execute_script 'return window.navigator.userAgent'
43
expect(ua).to eq('foo;bar')
44
end
45
end
46
47
it 'enables bidi', exclusive: {bidi: true, reason: 'bazel does not have dependencies otherwise'} do
48
quit_driver
49
50
options = Selenium::WebDriver::Options.chrome
51
expect(options.web_socket_url).to be_nil
52
expect(options.bidi?).to be false
53
54
options.enable_bidi!
55
expect(options.web_socket_url).to be true
56
expect(options.bidi?).to be true
57
58
driver = Selenium::WebDriver.for :chrome, options: options
59
60
expect(driver.capabilities.web_socket_url).to be_a String
61
62
driver.quit
63
end
64
65
it 'enables BiDi on initialization',
66
exclusive: {bidi: true, reason: 'bazel does not have dependencies otherwise'} do
67
quit_driver
68
69
options = Selenium::WebDriver::Options.chrome(bidi: true)
70
expect(options.web_socket_url).to be true
71
expect(options.bidi?).to be true
72
73
driver = Selenium::WebDriver.for :chrome, options: options
74
75
expect(driver.capabilities.web_socket_url).to be_a String
76
77
driver.quit
78
end
79
end
80
end # Chrome
81
end # WebDriver
82
end # Selenium
83
84