|
1 | 1 | import logging |
| 2 | +from typing import Literal |
2 | 3 |
|
3 | 4 | from selenium.common.exceptions import TimeoutException |
4 | 5 | from selenium.webdriver import ActionChains, Firefox |
@@ -342,6 +343,12 @@ def select_element_in_nav(self, element: str) -> BasePage: |
342 | 343 | self.get_element(element).click() |
343 | 344 | return self |
344 | 345 |
|
| 346 | + @BasePage.context_chrome |
| 347 | + def open_forget_panel(self) -> BasePage: |
| 348 | + """Open the Forget Panel by clicking the Forget button in the toolbar.""" |
| 349 | + self.get_element("forget-button").click() |
| 350 | + return self |
| 351 | + |
345 | 352 | @BasePage.context_chrome |
346 | 353 | def get_legacy_search_engine_label(self) -> str: |
347 | 354 | """Return the displayed engine name from the legacy search bar.""" |
@@ -652,3 +659,43 @@ def expect_bookmarks_toolbar_visibility(self, expected: bool) -> None: |
652 | 659 | self.expect_element_attribute_contains( |
653 | 660 | self.bookmarks_toolbar, "collapsed", expected_value |
654 | 661 | ) |
| 662 | + |
| 663 | + # |
| 664 | + def set_site_autoplay_permission( |
| 665 | + self, |
| 666 | + settings: Literal["allow-audio-video", "block-audio-video", "allow-audio-only"], |
| 667 | + ) -> BasePage: |
| 668 | + """ |
| 669 | + Open the Site audio-video permission panel and set a specific autoplay setting. |
| 670 | +
|
| 671 | + Arguments: |
| 672 | + settings: "allow-audio-video" → Allow Audio and Video, "block-audio-video" → Block Audio and Video, |
| 673 | + "allow-audio-only" → Allow Audio but block Video |
| 674 | + """ |
| 675 | + self.click_on("autoplay-icon-blocked") |
| 676 | + |
| 677 | + if settings == "allow-audio-video": |
| 678 | + self.element_clickable("permission-popup-audio-blocked") |
| 679 | + self.click_on("permission-popup-audio-blocked") |
| 680 | + self.click_and_hide_menu("allow-audio-video-menuitem") |
| 681 | + |
| 682 | + elif settings == "block-audio-video": |
| 683 | + self.element_clickable("permission-popup-audio-video-allowed") |
| 684 | + self.click_and_hide_menu("block-audio-video-menuitem") |
| 685 | + |
| 686 | + elif settings == "allow-audio-only": |
| 687 | + self.element_clickable("permission-popup-audio-video-allowed") |
| 688 | + self.click_and_hide_menu("allow-audio-only-menuitem") |
| 689 | + return self |
| 690 | + |
| 691 | + def verify_autoplay_state(self, expected: Literal["allow", "block"]) -> None: |
| 692 | + """Verify the current state of the autoplay permission panel and icon. |
| 693 | + Arguments: |
| 694 | + expected: "allow" → Allow Audio and Video, "block" → Block Audio and Video |
| 695 | + """ |
| 696 | + if expected == "allow": |
| 697 | + self.element_visible("permission-popup-audio-video-allowed") |
| 698 | + self.element_not_visible("autoplay-icon-blocked") |
| 699 | + else: |
| 700 | + self.element_visible("permission-popup-audio-video-blocked") |
| 701 | + self.element_visible("autoplay-icon-blocked") |
0 commit comments