import logging from contextlib import suppress import allure from ui_automation_framework.utils import logger as cl from waiting import TimeoutExpired from src.helpers.waiting_wrapper import wait from src.locators.artist_locators import ArtistLocators from src.pages.common_page import CommonPage from src.ui_elements.button_ui_element import ButtonUIElement from src.ui_elements.input_ui_element import InputUIElement from src.ui_elements.label_ui_element import LabelUIElement, LabelUIByText from src.ui_elements.list_ui_element import ListUIElement class ArtistPage(CommonPage): log = cl.Logger(logging.DEBUG) def __init__(self, driver): super().__init__(driver) self.driver = driver @property def lb_time_interval(self): return ButtonUIElement(self.driver, ArtistLocators.TIME_INTERVAL_LB, "Artist Time interval") @property def bn_social_instagram(self): return ButtonUIElement(self.driver, ArtistLocators.SOCIAL_INSTAGRAM_BN, "Social Instagram") @property def bn_social_twitter(self): return ButtonUIElement(self.driver, ArtistLocators.SOCIAL_TWITTER_BN, "Social Twitter") @property def bn_social_facebook(self): return ButtonUIElement(self.driver, ArtistLocators.SOCIAL_FACEBOOK_BN, "Social Facebook") @property def bn_compare(self): return ButtonUIElement(self.driver, ArtistLocators.COMPARE_BN, "Compare on Artist page") @property def lb_track_comparison(self): return ButtonUIElement(self.driver, ArtistLocators.TRACK_COMPARISON_SECTION, "Track Comparison section") @property def lb_track_bar(self): return LabelUIByText(self.driver, ArtistLocators.TRACK_BAR_BY_NAME, "Track bar") @allure.step("Artist name checking") def chosen_artist_name(self): self.bn_artist_selection.wait() artist_name = self.bn_artist_selection.value.split(', ')[1] print("Artist is {}".format(artist_name)) return artist_name @allure.step("Check time interval presence") def is_time_interval_present(self): with suppress(TimeoutExpired): return wait(self.lb_time_interval.is_visible) return False @allure.step("Check track comparison presence") def is_track_comparison_present(self): with suppress(TimeoutExpired): return wait(self.lb_track_comparison.is_visible) return False @allure.step("Proceed to Track Comparison") def go_to_track_comparison(self): self.bn_compare.click() return self