Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/spec/integration/selenium/webdriver/bidi_spec.rb
1864 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
describe BiDi, exclusive: {bidi: true, reason: 'only executed when bidi is enabled'},
25
only: {browser: %i[chrome edge firefox]} do
26
after { |example| reset_driver!(example: example) }
27
28
it 'errors when bidi not enabled' do
29
reset_driver!(web_socket_url: false) do |driver|
30
expect { driver.bidi }.to raise_error(WebDriver::Error::WebDriverError)
31
end
32
end
33
34
it 'gets session status' do
35
status = driver.bidi.session.status
36
expect(status).to respond_to(:ready)
37
expect(status.message).not_to be_empty
38
end
39
40
it 'does not close BiDi session if at least one window is opened' do
41
status = driver.bidi.session.status
42
expect(status.ready).to be false
43
expect(status.message).to be_a String
44
45
driver.switch_to.new_window(:window)
46
driver.switch_to.new_window(:tab)
47
driver.switch_to.new_window(:tab)
48
49
driver.close
50
51
status_after_closing = driver.bidi.session.status
52
expect(status_after_closing.ready).to be false
53
expect(status_after_closing.message).to be_a String
54
end
55
56
it 'closes BiDi session if last window is closed' do
57
status = driver.bidi.session.status
58
expect(status.ready).to be false
59
expect(status.message).to be_a String
60
61
driver.close
62
63
expect { driver.bidi.session.status }.to raise_error(IOError)
64
end
65
end
66
end
67
end
68
69