Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/selenium/webdriver/common/fedcm/dialog.py
1864 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
from typing import Optional
19
20
from .account import Account
21
22
23
class Dialog:
24
"""Represents a FedCM dialog that can be interacted with."""
25
26
DIALOG_TYPE_ACCOUNT_LIST = "AccountChooser"
27
DIALOG_TYPE_AUTO_REAUTH = "AutoReauthn"
28
29
def __init__(self, driver) -> None:
30
self._driver = driver
31
32
@property
33
def type(self) -> Optional[str]:
34
"""Gets the type of the dialog currently being shown."""
35
return self._driver.fedcm.dialog_type
36
37
@property
38
def title(self) -> str:
39
"""Gets the title of the dialog."""
40
return self._driver.fedcm.title
41
42
@property
43
def subtitle(self) -> Optional[str]:
44
"""Gets the subtitle of the dialog."""
45
result = self._driver.fedcm.subtitle
46
return result.get("subtitle") if result else None
47
48
def get_accounts(self) -> list[Account]:
49
"""Gets the list of accounts shown in the dialog."""
50
accounts = self._driver.fedcm.account_list
51
return [Account(account) for account in accounts]
52
53
def select_account(self, index: int) -> None:
54
"""Selects an account from the dialog by index."""
55
self._driver.fedcm.select_account(index)
56
57
def accept(self) -> None:
58
"""Clicks the continue button in the dialog."""
59
self._driver.fedcm.accept()
60
61
def dismiss(self) -> None:
62
"""Cancels/dismisses the dialog."""
63
self._driver.fedcm.dismiss()
64
65