Path: blob/trunk/rb/lib/selenium/webdriver/bidi/browser.rb
4102 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.1819module Selenium20module WebDriver21class BiDi22#23# BiDi Implementation of the Browser Module24# Continue to use functionality from existing `driver.manager.window` method25#26# @api private27#2829class Browser30Window = Struct.new(:handle, :active, :height, :width, :x, :y, :state) do31def active?32active33end34end35def initialize(bidi)36@bidi = bidi37end3839def create_user_context40@bidi.send_cmd('browser.createUserContext')41end4243def user_contexts44@bidi.send_cmd('browser.getUserContexts')45end4647def remove_user_context(user_context)48@bidi.send_cmd('browser.removeUserContext', userContext: user_context)49end5051def windows52response = @bidi.send_cmd('browser.getClientWindows')5354response['clientWindows'].map do |win_data|55attributes = {56handle: win_data['clientWindow'],57active: win_data['active'],58height: win_data['height'],59width: win_data['width'],60x: win_data['x'],61y: win_data['y'],62state: win_data['state']63}64Window.new(**attributes)65end66end67end # Browser68end # BiDi69end # WebDriver70end # Selenium717273