Path: blob/trunk/rb/spec/integration/selenium/webdriver/bidi_spec.rb
1864 views
# frozen_string_literal: true12# Licensed to the Software Freedom Conservancy (SFC) under one3# or more contributor license agreements. See the NOTICE file4# distributed with this work for additional information5# regarding copyright ownership. The SFC licenses this file6# to you under the Apache License, Version 2.0 (the7# "License"); you may not use this file except in compliance8# with the License. You may obtain a copy of the License at9#10# http://www.apache.org/licenses/LICENSE-2.011#12# Unless required by applicable law or agreed to in writing,13# software distributed under the License is distributed on an14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15# KIND, either express or implied. See the License for the16# specific language governing permissions and limitations17# under the License.1819require_relative 'spec_helper'2021module Selenium22module WebDriver23describe BiDi, exclusive: {bidi: true, reason: 'only executed when bidi is enabled'},24only: {browser: %i[chrome edge firefox]} do25after { |example| reset_driver!(example: example) }2627it 'errors when bidi not enabled' do28reset_driver!(web_socket_url: false) do |driver|29expect { driver.bidi }.to raise_error(WebDriver::Error::WebDriverError)30end31end3233it 'gets session status' do34status = driver.bidi.session.status35expect(status).to respond_to(:ready)36expect(status.message).not_to be_empty37end3839it 'does not close BiDi session if at least one window is opened' do40status = driver.bidi.session.status41expect(status.ready).to be false42expect(status.message).to be_a String4344driver.switch_to.new_window(:window)45driver.switch_to.new_window(:tab)46driver.switch_to.new_window(:tab)4748driver.close4950status_after_closing = driver.bidi.session.status51expect(status_after_closing.ready).to be false52expect(status_after_closing.message).to be_a String53end5455it 'closes BiDi session if last window is closed' do56status = driver.bidi.session.status57expect(status.ready).to be false58expect(status.message).to be_a String5960driver.close6162expect { driver.bidi.session.status }.to raise_error(IOError)63end64end65end66end676869