Skip to content

Commit ce4837c

Browse files
committed
Disable cookies, via pref list, for this test, instead of looking for a cookie banner.
1 parent d894a6f commit ce4837c

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

tests/tabs/test_mute_tabs.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,42 @@
11
from os import environ
22

33
import pytest
4+
from selenium.common.exceptions import (
5+
ElementNotInteractableException,
6+
NoSuchElementException,
7+
)
48
from selenium.webdriver import Firefox
59
from selenium.webdriver.common.by import By
6-
from selenium.common.exceptions import NoSuchElementException, ElementNotInteractableException
10+
from selenium.webdriver.support import expected_conditions as EC
711

812
from modules.browser_object import TabBar
913

1014
PLAY_BUTTON_SELECTOR = ".ytp-play-button"
11-
COOKIE_CONSENT_SELECTOR = "button[aria-label^='Accept all'], button[aria-label^='Accept the use']"
15+
COOKIE_CONSENT_SELECTOR = (
16+
"button[aria-label^='Accept all'], button[aria-label^='Accept the use']"
17+
)
18+
1219

1320
@pytest.fixture()
1421
def test_case():
1522
return "134719"
1623

24+
25+
@pytest.fixture()
26+
def add_to_prefs_list():
27+
return [("network.cookie.cookieBehavior", "2")]
28+
29+
1730
GHA = environ.get("GITHUB_ACTIONS") == "true"
1831

32+
1933
@pytest.mark.skipif(GHA, reason="Test unstable in Github Actions")
2034
@pytest.mark.audio
2135
def test_mute_unmute_tab(screenshot, driver: Firefox, video_url: str):
2236
"""C134719, test that tabs can be muted and unmuted"""
2337
tabs = TabBar(driver)
2438
driver.get(video_url)
25-
26-
# Dismiss cookie banner if present
27-
try:
28-
consent_button = driver.find_element(By.CSS_SELECTOR, COOKIE_CONSENT_SELECTOR)
29-
consent_button.click()
30-
except (NoSuchElementException, ElementNotInteractableException):
31-
pass # Banner wasn't displayed or not interactable; proceed normally
39+
tabs.expect(EC.title_contains("Top 10"))
3240

3341
play_button = driver.find_element(By.CSS_SELECTOR, PLAY_BUTTON_SELECTOR)
3442
play_button.click()

0 commit comments

Comments
 (0)