Path: blob/trunk/py/selenium/webdriver/remote/fedcm.py
1864 views
# Licensed to the Software Freedom Conservancy (SFC) under one1# or more contributor license agreements. See the NOTICE file2# distributed with this work for additional information3# regarding copyright ownership. The SFC licenses this file4# to you under the Apache License, Version 2.0 (the5# "License"); you may not use this file except in compliance6# with the License. You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing,11# software distributed under the License is distributed on an12# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13# KIND, either express or implied. See the License for the14# specific language governing permissions and limitations15# under the License.1617from typing import Optional1819from .command import Command202122class FedCM:23def __init__(self, driver) -> None:24self._driver = driver2526@property27def title(self) -> str:28"""Gets the title of the dialog."""29return self._driver.execute(Command.GET_FEDCM_TITLE)["value"].get("title")3031@property32def subtitle(self) -> Optional[str]:33"""Gets the subtitle of the dialog."""34return self._driver.execute(Command.GET_FEDCM_TITLE)["value"].get("subtitle")3536@property37def dialog_type(self) -> str:38"""Gets the type of the dialog currently being shown."""39return self._driver.execute(Command.GET_FEDCM_DIALOG_TYPE).get("value")4041@property42def account_list(self) -> list[dict]:43"""Gets the list of accounts shown in the dialog."""44return self._driver.execute(Command.GET_FEDCM_ACCOUNT_LIST).get("value")4546def select_account(self, index: int) -> None:47"""Selects an account from the dialog by index."""48self._driver.execute(Command.SELECT_FEDCM_ACCOUNT, {"accountIndex": index})4950def accept(self) -> None:51"""Clicks the continue button in the dialog."""52self._driver.execute(Command.CLICK_FEDCM_DIALOG_BUTTON, {"dialogButton": "ConfirmIdpLoginContinue"})5354def dismiss(self) -> None:55"""Cancels/dismisses the FedCM dialog."""56self._driver.execute(Command.CANCEL_FEDCM_DIALOG)5758def enable_delay(self) -> None:59"""Re-enables the promise rejection delay for FedCM."""60self._driver.execute(Command.SET_FEDCM_DELAY, {"enabled": True})6162def disable_delay(self) -> None:63"""Disables the promise rejection delay for FedCM."""64self._driver.execute(Command.SET_FEDCM_DELAY, {"enabled": False})6566def reset_cooldown(self) -> None:67"""Resets the FedCM dialog cooldown, allowing immediate retriggers."""68self._driver.execute(Command.RESET_FEDCM_COOLDOWN)697071