Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/test/selenium/webdriver/common/fedcm_tests.py
1865 views
1
# Licensed to the Software Freedom Conservancy (SFC) under one
2
# or more contributor license agreements. See the NOTICE file
3
# distributed with this work for additional information
4
# regarding copyright ownership. The SFC licenses this file
5
# to you under the Apache License, Version 2.0 (the
6
# "License"); you may not use this file except in compliance
7
# with the License. You may obtain a copy of the License at
8
#
9
# http://www.apache.org/licenses/LICENSE-2.0
10
#
11
# Unless required by applicable law or agreed to in writing,
12
# software distributed under the License is distributed on an
13
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
# KIND, either express or implied. See the License for the
15
# specific language governing permissions and limitations
16
# under the License.
17
18
import pytest
19
20
from selenium.common.exceptions import NoAlertPresentException
21
22
23
@pytest.mark.xfail_safari(reason="FedCM not supported")
24
@pytest.mark.xfail_chrome(reason="https://issues.chromium.org/u/0/issues/425801332")
25
@pytest.mark.xfail_firefox(reason="FedCM not supported")
26
@pytest.mark.xfail_ie(reason="FedCM not supported")
27
@pytest.mark.xfail_remote(reason="FedCM not supported, since remote uses Firefox")
28
class TestFedCM:
29
@pytest.fixture(autouse=True)
30
def setup(self, driver, webserver):
31
driver.get(webserver.where_is("fedcm/fedcm.html", localhost=True))
32
self.dialog = driver.dialog
33
34
def test_no_dialog_title(driver):
35
with pytest.raises(NoAlertPresentException):
36
driver.dialog.title
37
38
def test_no_dialog_subtitle(driver):
39
with pytest.raises(NoAlertPresentException):
40
driver.dialog.subtitle
41
42
def test_no_dialog_type(driver):
43
with pytest.raises(NoAlertPresentException):
44
driver.dialog.type
45
46
def test_no_dialog_get_accounts(driver):
47
with pytest.raises(NoAlertPresentException):
48
driver.dialog.get_accounts()
49
50
def test_no_dialog_select_account(driver):
51
with pytest.raises(NoAlertPresentException):
52
driver.dialog.select_account(1)
53
54
def test_no_dialog_cancel(driver):
55
with pytest.raises(NoAlertPresentException):
56
driver.dialog.dismiss()
57
58
def test_no_dialog_click_continue(driver):
59
with pytest.raises(NoAlertPresentException):
60
driver.dialog.accept()
61
62
def test_trigger_and_verify_dialog_title(self, driver):
63
driver.execute_script("triggerFedCm();")
64
dialog = driver.fedcm_dialog()
65
assert dialog.title == "Sign in to localhost with localhost"
66
dialog.dismiss()
67
68
def test_trigger_and_verify_dialog_subtitle(self, driver):
69
driver.execute_script("triggerFedCm();")
70
dialog = driver.fedcm_dialog()
71
assert dialog.subtitle is None
72
dialog.dismiss()
73
74
def test_trigger_and_verify_dialog_type(self, driver):
75
driver.execute_script("triggerFedCm();")
76
dialog = driver.fedcm_dialog()
77
assert dialog.type == "AccountChooser"
78
dialog.dismiss()
79
80
def test_trigger_and_verify_account_list(self, driver):
81
driver.execute_script("triggerFedCm();")
82
dialog = driver.fedcm_dialog()
83
accounts = dialog.get_accounts()
84
assert len(accounts) > 0
85
assert accounts[0].name == "John Doe"
86
dialog.dismiss()
87
88
def test_select_account(self, driver):
89
driver.execute_script("triggerFedCm();")
90
dialog = driver.fedcm_dialog()
91
dialog.select_account(1)
92
driver.fedcm_dialog() # Wait for dialog to become interactable
93
# dialog.click_continue()
94
dialog.dismiss()
95
96
def test_dialog_cancel(self, driver):
97
driver.execute_script("triggerFedCm();")
98
dialog = driver.fedcm_dialog()
99
dialog.dismiss()
100
with pytest.raises(NoAlertPresentException):
101
dialog.title
102
103
def test_enable_fedcm_delay(self, driver):
104
driver.fedcm.enable_delay()
105
106
def test_disable_fedcm_delay(self, driver):
107
driver.fedcm.disable_delay()
108
109
def test_fedcm_cooldown_reset(self, driver):
110
driver.fedcm.reset_cooldown()
111
112
def test_fedcm_no_dialog_type_present(self, driver):
113
with pytest.raises(NoAlertPresentException):
114
driver.fedcm.dialog_type
115
116
def test_fedcm_no_title_present(self, driver):
117
with pytest.raises(NoAlertPresentException):
118
driver.fedcm.title
119
120
def test_fedcm_no_subtitle_present(self, driver):
121
with pytest.raises(NoAlertPresentException):
122
driver.fedcm.subtitle
123
124
def test_fedcm_no_account_list_present(self, driver):
125
with pytest.raises(NoAlertPresentException):
126
driver.fedcm.account_list()
127
128
def test_fedcm_no_select_account_present(self, driver):
129
with pytest.raises(NoAlertPresentException):
130
driver.fedcm.select_account(1)
131
132
def test_fedcm_no_cancel_dialog_present(self, driver):
133
with pytest.raises(NoAlertPresentException):
134
driver.fedcm.dismiss()
135
136
def test_fedcm_no_click_continue_present(self, driver):
137
with pytest.raises(NoAlertPresentException):
138
driver.fedcm.accept()
139
140
def test_verify_dialog_type_after_cooldown_reset(self, driver):
141
driver.fedcm.reset_cooldown()
142
driver.execute_script("triggerFedCm();")
143
dialog = driver.fedcm_dialog()
144
assert dialog.type == "AccountChooser"
145
dialog.dismiss()
146
147