Path: blob/trunk/rb/lib/selenium/webdriver/common/fedcm/dialog.rb
1990 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 WebDriver21module FedCM22class Dialog23def initialize(bridge)24@bridge = bridge25end2627DIALOG_TYPE_ACCOUNT_LIST = 'AccountChooser'28DIALOG_TYPE_AUTO_REAUTH = 'AutoReauthn'2930# Closes the dialog as if the user had clicked X.31def click32@bridge.click_fedcm_dialog_button33end3435# Closes the dialog as if the user had clicked X.36def cancel37@bridge.cancel_fedcm_dialog38end3940# Selects an account as if the user had clicked on it.41#42# @param [Integer] index The index of the account to select from the list returned by get_accounts.43def select_account(index)44@bridge.select_fedcm_account index45end4647# Returns the type of the open dialog.48#49# One of DIALOG_TYPE_ACCOUNT_LIST and DIALOG_TYPE_AUTO_REAUTH.50def type51@bridge.fedcm_dialog_type52end5354# Returns the title of the dialog.55def title56@bridge.fedcm_title57end5859# Returns the subtitle of the dialog or nil if none.60def subtitle61@bridge.fedcm_subtitle62end6364# Returns the accounts shown in the account chooser.65#66# If this is an auto reauth dialog, returns the single account that is being signed in.67def accounts68@bridge.fedcm_account_list.map { |account| Account.new(**account) }69end70end # Dialog71end # FedCM72end # WebDriver73end # Selenium747576