Skip to content

Commit 032fb8f

Browse files
committed
Add test 1756752
1 parent eed6f3d commit 032fb8f

File tree

4 files changed

+52
-12
lines changed

4 files changed

+52
-12
lines changed

SELECTOR_INFO.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,13 @@ Description: The dropdown menu for default zoom selection
11511151
Location: about:preferences - Zoom settings
11521152
Path to .json: modules/data/about_prefs.components.json
11531153
```
1154+
```
1155+
Selector Name: unknown-content-type-dialog
1156+
Selector Data: unknownContentTypeWindo
1157+
Description: The unknown content type dialog
1158+
Location: about:preferences#general Applications subsection
1159+
Path to .json: modules/data/about_prefs.components.json
1160+
```
11541161
#### about_profiles
11551162
```
11561163
Selector Name: profile-container

modules/data/about_prefs.components.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,5 +541,13 @@
541541
"selectorData": "menuitem[data-l10n-id='preferences-default-zoom-value'][value='{.*}']",
542542
"strategy": "css",
543543
"groups": []
544-
}
544+
},
545+
546+
"unknown-content-type-dialog": {
547+
"selectorData": "unknownContentTypeWindow",
548+
"strategy": "id",
549+
"groups": [
550+
"doNotCache"
551+
]
552+
}
545553
}

modules/page_object_prefs.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,31 @@ def get_app_name_for_mime_type(self, mime_type: str) -> str:
657657
mime_type_data = json.loads(action_description.get_attribute("data-l10n-args"))
658658
return mime_type_data["app-name"]
659659

660+
def set_pdf_handling_to_always_ask(self) -> BasePage:
661+
"""
662+
Set PDF content type handling to "Always ask" in Applications settings.
663+
"""
664+
self.click_on("pdf-content-type")
665+
self.click_on("pdf-actions-menu")
666+
menu = self.get_element("pdf-actions-menu")
667+
menu.send_keys(Keys.DOWN)
668+
menu.send_keys(Keys.ENTER)
669+
return self
670+
671+
@BasePage.context_chrome
672+
def handle_unknown_content_dialog(self) -> BasePage:
673+
"""
674+
Wait for the unknown content type dialog to appear and close it with Escape.
675+
"""
676+
self.wait.until(lambda _: len(self.driver.window_handles) > 1)
677+
self.driver.switch_to.window(self.driver.window_handles[-1])
678+
self.wait.until(lambda _: self.get_element("unknown-content-type-dialog"))
679+
680+
# Close the dialog with Escape
681+
dialog = self.get_element("unknown-content-type-dialog")
682+
dialog.send_keys(Keys.ESCAPE)
683+
return self
684+
660685

661686
class AboutAddons(BasePage):
662687
"""

tests/downloads/test_set_always_ask_file_type.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ def delete_files_regex_string():
2727
@pytest.mark.ci
2828
def test_set_always_ask_file_type(driver: Firefox, delete_files):
2929
"""
30-
C1756752: Ensure that the Always ask option in Firefox Applications settings
30+
C1756752 - Ensure that the Always ask option in Firefox Applications settings
3131
leads to a dialog asking "What should Firefox do with this file?" when the file type
3232
is downloaded.
3333
"""
34+
35+
# Initialize page objects
3436
nav = Navigation(driver)
35-
about_prefs = AboutPrefs(driver, category="general").open()
37+
about_prefs = AboutPrefs(driver, category="general")
3638

37-
about_prefs.click_on("pdf-content-type")
38-
about_prefs.click_on("pdf-actions-menu")
39-
menu = about_prefs.get_element("pdf-actions-menu")
40-
menu.send_keys(Keys.DOWN)
41-
menu.send_keys(Keys.ENTER)
39+
# Set PDF handling to "Always ask"
40+
about_prefs.open()
41+
about_prefs.set_pdf_handling_to_always_ask()
4242

43+
# Navigate to download URL and verify dialog appears
4344
nav.search(CONTENT_DISPOSITION_ATTACHMENT_URL)
44-
sleep(2)
45-
with driver.context(driver.CONTEXT_CHROME):
46-
driver.switch_to.window(driver.window_handles[-1])
47-
driver.find_element(By.ID, "unknownContentTypeWindow").send_keys(Keys.ESCAPE)
45+
46+
# Wait for and handle the unknown content type dialog
47+
about_prefs.handle_unknown_content_dialog()

0 commit comments

Comments
 (0)