def bookmark_exists()

in foxpuppet/windows/browser/bookmarks/bookmark.py [0:0]


    def bookmark_exists(self, label: str) -> bool:
        """
        Check if a bookmark with the given label exists.

        Args:
            label (str): The name of the bookmark to search for.
        """
        with self.selenium.context(self.selenium.CONTEXT_CHROME):
            self.selenium.find_element(*BookmarkLocators.PANEL_MENU).click()
            self.selenium.find_element(*BookmarkLocators.PANEL_BOOKMARK_MENU).click()
            panel_bookmarks = self.selenium.find_element(
                *BookmarkLocators.PANEL_BOOKMARK_TOOLBAR
            )
            menu_items = panel_bookmarks.find_elements(
                By.CSS_SELECTOR, "toolbarbutton.bookmark-item"
            )
            if any(
                label.lower() in item_label.lower()
                for item in menu_items
                if (item_label := item.get_attribute("label"))
            ):
                return True
        return False