|
1 | 1 | from os import environ
|
2 | 2 |
|
3 | 3 | import pytest
|
| 4 | +from selenium.common.exceptions import ( |
| 5 | + ElementNotInteractableException, |
| 6 | + NoSuchElementException, |
| 7 | +) |
4 | 8 | from selenium.webdriver import Firefox
|
5 | 9 | 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 |
7 | 11 |
|
8 | 12 | from modules.browser_object import TabBar
|
9 | 13 |
|
10 | 14 | 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 | + |
12 | 19 |
|
13 | 20 | @pytest.fixture()
|
14 | 21 | def test_case():
|
15 | 22 | return "134719"
|
16 | 23 |
|
| 24 | + |
| 25 | +@pytest.fixture() |
| 26 | +def add_to_prefs_list(): |
| 27 | + return [("network.cookie.cookieBehavior", "2")] |
| 28 | + |
| 29 | + |
17 | 30 | GHA = environ.get("GITHUB_ACTIONS") == "true"
|
18 | 31 |
|
| 32 | + |
19 | 33 | @pytest.mark.skipif(GHA, reason="Test unstable in Github Actions")
|
20 | 34 | @pytest.mark.audio
|
21 | 35 | def test_mute_unmute_tab(screenshot, driver: Firefox, video_url: str):
|
22 | 36 | """C134719, test that tabs can be muted and unmuted"""
|
23 | 37 | tabs = TabBar(driver)
|
24 | 38 | 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")) |
32 | 40 |
|
33 | 41 | play_button = driver.find_element(By.CSS_SELECTOR, PLAY_BUTTON_SELECTOR)
|
34 | 42 | play_button.click()
|
|
0 commit comments