# Path: src/utils.py
# def click_retry(driver: Union[Chrome, Firefox], element_identifier: str, id_type: str):
#     """
#     Click on elements based on id type.
#     Currently supported ids are:
#     * xpath
#     * css_selector
# 
#     :param driver: browser Driver
#     :type driver: object
#     :param element_identifier: id of the element
#     :type element_identifier: str
#     :param id_type: selector type e.g. xpath
#     :type id_type: str
#     """
# 
#     def retry(action: staticmethod):
#         """
#         Retry an action if raise an error
# 
#         :param action: click to be performed
#         :type action: staticmethod
#         """
#         try:
#             action
#         except RuntimeError:
#             action
# 
#     if id_type == 'xpath':
#         retry(driver.find_element_by_xpath(element_identifier).click())
#     else:
#         retry(driver.find_element_by_css_selector(element_identifier).click())


from src.utils import click_retry
from typing import Union
from selenium.webdriver import Chrome, Firefox
    def __init__(self, driver: Union[Chrome, Firefox]):
        """

        :param driver: browser driver
        :type driver: object
        """
        self.__driver = driver

    def menu_button(self):
        """
        Click on menu
        """
        click_retry(self.__driver, self.MENU_BUTTON, 'css_selector')

    def filter_by_trend(self):
        """
        Sort results by trend
        """
        click_retry(self.__driver, self.TREND_BUTTON, 'xpath')

    def filter_by_history(self):
        """
        Sort results by history
        """
        click_retry(self.__driver, self.HISTORY_BUTTON, 'xpath')

    def browse(self):
        """
        Browse channels
        """

# Path: src/utils.py
# def click_retry(driver: Union[Chrome, Firefox], element_identifier: str, id_type: str):
#     """
#     Click on elements based on id type.
#     Currently supported ids are:
#     * xpath
#     * css_selector
# 
#     :param driver: browser Driver
#     :type driver: object
#     :param element_identifier: id of the element
#     :type element_identifier: str
#     :param id_type: selector type e.g. xpath
#     :type id_type: str
#     """
# 
#     def retry(action: staticmethod):
#         """
#         Retry an action if raise an error
# 
#         :param action: click to be performed
#         :type action: staticmethod
#         """
#         try:
#             action
#         except RuntimeError:
#             action
# 
#     if id_type == 'xpath':
#         retry(driver.find_element_by_xpath(element_identifier).click())
#     else:
#         retry(driver.find_element_by_css_selector(element_identifier).click())


# Path: src/factory/pages/menu.py
from src.utils import click_retry
from typing import Union
from selenium.webdriver import Chrome, Firefox

    def __init__(self, driver: Union[Chrome, Firefox]):
        """

        :param driver: browser driver
        :type driver: object
        """
        self.__driver = driver

    def menu_button(self):
        """
        Click on menu
        """
        click_retry(self.__driver, self.MENU_BUTTON, 'css_selector')

    def filter_by_trend(self):
        """
        Sort results by trend
        """
        click_retry(self.__driver, self.TREND_BUTTON, 'xpath')

    def filter_by_history(self):
        """
        Sort results by history
        """
        click_retry(self.__driver, self.HISTORY_BUTTON, 'xpath')

    def browse(self):
        """
        Browse channels
        """

        click_retry(self.__driver, self.BROWSE, 'xpath')