Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/selenium/webdriver/remote/fedcm.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 .command import Command
21
22
23
class FedCM:
24
def __init__(self, driver) -> None:
25
self._driver = driver
26
27
@property
28
def title(self) -> str:
29
"""Gets the title of the dialog."""
30
return self._driver.execute(Command.GET_FEDCM_TITLE)["value"].get("title")
31
32
@property
33
def subtitle(self) -> Optional[str]:
34
"""Gets the subtitle of the dialog."""
35
return self._driver.execute(Command.GET_FEDCM_TITLE)["value"].get("subtitle")
36
37
@property
38
def dialog_type(self) -> str:
39
"""Gets the type of the dialog currently being shown."""
40
return self._driver.execute(Command.GET_FEDCM_DIALOG_TYPE).get("value")
41
42
@property
43
def account_list(self) -> list[dict]:
44
"""Gets the list of accounts shown in the dialog."""
45
return self._driver.execute(Command.GET_FEDCM_ACCOUNT_LIST).get("value")
46
47
def select_account(self, index: int) -> None:
48
"""Selects an account from the dialog by index."""
49
self._driver.execute(Command.SELECT_FEDCM_ACCOUNT, {"accountIndex": index})
50
51
def accept(self) -> None:
52
"""Clicks the continue button in the dialog."""
53
self._driver.execute(Command.CLICK_FEDCM_DIALOG_BUTTON, {"dialogButton": "ConfirmIdpLoginContinue"})
54
55
def dismiss(self) -> None:
56
"""Cancels/dismisses the FedCM dialog."""
57
self._driver.execute(Command.CANCEL_FEDCM_DIALOG)
58
59
def enable_delay(self) -> None:
60
"""Re-enables the promise rejection delay for FedCM."""
61
self._driver.execute(Command.SET_FEDCM_DELAY, {"enabled": True})
62
63
def disable_delay(self) -> None:
64
"""Disables the promise rejection delay for FedCM."""
65
self._driver.execute(Command.SET_FEDCM_DELAY, {"enabled": False})
66
67
def reset_cooldown(self) -> None:
68
"""Resets the FedCM dialog cooldown, allowing immediate retriggers."""
69
self._driver.execute(Command.RESET_FEDCM_COOLDOWN)
70
71