Path: blob/trunk/py/selenium/webdriver/common/fedcm/dialog.py
4062 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.common.fedcm.account import Account192021class Dialog:22"""Represents a FedCM dialog that can be interacted with."""2324DIALOG_TYPE_ACCOUNT_LIST = "AccountChooser"25DIALOG_TYPE_AUTO_REAUTH = "AutoReauthn"2627def __init__(self, driver) -> None:28self._driver = driver2930@property31def type(self) -> str | None:32"""Gets the type of the dialog currently being shown."""33return self._driver.fedcm.dialog_type3435@property36def title(self) -> str:37"""Gets the title of the dialog."""38return self._driver.fedcm.title3940@property41def subtitle(self) -> str | None:42"""Gets the subtitle of the dialog."""43result = self._driver.fedcm.subtitle44return result.get("subtitle") if result else None4546def get_accounts(self) -> list[Account]:47"""Gets the list of accounts shown in the dialog."""48accounts = self._driver.fedcm.account_list49return [Account(account) for account in accounts]5051def select_account(self, index: int) -> None:52"""Selects an account from the dialog by index."""53self._driver.fedcm.select_account(index)5455def accept(self) -> None:56"""Clicks the continue button in the dialog."""57self._driver.fedcm.accept()5859def dismiss(self) -> None:60"""Cancels/dismisses the dialog."""61self._driver.fedcm.dismiss()626364