Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/selenium/webdriver/common/fedcm/dialog.py
4062 views
1
# Licensed to the Software Freedom Conservancy (SFC) under one
2
# or more contributor license agreements. See the NOTICE file
3
# distributed with this work for additional information
4
# regarding copyright ownership. The SFC licenses this file
5
# to you under the Apache License, Version 2.0 (the
6
# "License"); you may not use this file except in compliance
7
# with the License. You may obtain a copy of the License at
8
#
9
# http://www.apache.org/licenses/LICENSE-2.0
10
#
11
# Unless required by applicable law or agreed to in writing,
12
# software distributed under the License is distributed on an
13
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
# KIND, either express or implied. See the License for the
15
# specific language governing permissions and limitations
16
# under the License.
17
18
19
from selenium.webdriver.common.fedcm.account import Account
20
21
22
class Dialog:
23
"""Represents a FedCM dialog that can be interacted with."""
24
25
DIALOG_TYPE_ACCOUNT_LIST = "AccountChooser"
26
DIALOG_TYPE_AUTO_REAUTH = "AutoReauthn"
27
28
def __init__(self, driver) -> None:
29
self._driver = driver
30
31
@property
32
def type(self) -> str | None:
33
"""Gets the type of the dialog currently being shown."""
34
return self._driver.fedcm.dialog_type
35
36
@property
37
def title(self) -> str:
38
"""Gets the title of the dialog."""
39
return self._driver.fedcm.title
40
41
@property
42
def subtitle(self) -> str | None:
43
"""Gets the subtitle of the dialog."""
44
result = self._driver.fedcm.subtitle
45
return result.get("subtitle") if result else None
46
47
def get_accounts(self) -> list[Account]:
48
"""Gets the list of accounts shown in the dialog."""
49
accounts = self._driver.fedcm.account_list
50
return [Account(account) for account in accounts]
51
52
def select_account(self, index: int) -> None:
53
"""Selects an account from the dialog by index."""
54
self._driver.fedcm.select_account(index)
55
56
def accept(self) -> None:
57
"""Clicks the continue button in the dialog."""
58
self._driver.fedcm.accept()
59
60
def dismiss(self) -> None:
61
"""Cancels/dismisses the dialog."""
62
self._driver.fedcm.dismiss()
63
64