From 579e7bf82c9ce7ed3444f6f3fb5b6b0154f1fdb7 Mon Sep 17 00:00:00 2001 From: Sangie Date: Tue, 19 Aug 2025 21:20:01 -0400 Subject: [PATCH 1/9] test 1976523 passed locally --- Pipfile | 2 +- modules/browser_object_navigation.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Pipfile b/Pipfile index 94087ec5b..a2c46914a 100644 --- a/Pipfile +++ b/Pipfile @@ -11,7 +11,6 @@ pytest = "<8.4" pytest-httpserver = "1.0.12" requests = "<3.0" pytest-xdist = "3.6.1" -pytest-html = "4.1.1" pypom = "2.2.4" taskcluster-taskgraph = "==9.0.0" jsonpath-ng = "1.6.1" @@ -25,6 +24,7 @@ google-auth = "2.32.0" psutil = "<6.1" pytest-json-report = "==1.5.0" beautifulsoup4 = "4.12.3" +pytest-html = "*" [dev-packages] werkzeug = "==3.0.3" diff --git a/modules/browser_object_navigation.py b/modules/browser_object_navigation.py index ad0c64467..b8194a7d5 100644 --- a/modules/browser_object_navigation.py +++ b/modules/browser_object_navigation.py @@ -597,10 +597,17 @@ def open_bookmark_in_new_tab_via_context_menu( Argument: bookmark_title: The title of the bookmark to open """ - # Right-click the bookmark and open it in new tabe via context menu item + # Right-click the bookmark to make the menu appear self.panel_ui.element_clickable("bookmark-by-title", labels=[bookmark_title]) self.panel_ui.context_click("bookmark-by-title", labels=[bookmark_title]) - self.context_menu.click_on("context-menu-toolbar-open-in-new-tab") + + # Find the menu item we want to click + # We use .fetch() here to get the element without clicking it yet + menu_item = self.context_menu.fetch("context-menu-toolbar-open-in-new-tab") + + # Use ActionChains to perform a more reliable click + actions = ActionChains(self.driver) + actions.move_to_element(menu_item).click().perform() return self From c9c437b09c97ec32bd97831e417836c3ab906c18 Mon Sep 17 00:00:00 2001 From: Sangie Date: Wed, 20 Aug 2025 17:39:43 -0400 Subject: [PATCH 2/9] test 1976523 passed with project's latest main merged --- Pipfile | 2 +- l10n_CM/run_l10n.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Pipfile b/Pipfile index a2c46914a..94087ec5b 100644 --- a/Pipfile +++ b/Pipfile @@ -11,6 +11,7 @@ pytest = "<8.4" pytest-httpserver = "1.0.12" requests = "<3.0" pytest-xdist = "3.6.1" +pytest-html = "4.1.1" pypom = "2.2.4" taskcluster-taskgraph = "==9.0.0" jsonpath-ng = "1.6.1" @@ -24,7 +25,6 @@ google-auth = "2.32.0" psutil = "<6.1" pytest-json-report = "==1.5.0" beautifulsoup4 = "4.12.3" -pytest-html = "*" [dev-packages] werkzeug = "==3.0.3" diff --git a/l10n_CM/run_l10n.py b/l10n_CM/run_l10n.py index ad4ab8afa..82973acc8 100644 --- a/l10n_CM/run_l10n.py +++ b/l10n_CM/run_l10n.py @@ -98,6 +98,13 @@ "zalando", "zara", "zooplus", + "zara", + "cocolita", + "torfs", + "standaardboekhandel", + "douglas", + "brico", + "toychamp", } loaded_valid_sites = valid_l10n_mappings().keys() From ea65735cc9d540c4e951bd2bd9b325b0610fffc3 Mon Sep 17 00:00:00 2001 From: Sangie Date: Tue, 30 Sep 2025 16:11:42 -0400 Subject: [PATCH 3/9] local changes before merging --- modules/page_base.py | 16 ++++ .../test_change_position_of_pinned_tabs.py | 83 +++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 tests/tabs/test_change_position_of_pinned_tabs.py diff --git a/modules/page_base.py b/modules/page_base.py index e1d4fca55..c231c9522 100644 --- a/modules/page_base.py +++ b/modules/page_base.py @@ -305,6 +305,22 @@ def get_element( cache_name = f"{name}{labelscode}" if cache_name not in self.elements: self.elements[cache_name] = deepcopy(self.elements[name]) + # FIX: Check for doNotCache BEFORE trying to use cached elements + if ( + not multiple + and "doNotCache" + not in self.elements[cache_name]["groups"] # ADD THIS CHECK + and "seleniumObject" in self.elements[cache_name] + ): + # no caching for multiples + cached_element = self.elements[cache_name]["seleniumObject"] + try: + self.instawait.until_not(EC.staleness_of(cached_element)) + logging.info(f"Returned {cache_name} from object cache!") + return self.elements[cache_name]["seleniumObject"] + except (TimeoutError, TimeoutException): + # Because we have a timeout of 0, this should not cause delays + pass if multiple: logging.info(f"Multiples: Not caching {cache_name}...") if not multiple and "seleniumObject" in self.elements[cache_name]: diff --git a/tests/tabs/test_change_position_of_pinned_tabs.py b/tests/tabs/test_change_position_of_pinned_tabs.py new file mode 100644 index 000000000..b830d862b --- /dev/null +++ b/tests/tabs/test_change_position_of_pinned_tabs.py @@ -0,0 +1,83 @@ +import logging +import time + +import pytest +from selenium.webdriver import Firefox +from selenium.webdriver.common.action_chains import ActionChains +from selenium.webdriver.common.by import By + +from modules.browser_object import ContextMenu, Navigation, TabBar + + +@pytest.fixture() +def test_case(): + return "134723" + + +def test_change_position_of_pinned_tabs(driver: Firefox): + tabs = TabBar(driver) + nav = Navigation(driver) + tabs_context_menu = ContextMenu(driver) + num_tabs = 5 + + tab_titles = [] + url_list = [ + "https://www.google.com", + "https://www.youtube.com", + "https://www.mozilla.org", + "https://www.wikipedia.org", + "https://www.github.com", + ] + + driver.get(url_list[0]) + tab_titles.append(driver.title) + + # Open 5 tabs + for i in range(1, len(url_list)): + tabs.new_tab_by_button() + driver.switch_to.window(driver.window_handles[-1]) + driver.get(url_list[i]) + tab_titles.append(driver.title) + time.sleep(2) + + # specific tabs we want to work with + google_title = tab_titles[0] + mozilla_title = tab_titles[2] + + # Pin the 'Google' tab by its title + driver.switch_to.window(driver.window_handles[0]) + google_tab = tabs.get_tab(google_title) + assert google_tab is not None, "Google tab should exist" + tabs.context_click(google_tab) + tabs_context_menu.click_context_item("context-menu-pin-tab") + time.sleep(1) + + # FIX: Re-initialize the context menu object after the DOM has changed. + # FIX: Force a "context reset" by switching to a neutral tab. + driver.switch_to.window(driver.window_handles[1]) # Switch to YouTube + time.sleep(0.5) # A brief pause to ensure the context switch completes + tabs_context_menu = ContextMenu(driver) + + # Pin the 'Mozilla' tab by its title + driver.switch_to.window(driver.window_handles[2]) + mozilla_tab = tabs.get_tab(mozilla_title) + assert mozilla_tab is not None, "Mozilla tab should exist" + tabs.context_click(mozilla_tab) + tabs_context_menu.click_context_item("context-menu-pin-tab") + time.sleep(1) + + driver.switch_to.window(driver.window_handles[0]) + pinned_tab_one = tabs.get_tab(google_title) + assert tabs.is_pinned(pinned_tab_one) + + # ERROR + # pinned_tab_two = tabs.get_tab(mozilla_title) + # assert tabs.is_pinned(pinned_tab_two) + + # -----------------------after pinned error is fixed ------------------------------------ + # actions = ActionChains(driver) + # # A more robust, manual way to perform a drag-and-drop + # actions.drag_and_drop(pinned_tab_one, pinned_tab_two).perform() + + # assert tab_titles[0] in new_pinned_tab_one.text, "Google should now be the first pinned tab" + # assert tab_titles[2] in new_pinned_tab_two.text, "Mozilla should now be the second pinned tab" From c518a7a734a8ef37de91bd8e7ccbb0a5e1963a22 Mon Sep 17 00:00:00 2001 From: Tracy Date: Thu, 2 Oct 2025 11:32:25 -0500 Subject: [PATCH 4/9] Rework broken portions of the test --- modules/data/context_menu.components.json | 6 ++ .../test_change_position_of_pinned_tabs.py | 81 ++++++++----------- 2 files changed, 40 insertions(+), 47 deletions(-) diff --git a/modules/data/context_menu.components.json b/modules/data/context_menu.components.json index e8847b47d..e9afb106e 100644 --- a/modules/data/context_menu.components.json +++ b/modules/data/context_menu.components.json @@ -109,6 +109,12 @@ "groups": [] }, + "context-menu-move-tab-to-start": { + "selectorData": "menuitem[data-l10n-id='move-to-start']", + "strategy": "css", + "groups": [] + }, + "context-menu-open-link-in-tab": { "selectorData": "context-openlinkintab", "strategy": "id", diff --git a/tests/tabs/test_change_position_of_pinned_tabs.py b/tests/tabs/test_change_position_of_pinned_tabs.py index b830d862b..d3404a14c 100644 --- a/tests/tabs/test_change_position_of_pinned_tabs.py +++ b/tests/tabs/test_change_position_of_pinned_tabs.py @@ -1,12 +1,9 @@ import logging -import time import pytest from selenium.webdriver import Firefox -from selenium.webdriver.common.action_chains import ActionChains -from selenium.webdriver.common.by import By -from modules.browser_object import ContextMenu, Navigation, TabBar +from modules.browser_object import ContextMenu, TabBar @pytest.fixture() @@ -16,68 +13,58 @@ def test_case(): def test_change_position_of_pinned_tabs(driver: Firefox): tabs = TabBar(driver) - nav = Navigation(driver) - tabs_context_menu = ContextMenu(driver) - num_tabs = 5 + tab_context_menu = ContextMenu(driver) tab_titles = [] - url_list = [ - "https://www.google.com", - "https://www.youtube.com", - "https://www.mozilla.org", - "https://www.wikipedia.org", - "https://www.github.com", - ] + url_list = ["about:logo", "about:robots", "https://mozilla.org"] driver.get(url_list[0]) tab_titles.append(driver.title) - # Open 5 tabs + # Open 3 tabs for i in range(1, len(url_list)): tabs.new_tab_by_button() driver.switch_to.window(driver.window_handles[-1]) driver.get(url_list[i]) tab_titles.append(driver.title) - time.sleep(2) - # specific tabs we want to work with - google_title = tab_titles[0] + # Specific tabs we want to work with + robot_title = tab_titles[1] mozilla_title = tab_titles[2] - # Pin the 'Google' tab by its title + # Pin the 'Robots' tab by its title driver.switch_to.window(driver.window_handles[0]) - google_tab = tabs.get_tab(google_title) - assert google_tab is not None, "Google tab should exist" - tabs.context_click(google_tab) - tabs_context_menu.click_context_item("context-menu-pin-tab") - time.sleep(1) - - # FIX: Re-initialize the context menu object after the DOM has changed. - # FIX: Force a "context reset" by switching to a neutral tab. - driver.switch_to.window(driver.window_handles[1]) # Switch to YouTube - time.sleep(0.5) # A brief pause to ensure the context switch completes - tabs_context_menu = ContextMenu(driver) + robot_tab = tabs.get_tab(robot_title) + assert robot_tab is not None, "Robot tab should exist" + tabs.context_click(robot_tab) + tab_context_menu.click_and_hide_menu("context-menu-pin-tab") + pinned_tab_one = tabs.get_tab(robot_title) + assert tabs.is_pinned(pinned_tab_one) # Pin the 'Mozilla' tab by its title - driver.switch_to.window(driver.window_handles[2]) mozilla_tab = tabs.get_tab(mozilla_title) assert mozilla_tab is not None, "Mozilla tab should exist" tabs.context_click(mozilla_tab) - tabs_context_menu.click_context_item("context-menu-pin-tab") - time.sleep(1) - - driver.switch_to.window(driver.window_handles[0]) - pinned_tab_one = tabs.get_tab(google_title) - assert tabs.is_pinned(pinned_tab_one) - - # ERROR - # pinned_tab_two = tabs.get_tab(mozilla_title) - # assert tabs.is_pinned(pinned_tab_two) + tab_context_menu.click_and_hide_menu("context-menu-pin-tab") + pinned_tab_two = tabs.get_tab(mozilla_title) + assert tabs.is_pinned(pinned_tab_two) - # -----------------------after pinned error is fixed ------------------------------------ - # actions = ActionChains(driver) - # # A more robust, manual way to perform a drag-and-drop - # actions.drag_and_drop(pinned_tab_one, pinned_tab_two).perform() + # Move second pinned tab to the left + tabs.context_click(pinned_tab_two) + tab_context_menu.click_and_hide_menu("context-menu-move-tab-to-start") - # assert tab_titles[0] in new_pinned_tab_one.text, "Google should now be the first pinned tab" - # assert tab_titles[2] in new_pinned_tab_two.text, "Mozilla should now be the second pinned tab" + # Get the titles for each of the rearranged pinned tabs + driver.switch_to.window(driver.window_handles[0]) + new_pinned_tab_one_title = driver.title + logging.info("Tab title: %s", new_pinned_tab_one_title) + + driver.switch_to.window(driver.window_handles[1]) + new_pinned_tab_two_title = driver.title + logging.info("Tab title: %s", new_pinned_tab_two_title) + + assert "Mozilla" in new_pinned_tab_one_title, ( + "Mozilla should now be the first pinned tab" + ) + assert "Gort!" in new_pinned_tab_two_title, ( + "Robot should now be the second pinned tab" + ) From 5f58000587d48fe0931e7d168e705c3e8100b89d Mon Sep 17 00:00:00 2001 From: Sangie Date: Tue, 19 Aug 2025 21:20:01 -0400 Subject: [PATCH 5/9] test 1976523 passed locally --- Pipfile | 2 +- modules/browser_object_navigation.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Pipfile b/Pipfile index 94087ec5b..a2c46914a 100644 --- a/Pipfile +++ b/Pipfile @@ -11,7 +11,6 @@ pytest = "<8.4" pytest-httpserver = "1.0.12" requests = "<3.0" pytest-xdist = "3.6.1" -pytest-html = "4.1.1" pypom = "2.2.4" taskcluster-taskgraph = "==9.0.0" jsonpath-ng = "1.6.1" @@ -25,6 +24,7 @@ google-auth = "2.32.0" psutil = "<6.1" pytest-json-report = "==1.5.0" beautifulsoup4 = "4.12.3" +pytest-html = "*" [dev-packages] werkzeug = "==3.0.3" diff --git a/modules/browser_object_navigation.py b/modules/browser_object_navigation.py index b64aad288..ea8201cc7 100644 --- a/modules/browser_object_navigation.py +++ b/modules/browser_object_navigation.py @@ -598,10 +598,17 @@ def open_bookmark_in_new_tab_via_context_menu( Argument: bookmark_title: The title of the bookmark to open """ - # Right-click the bookmark and open it in new tabe via context menu item + # Right-click the bookmark to make the menu appear self.panel_ui.element_clickable("bookmark-by-title", labels=[bookmark_title]) self.panel_ui.context_click("bookmark-by-title", labels=[bookmark_title]) - self.context_menu.click_on("context-menu-toolbar-open-in-new-tab") + + # Find the menu item we want to click + # We use .fetch() here to get the element without clicking it yet + menu_item = self.context_menu.fetch("context-menu-toolbar-open-in-new-tab") + + # Use ActionChains to perform a more reliable click + actions = ActionChains(self.driver) + actions.move_to_element(menu_item).click().perform() return self From 0ffeefd62177a1d3156ff4345f1d9cd2eebb6f33 Mon Sep 17 00:00:00 2001 From: Sangie Date: Wed, 20 Aug 2025 17:39:43 -0400 Subject: [PATCH 6/9] test 1976523 passed with project's latest main merged --- Pipfile | 2 +- l10n_CM/run_l10n.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Pipfile b/Pipfile index a2c46914a..94087ec5b 100644 --- a/Pipfile +++ b/Pipfile @@ -11,6 +11,7 @@ pytest = "<8.4" pytest-httpserver = "1.0.12" requests = "<3.0" pytest-xdist = "3.6.1" +pytest-html = "4.1.1" pypom = "2.2.4" taskcluster-taskgraph = "==9.0.0" jsonpath-ng = "1.6.1" @@ -24,7 +25,6 @@ google-auth = "2.32.0" psutil = "<6.1" pytest-json-report = "==1.5.0" beautifulsoup4 = "4.12.3" -pytest-html = "*" [dev-packages] werkzeug = "==3.0.3" diff --git a/l10n_CM/run_l10n.py b/l10n_CM/run_l10n.py index ad4ab8afa..82973acc8 100644 --- a/l10n_CM/run_l10n.py +++ b/l10n_CM/run_l10n.py @@ -98,6 +98,13 @@ "zalando", "zara", "zooplus", + "zara", + "cocolita", + "torfs", + "standaardboekhandel", + "douglas", + "brico", + "toychamp", } loaded_valid_sites = valid_l10n_mappings().keys() From 55add345d6e3b96ccf4adedd17881613561f9368 Mon Sep 17 00:00:00 2001 From: Sangie Date: Tue, 30 Sep 2025 16:11:42 -0400 Subject: [PATCH 7/9] local changes before merging --- modules/page_base.py | 16 ++++ .../test_change_position_of_pinned_tabs.py | 83 +++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 tests/tabs/test_change_position_of_pinned_tabs.py diff --git a/modules/page_base.py b/modules/page_base.py index e1d4fca55..c231c9522 100644 --- a/modules/page_base.py +++ b/modules/page_base.py @@ -305,6 +305,22 @@ def get_element( cache_name = f"{name}{labelscode}" if cache_name not in self.elements: self.elements[cache_name] = deepcopy(self.elements[name]) + # FIX: Check for doNotCache BEFORE trying to use cached elements + if ( + not multiple + and "doNotCache" + not in self.elements[cache_name]["groups"] # ADD THIS CHECK + and "seleniumObject" in self.elements[cache_name] + ): + # no caching for multiples + cached_element = self.elements[cache_name]["seleniumObject"] + try: + self.instawait.until_not(EC.staleness_of(cached_element)) + logging.info(f"Returned {cache_name} from object cache!") + return self.elements[cache_name]["seleniumObject"] + except (TimeoutError, TimeoutException): + # Because we have a timeout of 0, this should not cause delays + pass if multiple: logging.info(f"Multiples: Not caching {cache_name}...") if not multiple and "seleniumObject" in self.elements[cache_name]: diff --git a/tests/tabs/test_change_position_of_pinned_tabs.py b/tests/tabs/test_change_position_of_pinned_tabs.py new file mode 100644 index 000000000..b830d862b --- /dev/null +++ b/tests/tabs/test_change_position_of_pinned_tabs.py @@ -0,0 +1,83 @@ +import logging +import time + +import pytest +from selenium.webdriver import Firefox +from selenium.webdriver.common.action_chains import ActionChains +from selenium.webdriver.common.by import By + +from modules.browser_object import ContextMenu, Navigation, TabBar + + +@pytest.fixture() +def test_case(): + return "134723" + + +def test_change_position_of_pinned_tabs(driver: Firefox): + tabs = TabBar(driver) + nav = Navigation(driver) + tabs_context_menu = ContextMenu(driver) + num_tabs = 5 + + tab_titles = [] + url_list = [ + "https://www.google.com", + "https://www.youtube.com", + "https://www.mozilla.org", + "https://www.wikipedia.org", + "https://www.github.com", + ] + + driver.get(url_list[0]) + tab_titles.append(driver.title) + + # Open 5 tabs + for i in range(1, len(url_list)): + tabs.new_tab_by_button() + driver.switch_to.window(driver.window_handles[-1]) + driver.get(url_list[i]) + tab_titles.append(driver.title) + time.sleep(2) + + # specific tabs we want to work with + google_title = tab_titles[0] + mozilla_title = tab_titles[2] + + # Pin the 'Google' tab by its title + driver.switch_to.window(driver.window_handles[0]) + google_tab = tabs.get_tab(google_title) + assert google_tab is not None, "Google tab should exist" + tabs.context_click(google_tab) + tabs_context_menu.click_context_item("context-menu-pin-tab") + time.sleep(1) + + # FIX: Re-initialize the context menu object after the DOM has changed. + # FIX: Force a "context reset" by switching to a neutral tab. + driver.switch_to.window(driver.window_handles[1]) # Switch to YouTube + time.sleep(0.5) # A brief pause to ensure the context switch completes + tabs_context_menu = ContextMenu(driver) + + # Pin the 'Mozilla' tab by its title + driver.switch_to.window(driver.window_handles[2]) + mozilla_tab = tabs.get_tab(mozilla_title) + assert mozilla_tab is not None, "Mozilla tab should exist" + tabs.context_click(mozilla_tab) + tabs_context_menu.click_context_item("context-menu-pin-tab") + time.sleep(1) + + driver.switch_to.window(driver.window_handles[0]) + pinned_tab_one = tabs.get_tab(google_title) + assert tabs.is_pinned(pinned_tab_one) + + # ERROR + # pinned_tab_two = tabs.get_tab(mozilla_title) + # assert tabs.is_pinned(pinned_tab_two) + + # -----------------------after pinned error is fixed ------------------------------------ + # actions = ActionChains(driver) + # # A more robust, manual way to perform a drag-and-drop + # actions.drag_and_drop(pinned_tab_one, pinned_tab_two).perform() + + # assert tab_titles[0] in new_pinned_tab_one.text, "Google should now be the first pinned tab" + # assert tab_titles[2] in new_pinned_tab_two.text, "Mozilla should now be the second pinned tab" From 501be9323b6d91cba0e48d581be67c52788bdd49 Mon Sep 17 00:00:00 2001 From: Tracy Date: Thu, 2 Oct 2025 11:32:25 -0500 Subject: [PATCH 8/9] Rework broken portions of the test --- modules/data/context_menu.components.json | 6 ++ .../test_change_position_of_pinned_tabs.py | 81 ++++++++----------- 2 files changed, 40 insertions(+), 47 deletions(-) diff --git a/modules/data/context_menu.components.json b/modules/data/context_menu.components.json index e8847b47d..e9afb106e 100644 --- a/modules/data/context_menu.components.json +++ b/modules/data/context_menu.components.json @@ -109,6 +109,12 @@ "groups": [] }, + "context-menu-move-tab-to-start": { + "selectorData": "menuitem[data-l10n-id='move-to-start']", + "strategy": "css", + "groups": [] + }, + "context-menu-open-link-in-tab": { "selectorData": "context-openlinkintab", "strategy": "id", diff --git a/tests/tabs/test_change_position_of_pinned_tabs.py b/tests/tabs/test_change_position_of_pinned_tabs.py index b830d862b..d3404a14c 100644 --- a/tests/tabs/test_change_position_of_pinned_tabs.py +++ b/tests/tabs/test_change_position_of_pinned_tabs.py @@ -1,12 +1,9 @@ import logging -import time import pytest from selenium.webdriver import Firefox -from selenium.webdriver.common.action_chains import ActionChains -from selenium.webdriver.common.by import By -from modules.browser_object import ContextMenu, Navigation, TabBar +from modules.browser_object import ContextMenu, TabBar @pytest.fixture() @@ -16,68 +13,58 @@ def test_case(): def test_change_position_of_pinned_tabs(driver: Firefox): tabs = TabBar(driver) - nav = Navigation(driver) - tabs_context_menu = ContextMenu(driver) - num_tabs = 5 + tab_context_menu = ContextMenu(driver) tab_titles = [] - url_list = [ - "https://www.google.com", - "https://www.youtube.com", - "https://www.mozilla.org", - "https://www.wikipedia.org", - "https://www.github.com", - ] + url_list = ["about:logo", "about:robots", "https://mozilla.org"] driver.get(url_list[0]) tab_titles.append(driver.title) - # Open 5 tabs + # Open 3 tabs for i in range(1, len(url_list)): tabs.new_tab_by_button() driver.switch_to.window(driver.window_handles[-1]) driver.get(url_list[i]) tab_titles.append(driver.title) - time.sleep(2) - # specific tabs we want to work with - google_title = tab_titles[0] + # Specific tabs we want to work with + robot_title = tab_titles[1] mozilla_title = tab_titles[2] - # Pin the 'Google' tab by its title + # Pin the 'Robots' tab by its title driver.switch_to.window(driver.window_handles[0]) - google_tab = tabs.get_tab(google_title) - assert google_tab is not None, "Google tab should exist" - tabs.context_click(google_tab) - tabs_context_menu.click_context_item("context-menu-pin-tab") - time.sleep(1) - - # FIX: Re-initialize the context menu object after the DOM has changed. - # FIX: Force a "context reset" by switching to a neutral tab. - driver.switch_to.window(driver.window_handles[1]) # Switch to YouTube - time.sleep(0.5) # A brief pause to ensure the context switch completes - tabs_context_menu = ContextMenu(driver) + robot_tab = tabs.get_tab(robot_title) + assert robot_tab is not None, "Robot tab should exist" + tabs.context_click(robot_tab) + tab_context_menu.click_and_hide_menu("context-menu-pin-tab") + pinned_tab_one = tabs.get_tab(robot_title) + assert tabs.is_pinned(pinned_tab_one) # Pin the 'Mozilla' tab by its title - driver.switch_to.window(driver.window_handles[2]) mozilla_tab = tabs.get_tab(mozilla_title) assert mozilla_tab is not None, "Mozilla tab should exist" tabs.context_click(mozilla_tab) - tabs_context_menu.click_context_item("context-menu-pin-tab") - time.sleep(1) - - driver.switch_to.window(driver.window_handles[0]) - pinned_tab_one = tabs.get_tab(google_title) - assert tabs.is_pinned(pinned_tab_one) - - # ERROR - # pinned_tab_two = tabs.get_tab(mozilla_title) - # assert tabs.is_pinned(pinned_tab_two) + tab_context_menu.click_and_hide_menu("context-menu-pin-tab") + pinned_tab_two = tabs.get_tab(mozilla_title) + assert tabs.is_pinned(pinned_tab_two) - # -----------------------after pinned error is fixed ------------------------------------ - # actions = ActionChains(driver) - # # A more robust, manual way to perform a drag-and-drop - # actions.drag_and_drop(pinned_tab_one, pinned_tab_two).perform() + # Move second pinned tab to the left + tabs.context_click(pinned_tab_two) + tab_context_menu.click_and_hide_menu("context-menu-move-tab-to-start") - # assert tab_titles[0] in new_pinned_tab_one.text, "Google should now be the first pinned tab" - # assert tab_titles[2] in new_pinned_tab_two.text, "Mozilla should now be the second pinned tab" + # Get the titles for each of the rearranged pinned tabs + driver.switch_to.window(driver.window_handles[0]) + new_pinned_tab_one_title = driver.title + logging.info("Tab title: %s", new_pinned_tab_one_title) + + driver.switch_to.window(driver.window_handles[1]) + new_pinned_tab_two_title = driver.title + logging.info("Tab title: %s", new_pinned_tab_two_title) + + assert "Mozilla" in new_pinned_tab_one_title, ( + "Mozilla should now be the first pinned tab" + ) + assert "Gort!" in new_pinned_tab_two_title, ( + "Robot should now be the second pinned tab" + ) From a51c27457cfaf237320f6652ca3629b155464fa7 Mon Sep 17 00:00:00 2001 From: Tracy Date: Thu, 2 Oct 2025 11:37:49 -0500 Subject: [PATCH 9/9] Add hide popup --- tests/tabs/test_change_position_of_pinned_tabs.py | 2 ++ .../test_customize_themes_and_redirect.py | 11 ++++++----- .../theme_and_toolbar/test_installed_theme_enabled.py | 8 ++++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/tabs/test_change_position_of_pinned_tabs.py b/tests/tabs/test_change_position_of_pinned_tabs.py index d3404a14c..2cee4b48a 100644 --- a/tests/tabs/test_change_position_of_pinned_tabs.py +++ b/tests/tabs/test_change_position_of_pinned_tabs.py @@ -52,6 +52,8 @@ def test_change_position_of_pinned_tabs(driver: Firefox): # Move second pinned tab to the left tabs.context_click(pinned_tab_two) tab_context_menu.click_and_hide_menu("context-menu-move-tab-to-start") + # Click-and-hide doesn't hide the parent popup + tabs.hide_popup("tabContextMenu") # Get the titles for each of the rearranged pinned tabs driver.switch_to.window(driver.window_handles[0]) diff --git a/tests/theme_and_toolbar/test_customize_themes_and_redirect.py b/tests/theme_and_toolbar/test_customize_themes_and_redirect.py index 4512faba6..a732c01ad 100644 --- a/tests/theme_and_toolbar/test_customize_themes_and_redirect.py +++ b/tests/theme_and_toolbar/test_customize_themes_and_redirect.py @@ -1,5 +1,6 @@ import pytest from selenium.webdriver import Firefox + from modules.browser_object import Navigation, PanelUi from modules.page_object import AboutAddons @@ -11,7 +12,7 @@ def test_case(): THEMES: dict[str, list[str]] = { "firefox-compact-dark_mozilla_org-heading": [ - "rgb(43, 42, 51)", # classic darker tone + "rgb(43, 42, 51)", # classic darker tone "rgb(143, 143, 148)", # focused dark "rgb(120, 119, 126)", # dark without focus ], @@ -82,7 +83,9 @@ def test_redirect_to_addons(driver: Firefox) -> None: @pytest.mark.parametrize("theme_name", list(THEMES.keys())) -def test_activate_theme_background_matches_expected(driver: Firefox, theme_name: str) -> None: +def test_activate_theme_background_matches_expected( + driver: Firefox, theme_name: str +) -> None: """ C118173: Ensure that activating each theme in about:addons applies the expected background color. Handles Developer Edition vs standard Firefox defaults. @@ -100,9 +103,7 @@ def test_activate_theme_background_matches_expected(driver: Firefox, theme_name: if theme_name == "firefox-compact-light_mozilla_org-heading": pytest.skip("Compact Light is default on Firefox, skipping.") - current_bg = abt_addons.activate_theme( - nav, theme_name, "", perform_assert=False - ) + current_bg = abt_addons.activate_theme(nav, theme_name, "", perform_assert=False) expected_list = THEMES[theme_name] assert any(colors_match(current_bg, exp) for exp in expected_list), ( diff --git a/tests/theme_and_toolbar/test_installed_theme_enabled.py b/tests/theme_and_toolbar/test_installed_theme_enabled.py index 3116b59df..ec39cc802 100644 --- a/tests/theme_and_toolbar/test_installed_theme_enabled.py +++ b/tests/theme_and_toolbar/test_installed_theme_enabled.py @@ -12,7 +12,9 @@ def test_case(): return "118174" -MAC_GHA: bool = environ.get("GITHUB_ACTIONS") == "true" and sys.platform.startswith("darwin") +MAC_GHA: bool = environ.get("GITHUB_ACTIONS") == "true" and sys.platform.startswith( + "darwin" +) AMO_HOST: str = "addons.mozilla.org" AMO_THEMES_PATH: str = "firefox/themes" @@ -44,7 +46,9 @@ def test_installed_theme_enabled(driver: Firefox) -> None: about_addons.choose_sidebar_option("theme") # Capture currently enabled theme title - starting_theme = about_addons.get_element("enabled-theme-title").get_attribute("innerText") + starting_theme = about_addons.get_element("enabled-theme-title").get_attribute( + "innerText" + ) # Go to AMO and install a recommended theme (POM encapsulates waits and flows) AmoThemes(driver).open().install_recommended_theme()