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
4062 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_firefox(reason="FedCM not supported")
25
@pytest.mark.xfail_ie(reason="FedCM not supported")
26
@pytest.mark.xfail_remote(reason="FedCM not supported, since remote uses Firefox")
27
class TestFedCM:
28
@pytest.fixture(autouse=True)
29
def setup(self, driver, webserver):
30
driver.get(webserver.where_is("fedcm/fedcm.html", localhost=True))
31
self.dialog = driver.dialog
32
33
def test_no_dialog_title(driver):
34
with pytest.raises(NoAlertPresentException):
35
driver.dialog.title
36
37
def test_no_dialog_subtitle(driver):
38
with pytest.raises(NoAlertPresentException):
39
driver.dialog.subtitle
40
41
def test_no_dialog_type(driver):
42
with pytest.raises(NoAlertPresentException):
43
driver.dialog.type
44
45
def test_no_dialog_get_accounts(driver):
46
with pytest.raises(NoAlertPresentException):
47
driver.dialog.get_accounts()
48
49
def test_no_dialog_select_account(driver):
50
with pytest.raises(NoAlertPresentException):
51
driver.dialog.select_account(1)
52
53
def test_no_dialog_cancel(driver):
54
with pytest.raises(NoAlertPresentException):
55
driver.dialog.dismiss()
56
57
def test_no_dialog_click_continue(driver):
58
with pytest.raises(NoAlertPresentException):
59
driver.dialog.accept()
60
61
def test_trigger_and_verify_dialog_title(self, driver):
62
driver.execute_script("triggerFedCm();")
63
dialog = driver.fedcm_dialog()
64
assert dialog.title == "Sign in to localhost with localhost"
65
dialog.dismiss()
66
67
def test_trigger_and_verify_dialog_subtitle(self, driver):
68
driver.execute_script("triggerFedCm();")
69
dialog = driver.fedcm_dialog()
70
assert dialog.subtitle is None
71
dialog.dismiss()
72
73
def test_trigger_and_verify_dialog_type(self, driver):
74
driver.execute_script("triggerFedCm();")
75
dialog = driver.fedcm_dialog()
76
assert dialog.type == "AccountChooser"
77
dialog.dismiss()
78
79
def test_trigger_and_verify_account_list(self, driver):
80
driver.execute_script("triggerFedCm();")
81
dialog = driver.fedcm_dialog()
82
accounts = dialog.get_accounts()
83
assert len(accounts) > 0
84
assert accounts[0].name == "John Doe"
85
dialog.dismiss()
86
87
def test_select_account(self, driver):
88
driver.execute_script("triggerFedCm();")
89
dialog = driver.fedcm_dialog()
90
dialog.select_account(1)
91
driver.fedcm_dialog() # Wait for dialog to become interactable
92
# dialog.click_continue()
93
dialog.dismiss()
94
95
def test_dialog_cancel(self, driver):
96
driver.execute_script("triggerFedCm();")
97
dialog = driver.fedcm_dialog()
98
dialog.dismiss()
99
with pytest.raises(NoAlertPresentException):
100
dialog.title
101
102
def test_enable_fedcm_delay(self, driver):
103
driver.fedcm.enable_delay()
104
105
def test_disable_fedcm_delay(self, driver):
106
driver.fedcm.disable_delay()
107
108
def test_fedcm_cooldown_reset(self, driver):
109
driver.fedcm.reset_cooldown()
110
111
def test_fedcm_no_dialog_type_present(self, driver):
112
with pytest.raises(NoAlertPresentException):
113
driver.fedcm.dialog_type
114
115
def test_fedcm_no_title_present(self, driver):
116
with pytest.raises(NoAlertPresentException):
117
driver.fedcm.title
118
119
def test_fedcm_no_subtitle_present(self, driver):
120
with pytest.raises(NoAlertPresentException):
121
driver.fedcm.subtitle
122
123
def test_fedcm_no_account_list_present(self, driver):
124
with pytest.raises(NoAlertPresentException):
125
driver.fedcm.account_list()
126
127
def test_fedcm_no_select_account_present(self, driver):
128
with pytest.raises(NoAlertPresentException):
129
driver.fedcm.select_account(1)
130
131
def test_fedcm_no_cancel_dialog_present(self, driver):
132
with pytest.raises(NoAlertPresentException):
133
driver.fedcm.dismiss()
134
135
def test_fedcm_no_click_continue_present(self, driver):
136
with pytest.raises(NoAlertPresentException):
137
driver.fedcm.accept()
138
139
def test_verify_dialog_type_after_cooldown_reset(self, driver):
140
driver.fedcm.reset_cooldown()
141
driver.execute_script("triggerFedCm();")
142
dialog = driver.fedcm_dialog()
143
assert dialog.type == "AccountChooser"
144
dialog.dismiss()
145
146