Skip to content

Commit ad94987

Browse files
committed
zoom text only stabilization
1 parent c56fdd2 commit ad94987

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

tests/scrolling_panning_zooming/test_zoom_text_only.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ def test_zoom_text_only_from_settings(
100100
nav = Navigation(driver)
101101
panel_ui = PanelUi(driver)
102102

103-
# Save the original positions of elements for comparison
103+
# Save the original sizes and positions for comparison
104104
panel_ui.open_and_switch_to_new_window("tab")
105105
nav.search(WEBSITE_2)
106106
web_page.wait.until(lambda _: web_page.title_contains("DuckDuckGo"))
107-
original_positions = save_original_positions(driver, web_page)
107+
original_data = save_original_data(driver, web_page)
108108

109109
# Set the pref to zoom text only
110110
panel_ui.open_and_switch_to_new_window("tab")
@@ -115,7 +115,7 @@ def test_zoom_text_only_from_settings(
115115
about_prefs.set_default_zoom_level(110)
116116

117117
# Verify results
118-
zoom_text_only_functionality_test(driver, nav, web_page, original_positions)
118+
zoom_text_only_functionality_test(driver, nav, web_page, original_data)
119119

120120
# Reset the zoom settings so the config is no longer zoom text only, and default zoom level is 100%
121121
about_prefs = AboutPrefs(driver, category="General").open()
@@ -136,62 +136,62 @@ def test_zoom_text_only_after_restart(
136136
nav = Navigation(driver)
137137
panel_ui = PanelUi(driver)
138138

139-
# Save the original positions of elements for comparison
139+
# Save the original sizes and positions for comparison
140140
panel_ui.open_and_switch_to_new_window("tab")
141141
nav.search(WEBSITE_2)
142142
web_page.wait.until(lambda _: web_page.title_contains("DuckDuckGo"))
143-
original_positions = save_original_positions(driver, web_page)
143+
original_data = save_original_data(driver, web_page)
144144

145145
# Set default zoom level
146146
panel_ui.open_and_switch_to_new_window("tab")
147147
about_prefs = AboutPrefs(driver, category="General").open()
148148
about_prefs.set_default_zoom_level(110)
149149

150150
# Verify results
151-
zoom_text_only_functionality_test(driver, nav, web_page, original_positions)
151+
zoom_text_only_functionality_test(driver, nav, web_page, original_data)
152152

153153
# Reset the zoom settings so the config is no longer zoom text only, and default zoom level is 100%
154154
about_prefs = AboutPrefs(driver, category="General").open()
155155
about_prefs.set_default_zoom_level(100)
156156
about_prefs.click_on("zoom-text-only")
157157

158158

159-
def save_original_positions(driver, web_page):
159+
def save_original_data(driver, web_page):
160160
"""
161-
Saves the original positions of elements to be tested to verify the effects of zooming
161+
Saves the original positions and sizes for comparison.
162162
"""
163163
driver.switch_to.window(driver.window_handles[0])
164164
original_website1_image_position = web_page.get_element("yahoo-logo").location["x"]
165165
original_website1_text_position = web_page.get_element(
166166
"yahoo-login-button"
167167
).location["x"]
168+
168169
driver.switch_to.window(driver.window_handles[1])
169-
original_website2_image_position = web_page.get_element("duckduckgo-logo").location[
170-
"x"
171-
]
170+
original_website2_image_size = web_page.get_element("duckduckgo-logo").size
172171
original_website2_text_position = web_page.get_element(
173172
"duckduckgo-tagline"
174173
).location["x"]
174+
175175
return (
176176
original_website1_image_position,
177177
original_website1_text_position,
178-
original_website2_image_position,
178+
original_website2_image_size,
179179
original_website2_text_position,
180180
)
181181

182182

183-
def zoom_text_only_functionality_test(driver, nav, web_page, original_positions):
183+
def zoom_text_only_functionality_test(driver, nav, web_page, original_data):
184184
"""
185185
Verifies that zoom text only works
186186
"""
187187
(
188188
original_website1_image_position,
189189
original_website1_text_position,
190-
original_website2_image_position,
190+
original_website2_image_size,
191191
original_website2_text_position,
192-
) = original_positions
192+
) = original_data
193193

194-
# Verify only text is enlarged
194+
# Verify Yahoo: image position unchanged, text position changed
195195
driver.switch_to.window(driver.window_handles[0])
196196
new_image_position = web_page.get_element("yahoo-logo").location["x"]
197197
new_text_position = web_page.get_element("yahoo-login-button").location["x"]
@@ -208,7 +208,7 @@ def zoom_text_only_functionality_test(driver, nav, web_page, original_positions)
208208
with driver.context(driver.CONTEXT_CHROME):
209209
nav.expect_element_attribute_contains("toolbar-zoom-level", "label", "90%")
210210

211-
# Verify that only text is zoomed out
211+
# Verify Yahoo at 90%: image position still unchanged, text position changed
212212
assert (
213213
web_page.get_element("yahoo-logo").location["x"]
214214
== original_website1_image_position
@@ -218,12 +218,11 @@ def zoom_text_only_functionality_test(driver, nav, web_page, original_positions)
218218
> original_website1_text_position
219219
)
220220

221-
# Verify that zoom level is default level for a different website and only text is enlarged
221+
# Verify DuckDuckGo: image SIZE unchanged, text position changed
222222
driver.switch_to.window(driver.window_handles[1])
223223
assert (
224-
web_page.get_element("duckduckgo-logo").location["x"]
225-
== original_website2_image_position
226-
)
224+
web_page.get_element("duckduckgo-logo").size == original_website2_image_size
225+
), "DuckDuckGo image size should not change (text-only zoom)"
227226
assert (
228227
web_page.get_element("duckduckgo-tagline").location["x"]
229228
< original_website2_text_position

0 commit comments

Comments
 (0)