From 22568ed69d738627e8fbd7b483a0af8b6fff4183 Mon Sep 17 00:00:00 2001 From: Tracy Date: Thu, 14 Aug 2025 12:25:34 -0500 Subject: [PATCH 1/2] Enable middle click in either context --- modules/page_base.py | 32 +++++++++++++------ ..._open_new_bg_tab_via_mouse_and_keyboard.py | 3 +- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/modules/page_base.py b/modules/page_base.py index db7c9d8e..e1d4fca5 100644 --- a/modules/page_base.py +++ b/modules/page_base.py @@ -11,7 +11,8 @@ from typing import List, Union from pynput.keyboard import Controller, Key -from pynput.mouse import Button, Controller as MouseController +from pynput.mouse import Button +from pynput.mouse import Controller as MouseController from pypom import Page from selenium.common import NoAlertPresentException from selenium.common.exceptions import ( @@ -564,7 +565,9 @@ def triple_click(self, reference: Union[str, tuple, WebElement], labels=[]) -> P """Actions helper: perform triple-click on a given element""" return self.multi_click(3, reference, labels) - def control_click(self, reference: Union[str, tuple, WebElement], labels=[]) -> Page: + def control_click( + self, reference: Union[str, tuple, WebElement], labels=[] + ) -> Page: """Actions helper: perform control-click on given element""" element = self.fetch(reference, labels) if self.sys_platform() == "Darwin": @@ -574,10 +577,9 @@ def control_click(self, reference: Union[str, tuple, WebElement], labels=[]) -> self.actions.key_down(mod_key).click(element).key_up(mod_key).perform() return self - def middle_click(self, reference: Union[str, tuple, WebElement], labels =[]): - """Perform a middle mouse click on desired element""" - with self.driver.context(self.driver.CONTEXT_CONTENT): - self.driver.maximize_window() + def middle_click(self, reference: Union[str, tuple, WebElement], labels=[]): + """Actions helper: Perform a middle mouse click on desired element""" + with self.driver.context(self.context_id): mouse = MouseController() element = self.fetch(reference, labels) @@ -589,14 +591,24 @@ def middle_click(self, reference: Union[str, tuple, WebElement], labels =[]): outer_height = self.driver.execute_script("return window.outerHeight;") chrome_height = outer_height - inner_height - element_x = window_position['x'] + element_location['x'] + (element_size['width'] / 2) - element_y = window_position['y'] + element_location['y'] + (element_size['height'] / 2) + chrome_height + element_x = ( + window_position["x"] + + element_location["x"] + + (element_size["width"] / 2) + ) + element_y = ( + window_position["y"] + + element_location["y"] + + (element_size["height"] / 2) + + chrome_height + ) mouse.position = (element_x, element_y) - time.sleep(1) + # Need a short wait to ensure the mouse move completes, then middle click + time.sleep(0.5) mouse.click(Button.middle, 1) return self - + def context_click( self, reference: Union[str, tuple, WebElement], labels=[] ) -> Page: 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 ad432a0c..6f736904 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 @@ -17,7 +17,8 @@ def test_open_new_bg_tab_via_mouse_and_keyboard(driver: Firefox): """ test_url = "https://www.iana.org/help/example-domains" - example = ExamplePage(driver).open() + example = ExamplePage(driver) + example.open() # Middle click link, verify new background tab opens with correct URL example.middle_click("more-information") From af5ae3f72275571bd0bab8de73810c5b7a23427f Mon Sep 17 00:00:00 2001 From: Tracy Date: Fri, 15 Aug 2025 09:41:19 -0500 Subject: [PATCH 2/2] Skip failing test on Linux --- ...bextension_completed_installation_successfully_displayed.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/notifications/test_webextension_completed_installation_successfully_displayed.py b/tests/notifications/test_webextension_completed_installation_successfully_displayed.py index 518695f5..c98822ec 100644 --- a/tests/notifications/test_webextension_completed_installation_successfully_displayed.py +++ b/tests/notifications/test_webextension_completed_installation_successfully_displayed.py @@ -1,3 +1,5 @@ +from platform import system + import pytest from selenium.webdriver import Firefox @@ -24,6 +26,7 @@ def temp_selectors(): TEST_URL = "https://addons.mozilla.org/en-US/firefox/addon/popup-blocker/" +@pytest.mark.skipif(system().lower().startswith("linux"), reason="Bug 1983280") def test_webextension_completed_installation_successfully_displayed( driver: Firefox, temp_selectors ):