File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 3
3
import pytest
4
4
from selenium .webdriver import Firefox
5
5
from selenium .webdriver .common .by import By
6
+ from selenium .common .exceptions import NoSuchElementException , ElementNotInteractableException
6
7
7
8
from modules .browser_object import TabBar
8
9
10
+ PLAY_BUTTON_SELECTOR = ".ytp-play-button"
11
+ COOKIE_CONSENT_SELECTOR = "button[aria-label^='Accept all'], button[aria-label^='Accept the use']"
9
12
10
13
@pytest .fixture ()
11
14
def test_case ():
12
15
return "134719"
13
16
14
-
15
17
GHA = environ .get ("GITHUB_ACTIONS" ) == "true"
16
18
17
-
18
19
@pytest .mark .skipif (GHA , reason = "Test unstable in Github Actions" )
19
20
@pytest .mark .audio
20
21
def test_mute_unmute_tab (screenshot , driver : Firefox , video_url : str ):
21
22
"""C134719, test that tabs can be muted and unmuted"""
22
23
tabs = TabBar (driver )
23
24
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 )
25
34
play_button .click ()
35
+
26
36
with driver .context (driver .CONTEXT_CHROME ):
27
37
tabs .expect_tab_sound_status (1 , tabs .MEDIA_STATUS .PLAYING )
28
38
tabs .click_tab_mute_button (1 )
You can’t perform that action at this time.
0 commit comments