Path: blob/trunk/py/selenium/webdriver/common/fedcm/dialog.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 .account import Account202122class Dialog:23"""Represents a FedCM dialog that can be interacted with."""2425DIALOG_TYPE_ACCOUNT_LIST = "AccountChooser"26DIALOG_TYPE_AUTO_REAUTH = "AutoReauthn"2728def __init__(self, driver) -> None:29self._driver = driver3031@property32def type(self) -> Optional[str]:33"""Gets the type of the dialog currently being shown."""34return self._driver.fedcm.dialog_type3536@property37def title(self) -> str:38"""Gets the title of the dialog."""39return self._driver.fedcm.title4041@property42def subtitle(self) -> Optional[str]:43"""Gets the subtitle of the dialog."""44result = self._driver.fedcm.subtitle45return result.get("subtitle") if result else None4647def get_accounts(self) -> list[Account]:48"""Gets the list of accounts shown in the dialog."""49accounts = self._driver.fedcm.account_list50return [Account(account) for account in accounts]5152def select_account(self, index: int) -> None:53"""Selects an account from the dialog by index."""54self._driver.fedcm.select_account(index)5556def accept(self) -> None:57"""Clicks the continue button in the dialog."""58self._driver.fedcm.accept()5960def dismiss(self) -> None:61"""Cancels/dismisses the dialog."""62self._driver.fedcm.dismiss()636465