Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/spec/integration/selenium/webdriver/edge/driver_spec.rb
1865 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 Edge
25
describe Driver, exclusive: [{bidi: false, reason: 'Not yet implemented with BiDi'}, {browser: :edge}] do
26
it 'gets and sets network conditions' do
27
driver.network_conditions = {offline: false, latency: 56, throughput: 789}
28
expect(driver.network_conditions).to eq(
29
'offline' => false,
30
'latency' => 56,
31
'download_throughput' => 789,
32
'upload_throughput' => 789
33
)
34
driver.delete_network_conditions
35
end
36
37
it 'supports default network conditions' do
38
driver.network_conditions = {latency: 56}
39
expect(driver.network_conditions).to eq(
40
'offline' => false,
41
'latency' => 56,
42
'download_throughput' => -1,
43
'upload_throughput' => -1
44
)
45
driver.delete_network_conditions
46
47
# Need to reset because https://bugs.chromium.org/p/chromedriver/issues/detail?id=4790
48
reset_driver!
49
end
50
51
it 'sets download path' do
52
expect { driver.download_path = File.expand_path(__dir__) }.not_to raise_exception
53
end
54
55
it 'can execute CDP commands' do
56
res = driver.execute_cdp('Page.addScriptToEvaluateOnNewDocument', source: 'window.was_here="TW";')
57
expect(res).to have_key('identifier')
58
59
begin
60
driver.navigate.to url_for('formPage.html')
61
62
tw = driver.execute_script('return window.was_here')
63
expect(tw).to eq('TW')
64
ensure
65
driver.execute_cdp('Page.removeScriptToEvaluateOnNewDocument', identifier: res['identifier'])
66
end
67
end
68
69
describe '#logs' do
70
before do
71
reset_driver!(logging_prefs: {browser: 'ALL',
72
driver: 'ALL',
73
performance: 'ALL'})
74
driver.navigate.to url_for('errors.html')
75
end
76
77
after(:all) { reset_driver! }
78
79
it 'can fetch available log types' do
80
expect(driver.logs.available_types).to include(:performance, :browser, :driver)
81
end
82
83
it 'can get the browser log' do
84
driver.find_element(tag_name: 'input').click
85
86
entries = driver.logs.get(:browser)
87
expect(entries).not_to be_empty
88
expect(entries.first).to be_a(LogEntry)
89
end
90
91
it 'can get the driver log' do
92
entries = driver.logs.get(:driver)
93
expect(entries).not_to be_empty
94
expect(entries.first).to be_a(LogEntry)
95
end
96
97
it 'can get the performance log' do
98
entries = driver.logs.get(:performance)
99
expect(entries).not_to be_empty
100
expect(entries.first).to be_a(LogEntry)
101
end
102
end
103
104
# This requires cast sinks to run
105
it 'casts' do
106
# Does not get list correctly the first time for some reason
107
driver.cast_sinks
108
sleep 2
109
sinks = driver.cast_sinks
110
unless sinks.empty?
111
device_name = sinks.first['name']
112
driver.start_cast_tab_mirroring(device_name)
113
expect { driver.stop_casting(device_name) }.not_to raise_exception
114
end
115
end
116
end
117
end # Edge
118
end # WebDriver
119
end # Selenium
120
121