Path: blob/trunk/py/test/selenium/webdriver/common/fedcm_tests.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.1617import pytest1819from selenium.common.exceptions import NoAlertPresentException202122@pytest.mark.xfail_safari(reason="FedCM not supported")23@pytest.mark.xfail_firefox(reason="FedCM not supported")24@pytest.mark.xfail_ie(reason="FedCM not supported")25@pytest.mark.xfail_remote(reason="FedCM not supported, since remote uses Firefox")26class TestFedCM:27@pytest.fixture(autouse=True)28def setup(self, driver, webserver):29driver.get(webserver.where_is("fedcm/fedcm.html", localhost=True))30self.dialog = driver.dialog3132def test_no_dialog_title(driver):33with pytest.raises(NoAlertPresentException):34driver.dialog.title3536def test_no_dialog_subtitle(driver):37with pytest.raises(NoAlertPresentException):38driver.dialog.subtitle3940def test_no_dialog_type(driver):41with pytest.raises(NoAlertPresentException):42driver.dialog.type4344def test_no_dialog_get_accounts(driver):45with pytest.raises(NoAlertPresentException):46driver.dialog.get_accounts()4748def test_no_dialog_select_account(driver):49with pytest.raises(NoAlertPresentException):50driver.dialog.select_account(1)5152def test_no_dialog_cancel(driver):53with pytest.raises(NoAlertPresentException):54driver.dialog.dismiss()5556def test_no_dialog_click_continue(driver):57with pytest.raises(NoAlertPresentException):58driver.dialog.accept()5960def test_trigger_and_verify_dialog_title(self, driver):61driver.execute_script("triggerFedCm();")62dialog = driver.fedcm_dialog()63assert dialog.title == "Sign in to localhost with localhost"64dialog.dismiss()6566def test_trigger_and_verify_dialog_subtitle(self, driver):67driver.execute_script("triggerFedCm();")68dialog = driver.fedcm_dialog()69assert dialog.subtitle is None70dialog.dismiss()7172def test_trigger_and_verify_dialog_type(self, driver):73driver.execute_script("triggerFedCm();")74dialog = driver.fedcm_dialog()75assert dialog.type == "AccountChooser"76dialog.dismiss()7778def test_trigger_and_verify_account_list(self, driver):79driver.execute_script("triggerFedCm();")80dialog = driver.fedcm_dialog()81accounts = dialog.get_accounts()82assert len(accounts) > 083assert accounts[0].name == "John Doe"84dialog.dismiss()8586def test_select_account(self, driver):87driver.execute_script("triggerFedCm();")88dialog = driver.fedcm_dialog()89dialog.select_account(1)90driver.fedcm_dialog() # Wait for dialog to become interactable91# dialog.click_continue()92dialog.dismiss()9394def test_dialog_cancel(self, driver):95driver.execute_script("triggerFedCm();")96dialog = driver.fedcm_dialog()97dialog.dismiss()98with pytest.raises(NoAlertPresentException):99dialog.title100101def test_enable_fedcm_delay(self, driver):102driver.fedcm.enable_delay()103104def test_disable_fedcm_delay(self, driver):105driver.fedcm.disable_delay()106107def test_fedcm_cooldown_reset(self, driver):108driver.fedcm.reset_cooldown()109110def test_fedcm_no_dialog_type_present(self, driver):111with pytest.raises(NoAlertPresentException):112driver.fedcm.dialog_type113114def test_fedcm_no_title_present(self, driver):115with pytest.raises(NoAlertPresentException):116driver.fedcm.title117118def test_fedcm_no_subtitle_present(self, driver):119with pytest.raises(NoAlertPresentException):120driver.fedcm.subtitle121122def test_fedcm_no_account_list_present(self, driver):123with pytest.raises(NoAlertPresentException):124driver.fedcm.account_list()125126def test_fedcm_no_select_account_present(self, driver):127with pytest.raises(NoAlertPresentException):128driver.fedcm.select_account(1)129130def test_fedcm_no_cancel_dialog_present(self, driver):131with pytest.raises(NoAlertPresentException):132driver.fedcm.dismiss()133134def test_fedcm_no_click_continue_present(self, driver):135with pytest.raises(NoAlertPresentException):136driver.fedcm.accept()137138def test_verify_dialog_type_after_cooldown_reset(self, driver):139driver.fedcm.reset_cooldown()140driver.execute_script("triggerFedCm();")141dialog = driver.fedcm_dialog()142assert dialog.type == "AccountChooser"143dialog.dismiss()144145146