Skip to content

Commit 13bf31e

Browse files
committed
Add toggle bookmarks toolbar
1 parent 4d7af75 commit 13bf31e

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

modules/browser_object_navigation.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def __init__(self, driver: Firefox, **kwargs):
3838
self.search_bar = None
3939
self.awesome_bar = None
4040
self.change_search_settings_button = None
41+
self.bookmarks_toolbar = "bookmarks-toolbar"
4142
self.context_menu = ContextMenu(self.driver)
4243
self.panel_ui = PanelUi(self.driver)
4344

@@ -591,3 +592,20 @@ def open_all_bookmarks_via_context_menu(self) -> BasePage:
591592
self.context_click("bookmarks-toolbar")
592593
self.context_menu.click_on("context-menu-toolbar-open-all-bookmarks")
593594
return self
595+
596+
@BasePage.context_chrome
597+
def expect_bookmarks_toolbar_visibility(self, expected: bool) -> None:
598+
"""
599+
Assert the visibility state of the Bookmarks Toolbar.
600+
601+
Arguments:
602+
----------
603+
expected (bool):
604+
If True, asserts that the toolbar is visible (collapsed="false").
605+
If False, asserts that the toolbar is hidden (collapsed="true")
606+
"""
607+
608+
expected_value = "false" if expected else "true"
609+
self.expect_element_attribute_contains(
610+
self.bookmarks_toolbar, "collapsed", expected_value
611+
)

tests/bookmarks_and_history/test_toggle_bookmarks_toolbar.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ def test_toggle_bookmark_toolbar(driver: Firefox):
1818
"""
1919
C2084637: Verify that the user can Hide or Show the Bookmarks Toolbar using Keyboard shortcuts
2020
"""
21-
# Instantiate the browser object
21+
# Instantiate the object
2222
nav = Navigation(driver)
2323

2424
# By default, the Bookmarks Toolbar is hidden. The element attribute indicates
2525
# whether the bookmarks toolbar is either, collapsed = 'true' is hidden,
2626
# or not collapsed = 'false' is visible.
27-
nav.expect_element_attribute_contains("bookmarks-toolbar", "collapsed", "true")
27+
nav.expect_bookmarks_toolbar_visibility(expected=False)
2828

2929
# Un-hide the Bookmarks Toolbar with keyboard shortcut.
3030
nav.toggle_bookmarks_toolbar_with_key_combo()
31-
nav.expect_element_attribute_contains("bookmarks-toolbar", "collapsed", "false")
31+
nav.expect_bookmarks_toolbar_visibility(expected=True)
3232

3333
# Toggle the Bookmarks Toolbar again and confirm it is hidden.
3434
nav.toggle_bookmarks_toolbar_with_key_combo()
35-
nav.expect_element_attribute_contains("bookmarks-toolbar", "collapsed", "true")
35+
nav.expect_bookmarks_toolbar_visibility(expected=False)

0 commit comments

Comments
 (0)