def bookmark_page(): """Bookmark the current page.""" if OSHelper.is_mac(): type(text='d', modifier=KeyModifier.CMD) else: type(text='d', modifier=KeyModifier.CTRL) try: wait(LocationBar.STAR_BUTTON_STARRED, 10) logger.debug('Page was successfully bookmarked') except FindError: raise APIHelperError('Page can not be bookmarked')
def bookmarks_sidebar(option: str): """Toggle open/close the bookmarks sidebar.""" if OSHelper.is_mac(): type(text='b', modifier=KeyModifier.CMD) else: type(text='b', modifier=KeyModifier.CTRL) bookmark_sidebar_header_pattern = SidebarBookmarks.BOOKMARKS_HEADER if option == 'open': try: wait(bookmark_sidebar_header_pattern, 10) logger.debug('Sidebar is opened.') except FindError: raise APIHelperError('Sidebar is NOT present on the page, aborting.') elif option == 'close': try: wait_vanish(bookmark_sidebar_header_pattern, 10) logger.debug('Sidebar is closed.') except FindError: raise APIHelperError('Sidebar is NOT closed, aborting.') else: raise APIHelperError('Option is not supported, aborting')
def bookmarks_sidebar(option: str): """Toggle open/close the bookmarks sidebar.""" if OSHelper.is_mac(): type(text="b", modifier=KeyModifier.CMD) else: type(text="b", modifier=KeyModifier.CTRL) bookmark_sidebar_header_pattern = SidebarBookmarks.BOOKMARKS_HEADER if option == "open": try: wait(bookmark_sidebar_header_pattern, 10) logger.debug("Sidebar is opened.") except FindError: raise APIHelperError( "Sidebar is NOT present on the page, aborting.") elif option == "close": try: wait_vanish(bookmark_sidebar_header_pattern, 10) logger.debug("Sidebar is closed.") except FindError: raise APIHelperError("Sidebar is NOT closed, aborting.") else: raise APIHelperError("Option is not supported, aborting") time.sleep(Settings.DEFAULT_UI_DELAY)