From 80631c53a835f15d52fbff3a92f588ad52b1242a Mon Sep 17 00:00:00 2001 From: kp <175162338+krishpdev@users.noreply.github.com> Date: Mon, 29 Sep 2025 13:55:16 -0400 Subject: [PATCH 1/4] Add test for toggle play/mute/unmute tabs --- .../test_play_mute_unmute_tabs_via_toggle.py | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 tests/tabs/test_play_mute_unmute_tabs_via_toggle.py diff --git a/tests/tabs/test_play_mute_unmute_tabs_via_toggle.py b/tests/tabs/test_play_mute_unmute_tabs_via_toggle.py new file mode 100644 index 000000000..906feb24e --- /dev/null +++ b/tests/tabs/test_play_mute_unmute_tabs_via_toggle.py @@ -0,0 +1,137 @@ +import time + +import pytest +from pynput.mouse import Button, Controller +from selenium.webdriver import Firefox +from selenium.webdriver.common.by import By +from selenium.webdriver.common.keys import Keys +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.support.ui import WebDriverWait + +from modules.browser_object import ContextMenu +from modules.browser_object_tabbar import TabBar +from modules.page_object_generics import GenericPage + + +@pytest.fixture() +def test_case(): + return "246981" + + +@pytest.fixture() +def add_to_prefs_list(): + return [("network.cookie.cookieBehavior", "2")] + + +@pytest.mark.audio +@pytest.mark.headed +def test_play_mute_unmute_tabs_via_toggle(driver: Firefox, sys_platform: str): + """ + C246981 - Verify that play/mute/unmute tabs via toggle audio works + """ + tabs = TabBar(driver) + context_menu = ContextMenu(driver) + mouse = Controller() + wait = WebDriverWait(driver, 10) + + # Open Mozilla's Youtube Page + playlist_url = "https://www.youtube.com/@Mozilla/videos" + playlist_page = GenericPage(driver, url=playlist_url) + playlist_page.open() + driver.maximize_window() + + # Locate and open 2 latest videos in new tabs + video_selector = "ytd-rich-item-renderer a#video-title-link" + video_links = wait.until( + EC.visibility_of_all_elements_located((By.CSS_SELECTOR, video_selector)) + ) + + for i in range(2): + playlist_page.context_click(video_links[i]) + context_menu.click_and_hide_menu("context-menu-open-link-in-tab") + + # Verify correct number of tabs opened + tabs.wait_for_num_tabs(3) + time.sleep(2) + + # Select all tabs via Control/Command click while staying on first tab + modifier_key = Keys.COMMAND if sys_platform == "Darwin" else Keys.CONTROL + + with driver.context(driver.CONTEXT_CHROME): + actions = tabs.actions + + # Hold modifier and select the video tabs + actions.key_down(modifier_key) + for i in range(2, 4): # Select tabs 2 and 3 + tab_to_select = tabs.get_tab(i) + actions.click(tab_to_select) + actions.key_up(modifier_key).perform() + + # Verify tabs are selected (multiselected attribute) + for i in range(2, 4): + tab = tabs.get_tab(i) + assert tab.get_attribute("multiselected") == "true", ( + f"Tab {i} should be multiselected" + ) + + # Helper function to click the multi-tab audio control button + def click_multi_tab_audio_button(): + tab = tabs.get_tab(2) + element_location = tab.location + element_size = tab.size + window_position = driver.get_window_position() + + inner_height = driver.execute_script("return window.innerHeight;") + outer_height = 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 + ) + # Offset to click on the audio control area (left side of tab) + mouse.position = (element_x - 75, element_y) + time.sleep(0.3) # Small delay for mouse positioning + mouse.click(Button.left, 1) + time.sleep(2) # Wait for action to take effect + + # Click Play button + click_multi_tab_audio_button() + + # Verify all selected tabs are playing + for i in [2, 3]: + tabs.expect_tab_sound_status(i, tabs.MEDIA_STATUS.PLAYING) + tab = tabs.get_tab(i) + assert tab.get_attribute("soundplaying") is not None, ( + f"Tab {i} should be playing audio" + ) + + # Click Mute button + click_multi_tab_audio_button() + + # Verify all selected tabs are muted + for i in [2, 3]: + tabs.expect_tab_sound_status(i, tabs.MEDIA_STATUS.MUTED) + tab = tabs.get_tab(i) + assert tab.get_attribute("muted") is not None, f"Tab {i} should be muted" + + # Click Unmute button + click_multi_tab_audio_button() + + # Verify all selected tabs are unmuted and playing again + for i in [2, 3]: + tabs.expect_tab_sound_status(i, tabs.MEDIA_STATUS.PLAYING) + tab = tabs.get_tab(i) + assert tab.get_attribute("soundplaying") is not None, ( + f"Tab {i} should be playing audio after unmute" + ) + assert tab.get_attribute("muted") is None, ( + f"Tab {i} should not be muted after unmute" + ) From e387a35029d69222580d274a4a68039915139224 Mon Sep 17 00:00:00 2001 From: Krish Patel <175162338+krishpdev@users.noreply.github.com> Date: Thu, 23 Oct 2025 16:14:57 -0400 Subject: [PATCH 2/4] Remove window maximization in test setup Removed window maximization before opening video links. --- tests/tabs/test_play_mute_unmute_tabs_via_toggle.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/tabs/test_play_mute_unmute_tabs_via_toggle.py b/tests/tabs/test_play_mute_unmute_tabs_via_toggle.py index 906feb24e..e7653893f 100644 --- a/tests/tabs/test_play_mute_unmute_tabs_via_toggle.py +++ b/tests/tabs/test_play_mute_unmute_tabs_via_toggle.py @@ -38,7 +38,6 @@ def test_play_mute_unmute_tabs_via_toggle(driver: Firefox, sys_platform: str): playlist_url = "https://www.youtube.com/@Mozilla/videos" playlist_page = GenericPage(driver, url=playlist_url) playlist_page.open() - driver.maximize_window() # Locate and open 2 latest videos in new tabs video_selector = "ytd-rich-item-renderer a#video-title-link" From 31b497147d48424f4e8cf0b1340ae760bc6b8d27 Mon Sep 17 00:00:00 2001 From: Tracy Date: Thu, 23 Oct 2025 16:03:41 -0500 Subject: [PATCH 3/4] Update test_play_mute_unmute_tabs_via_toggle.py Disable test on GHA --- .../tabs/test_play_mute_unmute_tabs_via_toggle.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/tabs/test_play_mute_unmute_tabs_via_toggle.py b/tests/tabs/test_play_mute_unmute_tabs_via_toggle.py index e7653893f..f6f576727 100644 --- a/tests/tabs/test_play_mute_unmute_tabs_via_toggle.py +++ b/tests/tabs/test_play_mute_unmute_tabs_via_toggle.py @@ -1,6 +1,8 @@ -import time - import pytest + +from os import environ +from time import sleep + from pynput.mouse import Button, Controller from selenium.webdriver import Firefox from selenium.webdriver.common.by import By @@ -12,6 +14,8 @@ from modules.browser_object_tabbar import TabBar from modules.page_object_generics import GenericPage +GHA = environ.get("GITHUB_ACTIONS") == "true" + @pytest.fixture() def test_case(): @@ -25,6 +29,7 @@ def add_to_prefs_list(): @pytest.mark.audio @pytest.mark.headed +@pytest.mark.skipif(GHA, reason="Test unstable in Github Actions") def test_play_mute_unmute_tabs_via_toggle(driver: Firefox, sys_platform: str): """ C246981 - Verify that play/mute/unmute tabs via toggle audio works @@ -51,7 +56,7 @@ def test_play_mute_unmute_tabs_via_toggle(driver: Firefox, sys_platform: str): # Verify correct number of tabs opened tabs.wait_for_num_tabs(3) - time.sleep(2) + sleep(2) # Select all tabs via Control/Command click while staying on first tab modifier_key = Keys.COMMAND if sys_platform == "Darwin" else Keys.CONTROL @@ -97,9 +102,9 @@ def click_multi_tab_audio_button(): ) # Offset to click on the audio control area (left side of tab) mouse.position = (element_x - 75, element_y) - time.sleep(0.3) # Small delay for mouse positioning + sleep(0.3) # Small delay for mouse positioning mouse.click(Button.left, 1) - time.sleep(2) # Wait for action to take effect + sleep(2) # Wait for action to take effect # Click Play button click_multi_tab_audio_button() From a7cbc8e6a75d940edbe217df90f17e5fe2b0c3af Mon Sep 17 00:00:00 2001 From: Krish Patel <175162338+krishpdev@users.noreply.github.com> Date: Tue, 4 Nov 2025 09:50:47 -0500 Subject: [PATCH 4/4] Add Delay Constants --- tests/tabs/test_play_mute_unmute_tabs_via_toggle.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/tabs/test_play_mute_unmute_tabs_via_toggle.py b/tests/tabs/test_play_mute_unmute_tabs_via_toggle.py index f6f576727..3ed54ec5e 100644 --- a/tests/tabs/test_play_mute_unmute_tabs_via_toggle.py +++ b/tests/tabs/test_play_mute_unmute_tabs_via_toggle.py @@ -38,7 +38,9 @@ def test_play_mute_unmute_tabs_via_toggle(driver: Firefox, sys_platform: str): context_menu = ContextMenu(driver) mouse = Controller() wait = WebDriverWait(driver, 10) - + DELAY = 2 + POSITION_DELAY = 0.3 + # Open Mozilla's Youtube Page playlist_url = "https://www.youtube.com/@Mozilla/videos" playlist_page = GenericPage(driver, url=playlist_url) @@ -56,7 +58,7 @@ def test_play_mute_unmute_tabs_via_toggle(driver: Firefox, sys_platform: str): # Verify correct number of tabs opened tabs.wait_for_num_tabs(3) - sleep(2) + sleep(DELAY) # Select all tabs via Control/Command click while staying on first tab modifier_key = Keys.COMMAND if sys_platform == "Darwin" else Keys.CONTROL @@ -102,9 +104,9 @@ def click_multi_tab_audio_button(): ) # Offset to click on the audio control area (left side of tab) mouse.position = (element_x - 75, element_y) - sleep(0.3) # Small delay for mouse positioning + sleep(POSITION_DELAY) # Small delay for mouse positioning mouse.click(Button.left, 1) - sleep(2) # Wait for action to take effect + sleep(DELAY) # Wait for action to take effect # Click Play button click_multi_tab_audio_button()