Skip to content

Commit 391d453

Browse files
committed
Update methods
1 parent 99441e8 commit 391d453

File tree

4 files changed

+28
-24
lines changed

4 files changed

+28
-24
lines changed

modules/browser_object_navigation.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,3 +658,11 @@ def expect_bookmarks_toolbar_visibility(self, expected: bool) -> None:
658658
self.expect_element_attribute_contains(
659659
self.bookmarks_toolbar, "collapsed", expected_value
660660
)
661+
662+
def open_audio_video_permission(self) -> BasePage:
663+
"""Open the Site information panel and select "Allow Audio and Video" """
664+
self.click_on("autoplay-icon-blocked")
665+
self.element_clickable("permission-popup-audio-blocked")
666+
self.click_on("permission-popup-audio-blocked")
667+
self.click_and_hide_menu("allow-audio-video-menuitem")
668+
return self

modules/page_object_prefs.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,16 @@ def get_manage_data_site_element(self, site: str) -> WebElement:
561561
element = self.get_element("manage-cookies-site", labels=[site])
562562
return element
563563

564+
def open_autopaly_modal(self) -> BasePage:
565+
"""
566+
Opens the Autoplay settings modal dialog from the about:preferences#privacy page.
567+
"""
568+
self.open()
569+
self.click_on("autoplay-settings-button")
570+
self.driver.switch_to.frame(self.get_iframe())
571+
self.click_on("autoplay-settings")
572+
return self
573+
564574
def set_autoplay_setting(
565575
self,
566576
settings: Literal[
@@ -577,12 +587,7 @@ def set_autoplay_setting(
577587
- "block-audio-video": Block both audio and video autoplay
578588
- "allow-audio-only": Allow audio but block video autoplay
579589
"""
580-
self.open()
581-
self.click_on("autoplay-settings-button")
582-
583-
self.driver.switch_to.frame(self.get_iframe())
584-
585-
self.click_on("autoplay-settings")
590+
self.open_autopaly_modal()
586591
self.click_on(settings)
587592
self.click_on("spacer")
588593
self.click_on("autoplay-save-changes")

tests/audio_video/test_allow_audio_video_functionality.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_case():
2020
TEST_URL = "https://www.mlb.com/video/rockies-black-agree-on-extension"
2121

2222

23-
# @pytest.mark.skipif(WIN_GHA, reason="Test unstable in Windows Github Actions")
23+
@pytest.mark.skipif(WIN_GHA, reason="Test unstable in Windows Github Actions")
2424
@pytest.mark.audio
2525
@pytest.mark.noxvfb
2626
def test_allow_audio_video_functionality(driver: Firefox):

tests/audio_video/test_users_actions_saved_on_reload.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from modules.browser_object_navigation import Navigation
55
from modules.page_object_generics import GenericPage
66
from modules.page_object_prefs import AboutPrefs
7-
from modules.util import BrowserActions
87

98

109
@pytest.fixture()
@@ -30,15 +29,13 @@ def test_users_actions_saved_on_reload(driver: Firefox):
3029
# Instantiate objects
3130
nav = Navigation(driver)
3231
about_prefs = AboutPrefs(driver, category="privacy")
33-
ba = BrowserActions(driver)
32+
page = GenericPage(driver, url=TEST_URL)
3433

3534
# Open Test page
36-
GenericPage(driver, url=TEST_URL).open()
35+
page.open()
3736

38-
# Open the Site information panel and check "Allow Audio and Video"
39-
nav.click_on("autoplay-icon-blocked")
40-
nav.click_on("permission-popup-audio-blocked")
41-
nav.click_and_hide_menu("allow-audio-video-menuitem")
37+
# Open the Audio-Video Permission panel and check "Allow Audio and Video"
38+
nav.open_audio_video_permission()
4239

4340
# Refresh test page and check the site information panel shows "Allow Audio and Video"
4441
driver.get(driver.current_url)
@@ -48,17 +45,11 @@ def test_users_actions_saved_on_reload(driver: Firefox):
4845
nav.element_not_visible("autoplay-icon-blocked")
4946

5047
# Check the website is added to the exceptions list in about:preferences#privacy
51-
about_prefs.open()
52-
about_prefs.get_element("autoplay-settings-button").click()
53-
54-
# Get the web element for the iframe
55-
iframe = about_prefs.get_iframe()
56-
ba.switch_to_iframe_context(iframe)
57-
48+
about_prefs.open_autopaly_modal()
5849
about_prefs.element_visible("mlb-allow-audio-video-settings")
5950

60-
# Open Test page
61-
GenericPage(driver, url=TEST_URL).open()
51+
# # Open Test page
52+
page.open()
6253

6354
# Open the Site information panel and check "Block Audio and Video"
6455
nav.click_on("autoplay-icon-blocked")
@@ -71,7 +62,7 @@ def test_users_actions_saved_on_reload(driver: Firefox):
7162
nav.element_visible("autoplay-icon-blocked")
7263

7364
# Revisit test page and check Site information panel shows "Block Audio and Video"
74-
GenericPage(driver, url=TEST_URL).open()
65+
page.open()
7566
nav.element_visible("permission-popup-audio-video-blocked")
7667

7768
# Check the Crossed off Play icon is displayed

0 commit comments

Comments
 (0)