Path: blob/trunk/py/selenium/webdriver/remote/fedcm.py
3985 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.161718from selenium.webdriver.remote.command import Command192021class FedCM:22def __init__(self, driver) -> None:23self._driver = driver2425@property26def title(self) -> str:27"""Gets the title of the dialog."""28return self._driver.execute(Command.GET_FEDCM_TITLE)["value"].get("title")2930@property31def subtitle(self) -> str | None:32"""Gets the subtitle of the dialog."""33return self._driver.execute(Command.GET_FEDCM_TITLE)["value"].get("subtitle")3435@property36def dialog_type(self) -> str:37"""Gets the type of the dialog currently being shown."""38return self._driver.execute(Command.GET_FEDCM_DIALOG_TYPE).get("value")3940@property41def account_list(self) -> list[dict]:42"""Gets the list of accounts shown in the dialog."""43return self._driver.execute(Command.GET_FEDCM_ACCOUNT_LIST).get("value")4445def select_account(self, index: int) -> None:46"""Selects an account from the dialog by index."""47self._driver.execute(Command.SELECT_FEDCM_ACCOUNT, {"accountIndex": index})4849def accept(self) -> None:50"""Clicks the continue button in the dialog."""51self._driver.execute(Command.CLICK_FEDCM_DIALOG_BUTTON, {"dialogButton": "ConfirmIdpLoginContinue"})5253def dismiss(self) -> None:54"""Cancels/dismisses the FedCM dialog."""55self._driver.execute(Command.CANCEL_FEDCM_DIALOG)5657def enable_delay(self) -> None:58"""Re-enables the promise rejection delay for FedCM."""59self._driver.execute(Command.SET_FEDCM_DELAY, {"enabled": True})6061def disable_delay(self) -> None:62"""Disables the promise rejection delay for FedCM."""63self._driver.execute(Command.SET_FEDCM_DELAY, {"enabled": False})6465def reset_cooldown(self) -> None:66"""Resets the FedCM dialog cooldown, allowing immediate retriggers."""67self._driver.execute(Command.RESET_FEDCM_COOLDOWN)686970