Skip to content

Commit d894a6f

Browse files
committed
vs/accept cookies banner2
1 parent 600361e commit d894a6f

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

tests/tabs/test_mute_tabs.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,36 @@
33
import pytest
44
from selenium.webdriver import Firefox
55
from selenium.webdriver.common.by import By
6+
from selenium.common.exceptions import NoSuchElementException, ElementNotInteractableException
67

78
from modules.browser_object import TabBar
89

10+
PLAY_BUTTON_SELECTOR = ".ytp-play-button"
11+
COOKIE_CONSENT_SELECTOR = "button[aria-label^='Accept all'], button[aria-label^='Accept the use']"
912

1013
@pytest.fixture()
1114
def test_case():
1215
return "134719"
1316

14-
1517
GHA = environ.get("GITHUB_ACTIONS") == "true"
1618

17-
1819
@pytest.mark.skipif(GHA, reason="Test unstable in Github Actions")
1920
@pytest.mark.audio
2021
def test_mute_unmute_tab(screenshot, driver: Firefox, video_url: str):
2122
"""C134719, test that tabs can be muted and unmuted"""
2223
tabs = TabBar(driver)
2324
driver.get(video_url)
24-
play_button = driver.find_element(By.CSS_SELECTOR, ".ytp-play-button")
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
32+
33+
play_button = driver.find_element(By.CSS_SELECTOR, PLAY_BUTTON_SELECTOR)
2534
play_button.click()
35+
2636
with driver.context(driver.CONTEXT_CHROME):
2737
tabs.expect_tab_sound_status(1, tabs.MEDIA_STATUS.PLAYING)
2838
tabs.click_tab_mute_button(1)

0 commit comments

Comments
 (0)