Skip to content

Commit 7be7791

Browse files
inital fix for test_zoom_text_only.py
1 parent e4c7226 commit 7be7791

File tree

2 files changed

+65
-18
lines changed

2 files changed

+65
-18
lines changed

tests/scrolling_panning_zooming/conftest.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@ def suite_id():
77

88

99
@pytest.fixture()
10-
def set_prefs():
10+
def add_prefs():
11+
return []
12+
13+
14+
@pytest.fixture()
15+
def set_prefs(add_prefs: dict):
1116
"""Set prefs"""
12-
return [
17+
prefs = [
1318
("browser.aboutConfig.showWarning", False),
1419
]
20+
prefs.extend(add_prefs)
21+
return prefs

tests/scrolling_panning_zooming/test_zoom_text_only.py

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ def test_case():
1313
@pytest.fixture()
1414
def temp_selectors():
1515
return {
16+
"yahoo-reject-cookie": {
17+
"selectorData": "button[name='reject']",
18+
"strategy": "css",
19+
"groups": [],
20+
},
21+
"yahoo-consent-page-scroll": {
22+
"selectorData": "scroll-down-btn",
23+
"strategy": "id",
24+
"groups": [],
25+
},
1626
"yahoo-logo": {
1727
"selectorData": "sfp-placeholder",
1828
"strategy": "id",
@@ -24,13 +34,13 @@ def temp_selectors():
2434
"groups": [],
2535
},
2636
"duckduckgo-logo": {
27-
"selectorData": "minimal-homepage_logoHorizontal__Q_hjO",
28-
"strategy": "class",
37+
"selectorData": "img[alt='DuckDuckGo Logo']",
38+
"strategy": "css",
2939
"groups": [],
3040
},
3141
"duckduckgo-tagline": {
32-
"selectorData": "minimal-homepage_taglineText__owJPH",
33-
"strategy": "class",
42+
"selectorData": "//span[contains(@class, 'minimal')]",
43+
"strategy": "xpath",
3444
"groups": [],
3545
},
3646
}
@@ -40,16 +50,48 @@ def temp_selectors():
4050
WEBSITE_2 = "https://start.duckduckgo.com/"
4151

4252

53+
@pytest.fixture()
54+
def add_prefs():
55+
"""
56+
Set the pref to zoom text only (simulate after restart)
57+
"""
58+
return [("browser.zoom.full", False)]
59+
60+
61+
@pytest.fixture()
62+
def web_page(driver: Firefox, temp_selectors):
63+
"""
64+
return instance of generic page with a given website
65+
"""
66+
generic_page = GenericPage(driver, url=WEBSITE_1)
67+
generic_page.elements |= temp_selectors
68+
generic_page.open()
69+
yield generic_page
70+
71+
72+
@pytest.fixture()
73+
def reject_consent_page(web_page: GenericPage):
74+
"""
75+
reject consent page. scroll to rejection button if necessary.
76+
"""
77+
if web_page.element_clickable("yahoo-consent-page-scroll"):
78+
web_page.click_on("yahoo-consent-page-scroll")
79+
web_page.wait.until(lambda _: web_page.element_clickable("yahoo-reject-cookie"))
80+
web_page.click_on("yahoo-reject-cookie")
81+
82+
4383
@pytest.mark.ci
44-
@pytest.mark.unstable
45-
def test_zoom_text_only_from_settings(driver: Firefox, temp_selectors):
84+
def test_zoom_text_only_from_settings(
85+
driver: Firefox, web_page: GenericPage, reject_consent_page
86+
):
4687
"""
4788
C545733.1: Verify that ticking the zoom text only box would only affect the scale of text.
4889
Verify setting the default zoom level applies the chosen zoom level to all websites.
90+
91+
Arguments:
92+
web_page: instance of generic page.
4993
"""
5094
# Initializing objects
51-
web_page = GenericPage(driver, url=WEBSITE_1).open()
52-
web_page.elements |= temp_selectors
5395
nav = Navigation(driver)
5496

5597
# Save the original positions of elements for comparison
@@ -75,18 +117,16 @@ def test_zoom_text_only_from_settings(driver: Firefox, temp_selectors):
75117
about_prefs.click_on("zoom-text-only")
76118

77119

78-
@pytest.mark.unstable
79-
def test_zoom_text_only_after_restart(driver: Firefox, temp_selectors):
120+
def test_zoom_text_only_after_restart(
121+
driver: Firefox, web_page: GenericPage, reject_consent_page
122+
):
80123
"""
81124
C545733.2: Verify that the zoom text only option works after restart
82-
"""
83-
# Set the pref to zoom text only (simulate after restart)
84-
about_config = AboutConfig(driver)
85-
about_config.toggle_true_false_config("browser.zoom.full")
86125
126+
Arguments:
127+
web_page: instance of generic page.
128+
"""
87129
# Initializing objects
88-
web_page = GenericPage(driver, url=WEBSITE_1).open()
89-
web_page.elements |= temp_selectors
90130
nav = Navigation(driver)
91131

92132
# Save the original positions of elements for comparison

0 commit comments

Comments
 (0)