Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/lib/selenium/webdriver/common/fedcm/dialog.rb
1990 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
module Selenium
21
module WebDriver
22
module FedCM
23
class Dialog
24
def initialize(bridge)
25
@bridge = bridge
26
end
27
28
DIALOG_TYPE_ACCOUNT_LIST = 'AccountChooser'
29
DIALOG_TYPE_AUTO_REAUTH = 'AutoReauthn'
30
31
# Closes the dialog as if the user had clicked X.
32
def click
33
@bridge.click_fedcm_dialog_button
34
end
35
36
# Closes the dialog as if the user had clicked X.
37
def cancel
38
@bridge.cancel_fedcm_dialog
39
end
40
41
# Selects an account as if the user had clicked on it.
42
#
43
# @param [Integer] index The index of the account to select from the list returned by get_accounts.
44
def select_account(index)
45
@bridge.select_fedcm_account index
46
end
47
48
# Returns the type of the open dialog.
49
#
50
# One of DIALOG_TYPE_ACCOUNT_LIST and DIALOG_TYPE_AUTO_REAUTH.
51
def type
52
@bridge.fedcm_dialog_type
53
end
54
55
# Returns the title of the dialog.
56
def title
57
@bridge.fedcm_title
58
end
59
60
# Returns the subtitle of the dialog or nil if none.
61
def subtitle
62
@bridge.fedcm_subtitle
63
end
64
65
# Returns the accounts shown in the account chooser.
66
#
67
# If this is an auto reauth dialog, returns the single account that is being signed in.
68
def accounts
69
@bridge.fedcm_account_list.map { |account| Account.new(**account) }
70
end
71
end # Dialog
72
end # FedCM
73
end # WebDriver
74
end # Selenium
75
76