Untitled

 avatar
unknown
plain_text
a month ago
1.5 kB
8
Indexable
    def switch_to_workforce(
        self,
        workforce: str,
        expected_page_title: str = ReadConfig.get_overview_page_title()
    ):
        """Switching the workforce based on the given workforce.

        Args:
            workforce (str): the workforce to be switched to
            expected_page_title (str, optional): the expected page title after switching to that workforce.
                Defaults to ReadConfig.get_overview_page_title().z
        """
        self.check_loading_elements(duration=35)
        sleep(3)
        try:
            # Attempt to click the workforce button
            self.base_click(loc.workforce_btn_xpath, loc.sidebar_one_item.format(workforce), wait=120)
        except TimeoutException:
            # If the click operation times out, try searching for the workforce
            print(f"TimeoutException: Button click failed, attempting to search for workforce: {workforce}")

            # Perform search and select actions as a fallback
            self.base_click(loc.search_workforce_button_xpath)
            self.base_send_keys(loc.search_workforce_input_xpath, workforce)
            self.base_click(loc.searched_workforce_xpath.format(workforce))
        assert self.base_is_visible(
            loc.workforce_name_xpath.format(workforce),
            loc.workforce_sidebar_header,
            wait=25
        )
        assert self.compare_page_title(expected_page_title)
        sleep(10)
        self.move_to_element(loc.workforce_header)  # To remove tooltip from workforce sidebar
Leave a Comment