import datetime import random import time import unittest import allure import pytest from parameterized import parameterized from ui_automation_framework.core import TestStatus from ui_automation_framework.utils import AppConfig from app.api_client import ApiClient from app.src.pages.login_page import LoginPage from app.src.pages.top_charts_page import TopChartsPage from app.src.pages.track_page import TrackPage @pytest.mark.usefixtures("set_up", "one_time_set_up") class TopChartsPageTest(unittest.TestCase): melbourne = "Melbourne" @pytest.fixture(autouse=True) def classSetup(self): self.loginPage = LoginPage(self.driver) self.topChartsPage = TopChartsPage(self.driver) self.trackPage = TrackPage(self.driver) self.api_client = ApiClient() self.ts = TestStatus(self.driver) @parameterized.expand([("Global", "All Cities", ""), ("Global", "All Cities", "previous"), ("us", "New York City", "")]) @allure.story("AP-7625") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-7047][Top Charts. Shazam] Pop-up Export") @allure.description("TC verifies that users have the ability to export the data from the pop-up on the Top Charts page → 'Shazam Daily Top 200' tab.") def test_top_shazam_tab_popup_export_verification(self, market, city, period): self.loginPage.login_with_worker() # step 10 self.trackPage.select_market(AppConfig.get("market")[market.lower()]["name"]) self.topChartsPage.open_top_chart_page() self.topChartsPage.switch_tab(self.topChartsPage.SHAZAM_TYPE) self.topChartsPage.select_shazam_city(city) chart_date = self.topChartsPage.get_chosen_date() chart_date_f = datetime.datetime.strptime(chart_date, "%m/%d/%y").strftime("%Y-%m-%d") self.topChartsPage.sort_by_column(self.topChartsPage.SHAZAM_TYPE, "days-on-chart") index = random.choice([1, 2, 3, 4, 5]) self.topChartsPage.shazam_open_popup(position=index) if period == "previous": time.sleep(2) self.trackPage.select_previous_mounth_period() # steps 1-2 self.topChartsPage.verify_export_button(button="shazam_popup") # steps 3-7, 9 self.topChartsPage.shazam_tab_verify_popup_export(date=chart_date_f) # step 12 if period == "previous": self.trackPage.select_month_period("August 2017") self.topChartsPage.verify_export_button_inactive(button="shazam_popup") # NOT AUTOMATED - STEPS - 8, 11, 13