diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml index 861e79208..7a3d15bb3 100644 --- a/.github/workflows/smoke.yml +++ b/.github/workflows/smoke.yml @@ -107,7 +107,7 @@ jobs: $env:FX_EXECUTABLE = "C:\Program Files\Custom Firefox\firefox.exe" Start-Process -FilePath $env:FX_EXECUTABLE -ArgumentList "--version" -Wait -NoNewWindow pipenv run python choose_ci_set.py - pipenv run pytest $(cat selected_tests) + pipenv run pytest --geckodriver geckodriver.exe $(cat selected_tests) $env:TEST_EXIT_CODE = $LASTEXITCODE mv artifacts artifacts-win || true exit $env:TEST_EXIT_CODE @@ -120,7 +120,7 @@ jobs: mv ./ci_pyproject_headed.toml ./pyproject.toml; $env:FX_EXECUTABLE = "C:\Program Files\Custom Firefox\firefox.exe" pipenv run python choose_ci_set.py - pipenv run pytest $(cat selected_tests) + pipenv run pytest --geckodriver geckodriver.exe $(cat selected_tests) $env:TEST_EXIT_CODE = $LASTEXITCODE rm artifacts/assets -r -Force Get-ChildItem -Path "artifacts" | ForEach-Object { diff --git a/SELECTOR_INFO.md b/SELECTOR_INFO.md index 70e467847..cf512adeb 100644 --- a/SELECTOR_INFO.md +++ b/SELECTOR_INFO.md @@ -495,14 +495,14 @@ Path to .json: modules/data/about_prefs.components.json ``` ``` Selector Name: save-and-fill-addresses -Selector Data: "checkbox[label='Save and fill addresses']" +Selector Data: "[data-l10n-id='autofill-addresses-checkbox-message']" Description: Label for Autofill > Save and fill addresses option Location: about:preferences#privacy Path to .json: modules/data/about_prefs.components.json ``` ``` Selector Name: save-and-fill-payment-methods -Selector Data: "checkbox[label='Save and fill payment methods']" +Selector Data: "[data-l10n-id='autofill-payment-methods-checkbox-message-2']" Description: Label for Autofill > Save and fill payment methods option Location: about:preferences#privacy Path to .json: modules/data/about_prefs.components.json @@ -515,6 +515,20 @@ Location: about:preferences#privacy Path to .json: modules/data/about_prefs.components.json ``` ``` +Selector Name: saved-payments-button +Selector Data: "[data-l10n-id='autofill-payment-methods-manage-payments-button']" +Description: Embedded button/label for "Manage Saved Payments" +Location: about:preferences#privacy +Path to .json: modules/data/about_prefs.components.json +``` +``` +Selector Name: saved-addresses-button +Selector Data: "[data-l10n-id='autofill-addresses-manage-addresses-button']" +Description: Embedded button/label for "Manage Addresses and more..." +Location: about:preferences#privacy +Path to .json: modules/data/about_prefs.components.json +``` +``` Selector Name: import-browser-data Selector Data: "button[id='data-migration']" Description: Import Browser Data > Import Data button @@ -845,7 +859,7 @@ Path to .json: modules/data/about_prefs.components.json ``` ``` Selector Name: cookies-privacy-label -Selector Data: "description[data-l10n-id='sitedata-delete-on-close-private-browsing2']" +Selector Data: "[data-l10n-id='sitedata-delete-on-close-private-browsing3']" Description: Message in Cookies and Site data when History is not remembered Location: about:preferences#privacy Path to .json: modules/data/about_prefs.components.json @@ -1833,9 +1847,9 @@ Location: Any non-linked content space inside example.com page Path to .json: modules/data/exemple_page.components.json ``` ``` -Selector Name: more-information -Selector Data: "More information..." -Description: More information..." link +Selector Name: learn-more +Selector Data: "Learn more" +Description: "Learn more" link Location: The hyperlink positioned in the middle of example.com page Path to .json: modules/data/exemple_page.components.json ``` diff --git a/conftest.py b/conftest.py index 142f33e83..18b45e369 100644 --- a/conftest.py +++ b/conftest.py @@ -8,12 +8,14 @@ from subprocess import check_output, run from typing import Callable, List, Tuple, Union +# import psutil import pytest from PIL import Image, ImageGrab from selenium.common.exceptions import TimeoutException, WebDriverException from selenium.webdriver import Firefox from selenium.webdriver.common.by import By from selenium.webdriver.firefox.options import Options +from selenium.webdriver.firefox.service import Service from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait @@ -132,6 +134,13 @@ def pytest_addoption(parser): help="Path to Fx executable. Will overwrite --fx-channel.", ) + parser.addoption( + "--geckodriver", + action="store", + default="", + help="Path to geckodriver.", + ) + parser.addoption( "--run-headless", action="store_true", @@ -216,12 +225,17 @@ def sys_platform(): return platform.system() +@pytest.fixture(scope="session") +def geckodriver(request): + return request.config.getoption("--geckodriver") + + @pytest.fixture() def downloads_folder(sys_platform): """Return the downloads folder location for this OS""" if sys_platform == "Windows": user = os.environ.get("USERNAME") - return f"C:\\Users\\{user}\\Downloads" + return rf"C:\Users\{user}\Downloads" elif sys_platform == "Darwin": # MacOS user = os.environ.get("USER") return f"/Users/{user}/Downloads" @@ -242,11 +256,11 @@ def fx_executable(request, sys_platform): location = "" if sys_platform == "Windows": if version == "Firefox": - location = "C:\\Program Files\\Mozilla Firefox\\firefox.exe" + location = r"C:\Program Files\Mozilla Firefox\firefox.exe" elif version == "Nightly": - location = "C:\\Program Files\\Firefox Nightly\\firefox.exe" + location = r"C:\Program Files\Firefox Nightly\firefox.exe" elif version == "Custom": - location = "C:\\Program Files\\Custom Firefox\\firefox.exe" + location = r"C:\Program Files\Custom Firefox\firefox.exe" elif sys_platform == "Darwin": if version == "Firefox": location = "/Applications/Firefox.app/Contents/MacOS/firefox" @@ -392,6 +406,7 @@ def hard_quit(): @pytest.fixture(autouse=True) def driver( fx_executable: str, + geckodriver: str, opt_headless: bool, opt_implicit_timeout: int, prefs_list: List[Tuple], @@ -457,7 +472,15 @@ def driver( options.profile = profile_path for opt, value in prefs_list: options.set_preference(opt, value) - driver = Firefox(options=options) + if geckodriver: + service = Service(executable_path=geckodriver) + driver = Firefox(service=service, options=options) + else: + driver = Firefox(options=options) + # Uncomment below to find Fx process info + # for proc in psutil.process_iter(["name", "exe", "cmdline"]): + # if proc.info["name"] and "firefox" in proc.info["name"].lower(): + # print(proc.info) separator = "x" if separator not in opt_window_size: if "by" in opt_window_size: diff --git a/modules/browser_object_panel_ui.py b/modules/browser_object_panel_ui.py index 711509fb9..d64527f7c 100644 --- a/modules/browser_object_panel_ui.py +++ b/modules/browser_object_panel_ui.py @@ -171,7 +171,7 @@ def reopen_recently_closed_tabs(self) -> BasePage: self.click_on("panel-ui-history") self.click_on("panel-ui-history-recently-closed") - if self.sys_platform() == "Linux": + if self.sys_platform() in ("Linux", "Darwin"): sleep(2) self.click_on("panel-ui-history-recently-closed-reopen-tabs") diff --git a/modules/browser_object_tracker_panel.py b/modules/browser_object_tracker_panel.py index a02762d64..839703a16 100644 --- a/modules/browser_object_tracker_panel.py +++ b/modules/browser_object_tracker_panel.py @@ -76,7 +76,7 @@ def wait_for_blocked_tracking_icon( self, nav: Navigation, page: BasePage ) -> BasePage: """ - Waits for the shield icon to indicate that cookies/trackers are being blocked by continuously refresing the page + Waits for the shield icon to indicate that cookies/trackers are being blocked by continuously refreshing the page Remember to open the passed in page beforehand, this waits for the page to load. diff --git a/modules/data/about_prefs.components.json b/modules/data/about_prefs.components.json index 2b2d50092..c1e5e3a9f 100644 --- a/modules/data/about_prefs.components.json +++ b/modules/data/about_prefs.components.json @@ -45,12 +45,12 @@ "groups": [] }, "save-and-fill-addresses": { - "selectorData": "checkbox[label='Save and fill addresses']", + "selectorData": "[data-l10n-id='autofill-addresses-checkbox-message']", "strategy": "css", "groups": [] }, "save-and-fill-payment-methods": { - "selectorData": "checkbox[label='Save and fill payment methods']", + "selectorData": "[data-l10n-id='autofill-payment-methods-checkbox-message-2']", "strategy": "css", "groups": [] }, @@ -59,6 +59,16 @@ "strategy": "css", "groups": [] }, + "saved-payments-button": { + "selectorData": "[data-l10n-id='autofill-payment-methods-manage-payments-button']", + "strategy": "css", + "groups": [] + }, + "saved-addresses-button": { + "selectorData": "[data-l10n-id='autofill-addresses-manage-addresses-button']", + "strategy": "css", + "groups": [] + }, "import-browser-data": { "selectorData": "button[id='data-migration']", "strategy": "css", @@ -307,7 +317,7 @@ "groups": [] }, "cookies-privacy-label": { - "selectorData": "description[data-l10n-id='sitedata-delete-on-close-private-browsing2']", + "selectorData": "[data-l10n-id='sitedata-delete-on-close-private-browsing3']", "strategy": "css", "groups": [] }, diff --git a/modules/data/example_page.components.json b/modules/data/example_page.components.json index d8cc5339f..1333ea853 100644 --- a/modules/data/example_page.components.json +++ b/modules/data/example_page.components.json @@ -14,8 +14,8 @@ ] }, - "more-information": { - "selectorData": "More information...", + "learn-more": { + "selectorData": "Learn more", "strategy": "link_text", "groups": [] } diff --git a/modules/data/panel_ui.components.json b/modules/data/panel_ui.components.json index 4be365c5e..8011674e1 100644 --- a/modules/data/panel_ui.components.json +++ b/modules/data/panel_ui.components.json @@ -133,7 +133,7 @@ }, "panel-ui-history-recently-closed-reopen-tabs": { - "selectorData": "toolbarbutton[class='restoreallitem subviewbutton panel-subview-footer-button']", + "selectorData": "toolbarbutton[class='subviewbutton subviewbutton-nav'][label='Recently closed tabs']", "strategy": "css", "groups": [] }, diff --git a/modules/page_object_prefs.py b/modules/page_object_prefs.py index 9f0528e16..a04fbcb76 100644 --- a/modules/page_object_prefs.py +++ b/modules/page_object_prefs.py @@ -204,12 +204,6 @@ def verify_cc_edit_saved_payments_profile( assert field_value != expected_cvv, "CVV is displayed." return self - def get_saved_payments_popup(self) -> WebElement: - """ - Open saved payments dialog panel - """ - return self.get_element("prefs-button", labels=["Saved payment methods"]) - def click_edit_on_dialog_element(self): """ Click on edit button on dialog panel @@ -283,7 +277,11 @@ def add_entry_to_saved_payments(self, cc_data: CreditCardBase): def close_dialog_box(self): """Close dialog box for saved addresses or payments.""" self.element_clickable("panel-popup-button", labels=["close-button"]) - self.get_element("panel-popup-button", labels=["close-button"]).click() + self.click_on("panel-popup-button", labels=["close-button"]) + if self.get_element( + "panel-popup-button", labels=["close-button"] + ).is_displayed(): + self.click_on("panel-popup-button", labels=["close-button"]) return self def update_cc_field_panel(self, field_name: str, value: str | int) -> BasePage: @@ -317,12 +315,6 @@ def update_cc_field_panel(self, field_name: str, value: str | int) -> BasePage: self.get_element("save-button").click() return self - def get_saved_addresses_popup(self) -> WebElement: - """ - Returns saved addresses button element - """ - return self.get_element("prefs-button", labels=["Saved addresses"]) - def open_and_switch_to_saved_addresses_popup(self) -> BasePage: """ Open and Switch to saved addresses popup frame. @@ -420,7 +412,8 @@ def get_saved_payments_popup_iframe(self) -> WebElement: """ Returns the iframe object for the dialog panel in the popup """ - self.get_saved_payments_popup().click() + self.find_in_settings("pay") + self.click_on("saved-payments-button") iframe = self.get_element("browser-popup") return iframe @@ -444,7 +437,8 @@ def get_saved_addresses_popup_iframe(self) -> WebElement: """ Returns the iframe object for the dialog panel in the popup """ - self.get_saved_addresses_popup().click() + self.find_in_settings("pay") + self.click_on("saved-addresses-button") iframe = self.get_element("browser-popup") return iframe diff --git a/tests/address_bar_and_search/test_search_mode_persists_mixed_with_bing.py b/tests/address_bar_and_search/test_search_mode_persists_mixed_with_bing.py new file mode 100644 index 000000000..7d7cbc5d0 --- /dev/null +++ b/tests/address_bar_and_search/test_search_mode_persists_mixed_with_bing.py @@ -0,0 +1,46 @@ +import pytest +from selenium.webdriver import Firefox +from selenium.webdriver.common.keys import Keys + +from modules.browser_object_navigation import Navigation +from modules.page_object_generics import GenericPage + + +@pytest.fixture() +def test_case(): + return "3028730" + + +@pytest.mark.parametrize("engine", ["DuckDuckGo"]) +def test_search_mode_persists_mixed_with_bing(driver: Firefox, engine): + """ + TC 3028730: Ensure '@bing' is NOT recognized as a special Bing search when DuckDuckGo is selected. + """ + # Open a neutral page (new tab) and prepare helpers + page = GenericPage(driver, url="about:newtab") + nav = Navigation(driver) + + page.open() + + # Step 1: pick DuckDuckGo from the search mode switcher (aka USB) + nav.click_search_mode_switcher() + nav.set_search_mode(engine) + + # Step 2: type '@bing' in the Awesome Bar + nav.click_in_awesome_bar() + nav.type_in_awesome_bar("@bing") + + # Assert that the "tab to search" / alias UI is NOT shown for '@bing' + nav.element_not_visible("tab-to-search-text-span") + + # Step 3: continue typing any word and hit Enter + nav.type_in_awesome_bar(" test" + Keys.ENTER) + + # Expectation: a DuckDuckGo results page, with '@bing' included as plain text in the query. + page.url_contains("duckduckgo.com") + + # Verify '@bing' appears in the query (allowing for URL encoding) + current_url = driver.current_url + assert ("%40bing" in current_url) or ("@bing" in current_url), ( + f"@bing should be part of the search term, but URL was: {current_url}" + ) diff --git a/tests/audio_video/test_allow_audio_video_functionality.py b/tests/audio_video/test_allow_audio_video_functionality.py index c74c5e032..9826a0dc8 100644 --- a/tests/audio_video/test_allow_audio_video_functionality.py +++ b/tests/audio_video/test_allow_audio_video_functionality.py @@ -15,12 +15,12 @@ def test_case(): WIN_GHA = environ.get("GITHUB_ACTIONS") == "true" and sys.platform.startswith("win") +TEST_URL = "https://www.w3schools.com/html/mov_bbb.mp4" -TEST_URL = "https://www.mlb.com/video/rockies-black-agree-on-extension" - - -@pytest.mark.skipif(WIN_GHA, reason="Test unstable in Windows Github Actions") +@pytest.mark.skipif( + WIN_GHA, reason="Audio playback not supported in Windows CI environment" +) @pytest.mark.audio @pytest.mark.noxvfb def test_allow_audio_video_functionality(driver: Firefox): @@ -32,9 +32,11 @@ def test_allow_audio_video_functionality(driver: Firefox): tabs = TabBar(driver) page = GenericPage(driver, url=TEST_URL) - # Open privacy and click on the "Settings" button from Autoplay + # Open privacy and security preferences and set 'Allow Audio and Video' for autoplay about_prefs.set_autoplay_setting_in_preferences("allow-audio-video") - # Open the website and check if the video starts playing with sound + # Open the website in a new tab and check if the video starts playing with sound + tabs.new_tab_by_button() + tabs.switch_to_new_tab() page.open() - tabs.expect_tab_sound_status(1, tabs.MEDIA_STATUS.PLAYING) + tabs.expect_tab_sound_status(2, tabs.MEDIA_STATUS.PLAYING) diff --git a/tests/downloads/test_download_pdf_from_context_menu.py b/tests/downloads/test_download_pdf_from_context_menu.py index 49536e66e..eb07a5c42 100644 --- a/tests/downloads/test_download_pdf_from_context_menu.py +++ b/tests/downloads/test_download_pdf_from_context_menu.py @@ -1,3 +1,4 @@ +from platform import system from time import sleep import pytest @@ -24,6 +25,10 @@ def delete_files_regex_string(): PDF_TELEMETRY_DATA = ["downloads", "added", "fileExtension", "pdf"] +@pytest.mark.skipif( + system().lower().startswith("darwin") or system().lower().startswith("linux"), + reason="bug 1994061", +) @pytest.mark.headed def test_download_pdf_from_context_menu( driver: Firefox, diff --git a/tests/form_autofill/conftest.py b/tests/form_autofill/conftest.py index f7006beb3..2cdf5d15d 100644 --- a/tests/form_autofill/conftest.py +++ b/tests/form_autofill/conftest.py @@ -19,6 +19,8 @@ def prefs_list(add_to_prefs_list: dict): prefs = [ ("extensions.formautofill.creditCards.reauth.optout", False), ("extensions.formautofill.reauth.enabled", False), + ("extensions.formautofill.addresses.enabled", True), + ("extensions.formautofill.creditCards.enabled", True), ] prefs.extend(add_to_prefs_list) return prefs diff --git a/tests/menus/test_hyperlink_context_menu.py b/tests/menus/test_hyperlink_context_menu.py index c58f77b79..362eaae88 100644 --- a/tests/menus/test_hyperlink_context_menu.py +++ b/tests/menus/test_hyperlink_context_menu.py @@ -19,13 +19,13 @@ def test_open_link_in_new_window(driver: Firefox): example = ExamplePage(driver) example.open() - # right click the hyperlink - example.context_click("more-information") + # Right-click the hyperlink + example.context_click("learn-more") - # click on the open in new window option + # Click on the open in new window option hyperlink_context.click_and_hide_menu("context-menu-open-link-in-new-window") - # verify there are two instances (two windows) + # Verify there are two instances (two windows) tabs.wait_for_num_windows(2) driver.switch_to.window(driver.window_handles[1]) diff --git a/tests/menus/test_tab_context_menu_actions.py b/tests/menus/test_tab_context_menu_actions.py index 7da28305b..1eae831da 100644 --- a/tests/menus/test_tab_context_menu_actions.py +++ b/tests/menus/test_tab_context_menu_actions.py @@ -28,18 +28,18 @@ def test_duplicate_tab(driver: Firefox): tabs_to_open = 4 - # open some tabs + # Open some tabs for i in range(tabs_to_open): driver.get(links[i]) tabs.new_tab_by_button() driver.switch_to.window(driver.window_handles[i + 1]) - # context click + # Context click first_tab = tabs.get_tab(1) tabs.context_click(first_tab) tab_context_menu.click_and_hide_menu("context-menu-duplicate-tab") - # get the current tab and assert the url + # Get the current tab and assert the url driver.switch_to.window(driver.window_handles[tabs_to_open + 1]) current_page = driver.current_url assert current_page == links[0] @@ -54,7 +54,7 @@ def test_close_multiple_tabs_to_right(driver: Firefox): tabs_to_open = 4 - # open some tabs + # Open some tabs for i in range(tabs_to_open): driver.get(links[i]) tabs.new_tab_by_button() diff --git a/tests/menus/test_tab_context_menu_close.py b/tests/menus/test_tab_context_menu_close.py index 4957ec51f..195932b70 100644 --- a/tests/menus/test_tab_context_menu_close.py +++ b/tests/menus/test_tab_context_menu_close.py @@ -93,27 +93,29 @@ def test_copy_link(driver: Firefox): nav = Navigation(driver) hyperlink_context = ContextMenu(driver) tabs = TabBar(driver) - example = ExamplePage(driver).open() + example = ExamplePage(driver) - # right click the hyperlink + example.open() + + # Right-click the hyperlink sleep(1) - example.context_click("more-information") + example.context_click("learn-more") - # click on the open in new window option + # Click on the open in new window option sleep(1) hyperlink_context.click_and_hide_menu("context-menu-copy-link") - # open a new tab + # Open a new tab tabs.new_tab_by_button() tabs.wait_for_num_tabs(2) sleep(1) driver.switch_to.window(driver.window_handles[1]) - # # context click and paste + # Context click and paste search_bar = nav.get_awesome_bar() nav.context_click(search_bar) - # paste and go + # Paste and go nav.click_and_hide_menu("context-menu-paste-and-go") example.title_contains(example.MORE_INFO_TITLE) diff --git a/tests/meta/test_version.py b/tests/meta/test_version.py index 991f345f6..70d21d310 100644 --- a/tests/meta/test_version.py +++ b/tests/meta/test_version.py @@ -1,12 +1,19 @@ +import json import logging from subprocess import check_output -def test_version(opt_ci, fx_executable): +def test_version(driver, opt_ci, fx_executable): """Get the Fx version""" version = check_output([fx_executable, "--version"]).decode() + assert driver.capabilities["browserVersion"] in version logging.info(version) + logging.warning(f"Fx version {driver.capabilities}") + driver.get("chrome://browser/content/aboutDialog.xhtml") + ver_label = driver.find_element("id", "version") + ver_info = json.loads(ver_label.get_attribute("data-l10n-args")) + assert ver_info.get("version") in version if opt_ci: with open("artifacts/fx_version", "w") as fh: fh.write(version) diff --git a/tests/preferences/test_clear_cookie_data.py b/tests/preferences/test_clear_cookie_data.py index 8ca8120f6..e0ed97862 100644 --- a/tests/preferences/test_clear_cookie_data.py +++ b/tests/preferences/test_clear_cookie_data.py @@ -1,3 +1,5 @@ +from platform import system + import pytest from selenium.webdriver import Firefox from selenium.webdriver.support.ui import WebDriverWait @@ -24,7 +26,7 @@ def _dialog_options_present(about_prefs: AboutPrefs) -> bool: return False -def open_clear_cookies_data_dialog( +def _open_clear_cookies_data_dialog( about_prefs: AboutPrefs, ba: BrowserActions, wait: WebDriverWait ): """ @@ -53,6 +55,10 @@ def open_clear_cookies_data_dialog( # @pytest.mark.skipif(WIN_GHA, reason="Test unstable in Windows GA, tracked in 1990570") +@pytest.mark.skipif( + system().lower().startswith("darwin") or system().lower().startswith("linux"), + reason="bug 1994055", +) def test_clear_cookie_data(driver: Firefox): """ C143627: Cookies and site data can be cleared via the "Clear Data" panel @@ -65,7 +71,7 @@ def test_clear_cookie_data(driver: Firefox): driver.get(WEBSITE_ADDRESS) # Open dialog and read current value (must be > 0) - cookie_value = open_clear_cookies_data_dialog(about_prefs, ba, wait) + cookie_value = _open_clear_cookies_data_dialog(about_prefs, ba, wait) assert cookie_value > 0, f"Expected cookie/site data > 0, got {cookie_value}" # Clear cookies and site data: open dialog again, wait for iframe, click clear @@ -77,7 +83,7 @@ def test_clear_cookie_data(driver: Firefox): ba.switch_to_content_context() # Wait until the dialog reports 0 (reopen/poll via helper) - wait.until(lambda _: open_clear_cookies_data_dialog(about_prefs, ba, wait) == 0) + wait.until(lambda _: _open_clear_cookies_data_dialog(about_prefs, ba, wait) == 0) - final_value = open_clear_cookies_data_dialog(about_prefs, ba, wait) + final_value = _open_clear_cookies_data_dialog(about_prefs, ba, wait) assert final_value == 0, f"Expected 0 after clearing, got {final_value}" diff --git a/tests/preferences/test_manage_cookie_data.py b/tests/preferences/test_manage_cookie_data.py index 3cf377248..5dbc2cadb 100644 --- a/tests/preferences/test_manage_cookie_data.py +++ b/tests/preferences/test_manage_cookie_data.py @@ -1,3 +1,4 @@ +from platform import system from time import sleep import pytest @@ -16,6 +17,10 @@ def test_case(): COOKIE_SITE = "google.com" +@pytest.mark.skipif( + system().lower().startswith("darwin") or system().lower().startswith("linux"), + reason="bug 1994056", +) @pytest.mark.headed @pytest.mark.noxvfb def test_manage_cookie_data(driver: Firefox): diff --git a/tests/security_and_privacy/test_never_remember_browsing_history.py b/tests/security_and_privacy/test_never_remember_browsing_history.py index 89708e266..e23e251fc 100644 --- a/tests/security_and_privacy/test_never_remember_browsing_history.py +++ b/tests/security_and_privacy/test_never_remember_browsing_history.py @@ -38,7 +38,7 @@ def test_never_remember_browsing_history_settings(driver: Firefox): # perform all about:preferences#privacy assertions according to testrail cookies_label = about_prefs.get_element("cookies-privacy-label") - assert cookies_label.get_attribute("innerHTML") == COOKIE_LABEL_TEXT + assert cookies_label.get_attribute("message") == COOKIE_LABEL_TEXT delete_cookies_checkbox = about_prefs.get_element("cookies-delete-on-close") assert delete_cookies_checkbox.get_attribute("checked") == "true" diff --git a/tests/security_and_privacy/test_open_link_in_private_window.py b/tests/security_and_privacy/test_open_link_in_private_window.py index ee6f5aa5a..f2c4004a6 100644 --- a/tests/security_and_privacy/test_open_link_in_private_window.py +++ b/tests/security_and_privacy/test_open_link_in_private_window.py @@ -20,7 +20,7 @@ def test_open_link_in_private_window(driver: Firefox): nav = Navigation(driver) sleep(1) - example.context_click("more-information") + example.context_click("learn-more") sleep(1) context_menu.click_and_hide_menu("context-menu-open-link-in-new-private-window") diff --git a/tests/security_and_privacy/test_third_party_content_blocked_private_browsing.py b/tests/security_and_privacy/test_third_party_content_blocked_private_browsing.py index e68161cfb..dfc4bfb93 100644 --- a/tests/security_and_privacy/test_third_party_content_blocked_private_browsing.py +++ b/tests/security_and_privacy/test_third_party_content_blocked_private_browsing.py @@ -1,3 +1,5 @@ +from platform import system + import pytest from selenium.webdriver import Firefox @@ -10,14 +12,12 @@ def test_case(): return "446323" -ALLOWED_TRACKING_URLS = set( - [ - "https://content-track-digest256.dummytracker.org", - "https://ads-track-digest256.dummytracker.org", - "https://social-track-digest256.dummytracker.org", - "https://analytics-track-digest256.dummytracker.org", - ] -) +ALLOWED_TRACKING_URLS = { + "https://content-track-digest256.dummytracker.org", + "https://ads-track-digest256.dummytracker.org", + "https://social-track-digest256.dummytracker.org", + "https://analytics-track-digest256.dummytracker.org", +} BLOCKED_TRACKER_URL = "https://content-track-digest256.dummytracker.org" FIRST_TRACKER_WEBSITE = "https://senglehardt.com/test/trackingprotection/test_pages/tracking_protection.html" @@ -103,6 +103,10 @@ def test_third_party_content_blocked_private_browsing_allowed_tracking(driver: F assert item.get_attribute("value") in ALLOWED_TRACKING_URLS +@pytest.mark.skipif( + system().lower().startswith("darwin") or system().lower().startswith("linux"), + reason="bug 1994060", +) def test_third_party_content_private_browsing_tracking_statuses(driver: Firefox): """ C446323.3: Ensure that the statuses of some third party content are loaded properly diff --git a/tests/tabs/test_open_new_bg_tab_via_mouse_and_keyboard.py b/tests/tabs/test_open_new_bg_tab_via_mouse_and_keyboard.py index 6f7369044..45d726dc3 100644 --- a/tests/tabs/test_open_new_bg_tab_via_mouse_and_keyboard.py +++ b/tests/tabs/test_open_new_bg_tab_via_mouse_and_keyboard.py @@ -21,7 +21,7 @@ def test_open_new_bg_tab_via_mouse_and_keyboard(driver: Firefox): example.open() # Middle click link, verify new background tab opens with correct URL - example.middle_click("more-information") + example.middle_click("learn-more") example.wait_for_num_tabs(2) example.switch_to_new_tab() @@ -32,7 +32,7 @@ def test_open_new_bg_tab_via_mouse_and_keyboard(driver: Firefox): example.switch_to_new_tab() # Control click link, verify new background tab opens with correct URL - example.control_click("more-information") + example.control_click("learn-more") example.wait_for_num_tabs(2) example.switch_to_new_tab() diff --git a/tests/tabs/test_open_new_tab_via_hyperlink.py b/tests/tabs/test_open_new_tab_via_hyperlink.py index 6377aced0..24932323d 100644 --- a/tests/tabs/test_open_new_tab_via_hyperlink.py +++ b/tests/tabs/test_open_new_tab_via_hyperlink.py @@ -4,6 +4,8 @@ from modules.browser_object import ContextMenu from modules.page_object import ExamplePage +URL = "https://www.iana.org/help/example-domains" + @pytest.fixture() def test_case(): @@ -14,15 +16,17 @@ def test_open_new_via_hyperlink(driver: Firefox): """ C134444 - A hyperlink can be opened in a new tab """ - example = ExamplePage(driver).open() - # Use context menu option to open link in new tab - example.context_click("more-information") + # Instantiate objects + example = ExamplePage(driver) context_menu = ContextMenu(driver) - with driver.context(driver.CONTEXT_CHROME): - context_menu.click_and_hide_menu("context-menu-open-link-in-tab") + + # Use context menu option to open link in new tab + example.open() + example.context_click("learn-more") + context_menu.click_and_hide_menu("context-menu-open-link-in-tab") # Get the title of the new tab example.wait_for_num_tabs(2) example.switch_to_new_tab() - example.url_contains("https://www.iana.org/help/example-domains") + example.url_contains(URL) diff --git a/tests/tabs/test_pin_tab.py b/tests/tabs/test_pin_tab.py index 619ecd9e0..94f94809a 100644 --- a/tests/tabs/test_pin_tab.py +++ b/tests/tabs/test_pin_tab.py @@ -3,6 +3,8 @@ from modules.browser_object import ContextMenu, TabBar +NUM_TABS = 5 + @pytest.fixture() def test_case(): @@ -13,16 +15,16 @@ def test_pin_tab(driver: Firefox): """ C134722, ensures that tabs can be pinned """ + + # Instantiate objects tabs = TabBar(driver) tab_context_menu = ContextMenu(driver) - num_tabs = 5 - - # opening some tabs - for _ in range(num_tabs): + # Opening some tabs + for _ in range(NUM_TABS): tabs.new_tab_by_button() - # pin the 1st tab + # Pin the 1st tab first_tab = tabs.get_tab(1) tabs.context_click(first_tab) tab_context_menu.click_and_hide_menu("context-menu-pin-tab") @@ -30,11 +32,11 @@ def test_pin_tab(driver: Firefox): assert tabs.is_pinned(first_tab) # ensuring all the other tabs are not pinned - for i in range(2, num_tabs + 2): + for i in range(2, NUM_TABS + 2): tab = tabs.get_tab(i) assert not tabs.is_pinned(tab) - # unpinning the tab and ensuring it is no longer pinned + # Unpinning the tab and ensuring it is no longer pinned tabs.context_click(first_tab) tab_context_menu.click_and_hide_menu("context-menu-unpin-tab") diff --git a/tests/tabs/test_reopen_tab_through_context_menu.py b/tests/tabs/test_reopen_tab_through_context_menu.py index b28dd7e56..cf33e00a5 100644 --- a/tests/tabs/test_reopen_tab_through_context_menu.py +++ b/tests/tabs/test_reopen_tab_through_context_menu.py @@ -3,6 +3,10 @@ from modules.browser_object import ContextMenu, TabBar +TABS_TO_OPEN = 4 +FIRST_URL = "about:about" +SECOND_URL = "about:robots" + @pytest.fixture() def test_case(): @@ -11,27 +15,28 @@ def test_case(): def test_reopen_tab_through_context_menu(driver: Firefox): """C134648: Reopen tab through context menu""" + + # Instantiate objects tabs = TabBar(driver) tab_context_menu = ContextMenu(driver) - tabs_to_open = 4 - - driver.get("about:about") - for _ in range(1, tabs_to_open): + # Open several different tabs and close them + driver.get(FIRST_URL) + for _ in range(1, TABS_TO_OPEN): tabs.new_tab_by_button() driver.switch_to.window(driver.window_handles[-1]) - driver.get("about:robots") + driver.get(SECOND_URL) remaining_tab = tabs.get_tab(1) - closing_tab = tabs.get_tab(tabs_to_open) + closing_tab = tabs.get_tab(TABS_TO_OPEN) - with driver.context(driver.CONTEXT_CHROME): - assert tabs.get_tab_title(closing_tab).startswith("Gort") + assert tabs.get_tab_title(closing_tab).startswith("Gort") driver.close() driver.switch_to.window(driver.window_handles[0]) + # Right click on the remaining tab and reopen previously closed tab tabs.context_click(remaining_tab) tab_context_menu.click_and_hide_menu("context-menu-reopen-closed-tab") - reopened_tab = tabs.get_tab(tabs_to_open + 1) + reopened_tab = tabs.get_tab(TABS_TO_OPEN + 1) assert tabs.get_tab_title(reopened_tab).startswith("Gort") diff --git a/tests/tabs/test_reopen_tab_through_history_menu.py b/tests/tabs/test_reopen_tab_through_history_menu.py index bf7a40f63..53b8f37ab 100644 --- a/tests/tabs/test_reopen_tab_through_history_menu.py +++ b/tests/tabs/test_reopen_tab_through_history_menu.py @@ -12,7 +12,7 @@ def test_case(): return "134650" -links = [ +LINKS = [ "about:about", "about:addons", "about:cache", @@ -22,7 +22,8 @@ def test_case(): "about:blank", ] -link_set = set(links) +LINK_SET = set(LINKS) +NUM_TABS = 6 @pytest.mark.skipif( @@ -30,27 +31,28 @@ def test_case(): ) def test_reopen_tab_through_history_menu(driver: Firefox): """C134650 - Verify that the recently closed tab can be reopened from the history menu""" - # open 6 tabs + + # Instantiate objects tabs = TabBar(driver) panel = PanelUi(driver) - num_tabs = 6 - for i in range(num_tabs): - driver.get(links[i]) + # open 6 tabs + for i in range(NUM_TABS): + driver.get(LINKS[i]) tabs.new_tab_by_button() driver.switch_to.window(driver.window_handles[i + 1]) # close the first 6 tabs - for i in range(num_tabs): - tabs.close_tab(tabs.get_tab(num_tabs - i)) + for i in range(NUM_TABS): + tabs.close_tab(tabs.get_tab(NUM_TABS - i)) # open menu bar and reopen recently closed tabs panel.open() panel.reopen_recently_closed_tabs() # go through all the tabs and ensure they were the ones that were opened previously - for i in range(num_tabs): - driver.switch_to.window(driver.window_handles[i + 1]) + for i in range(NUM_TABS): + driver.switch_to.window(driver.window_handles[-1]) current_page = driver.current_url logging.info(f"The current URL is: {current_page}") - assert current_page in link_set + assert current_page in LINK_SET