import unittest import allure import pytest from assertpy import assert_that from ui_automation_framework.core import TestStatus from ui_automation_framework.utils import AppConfig, CoreConfig from app.src.pages.comparison_page import TrackComparisonPage from app.src.pages.login_page import LoginPage from app.src.pages.track_page import TrackPage @pytest.mark.usefixtures("set_up", "one_time_set_up") class DeepLinkingTrackPageTest(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self): self.loginPage = LoginPage(self.driver) self.tp = TrackPage(self.driver) self.cp = TrackComparisonPage(self.driver) self.ts = TestStatus(self.driver) @allure.story("AP-4770") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-4526] Deep linking of countries multi-selection") @allure.description("TC verifies that user can share the link to track page with several selected countries.") def test_apple_playlist_toggle(self): self.loginPage.login(CoreConfig.USER_EMAIL, CoreConfig.USER_PASSWORD) self.loginPage.is_logged_in() self.tp.open_spotify_track_page_with_market_id(track_id=AppConfig.get("track40")["id"], market_id=AppConfig.get("market")["global"]["url"]) # step 1 self.tp.verify_params_in_url({self.tp.market: AppConfig.get("market")["global"]["url"]}) # step 2 self.tp.select_market(AppConfig.get("market")["brazil"]["name"]) self.switch_to_new_tab() self.tp.verify_params_in_url({self.tp.market: AppConfig.get("market")["brazil"]["url"]}) market_graph = self.tp.graph_get_selected_market() assert_that(market_graph).is_equal_to(AppConfig.get("market")["brazil"]["name"]) self.switch_to_previous_tab() # step 3 countries_add = [ AppConfig.get("market")["argentina"], AppConfig.get("market")["brazil"], AppConfig.get("market")["france"], AppConfig.get("market")["germany"], AppConfig.get("market")["us"], AppConfig.get("market")["uk"], ] self.tp.market_dd_choose_few_countries([c["name"] for c in countries_add]) self.switch_to_new_tab() self.tp.verify_params_in_url({self.tp.market: AppConfig.get("market")["brazil"]["url"]}) url_countries = self.tp.parameter_from_url(self.tp.str_gr_country).split(",") assert_that(sorted(url_countries)).is_equal_to(sorted([c["market"] for c in countries_add])) self.switch_to_previous_tab() # step 4 countries_ex_fr = countries_add.copy() countries_ex_fr.remove(AppConfig.get("market")["france"]) self.tp.stream_and_source_deselect_countries([AppConfig.get("market")["france"]["name"]]) self.switch_to_new_tab() self.tp.verify_params_in_url({self.tp.market: AppConfig.get("market")["brazil"]["url"]}) url_countries = self.tp.parameter_from_url(self.tp.str_gr_country).split(",") assert_that(sorted(url_countries)).is_equal_to(sorted([c["market"] for c in countries_ex_fr])) self.switch_to_previous_tab() # step 5 self.tp.select_dsp(AppConfig.get("dsp")["amazon"]) self.switch_to_new_tab() url_countries = self.tp.parameter_from_url(self.tp.str_gr_country).split(",") assert_that(sorted(url_countries)).is_equal_to(sorted([c["market"] for c in countries_ex_fr])) self.switch_to_previous_tab() # step 8 self.tp.switch_to_streams_by_markets_tab() self.switch_to_new_tab() self.tp.verify_params_in_url({self.tp.market: AppConfig.get("market")["brazil"]["url"], self.tp.str_gr_tab: 2, self.tp.str_gr_dsp: 3}) self.switch_to_previous_tab() # step 9 self.tp.switch_to_streams_and_sources_tab() self.switch_to_new_tab() self.tp.verify_params_in_url({self.tp.market: AppConfig.get("market")["brazil"]["url"], self.tp.str_gr_tab: 1, self.tp.str_gr_dsp: 3}) market_graph = self.tp.graph_get_selected_market() assert_that(market_graph).is_equal_to(AppConfig.get("market")["brazil"]["name"]) self.switch_to_previous_tab() # step 10 amazon_markets_only = [ AppConfig.get("market")["china"], AppConfig.get("market")["sri_lanka"], AppConfig.get("market")["nepal"], ] self.tp.market_dd_choose_few_countries([m["name"] for m in amazon_markets_only]) self.switch_to_new_tab() self.tp.verify_params_in_url({self.tp.market: AppConfig.get("market")["brazil"]["url"], self.tp.str_gr_tab: 1, self.tp.str_gr_dsp: 3}) url_countries = self.tp.parameter_from_url(self.tp.str_gr_country).split(",") assert_that(sorted(url_countries)).is_equal_to(sorted([c["market"] for c in amazon_markets_only])) self.switch_to_previous_tab() # step 11 for d, u in [ (AppConfig.get("dsp")["apple"], 2), (AppConfig.get("dsp")["by_dsp"], 5), (AppConfig.get("dsp")["total_streams"], 4), ]: self.tp.select_dsp(d) self.switch_to_new_tab() self.tp.verify_params_in_url({self.tp.market: AppConfig.get("market")["brazil"]["url"], self.tp.str_gr_tab: 1, self.tp.str_gr_dsp: u}) url_countries = self.tp.parameter_from_url(self.tp.str_gr_country).split(",") countries_selected = self.tp.graph_get_selected_market() assert_that(countries_selected).is_equal_to("3 Markets") assert_that(sorted(url_countries)).is_equal_to(sorted([c["market"] for c in amazon_markets_only])) self.switch_to_previous_tab() # step 12 self.tp.select_dsp(AppConfig.get("dsp")["spotify"]) selected_markets_streams_before = self.tp.get_streams_in_period_total() self.switch_to_new_tab() countries_selected = self.tp.graph_get_selected_market() selected_markets_streams_after = self.tp.get_streams_in_period_total() self.tp.verify_params_in_url({self.tp.str_gr_dsp: 1}) assert_that(countries_selected).is_equal_to("3 Markets") assert_that(selected_markets_streams_before).is_equal_to(selected_markets_streams_after) self.switch_to_previous_tab() @allure.step("Open and switch to new tab") def switch_to_new_tab(self): url_current = self.tp.get_url() self.cp.open_new_tab() self.cp.switch_to_tab(2) self.tp.open_url(url_current) @allure.step("Close second tab and switch to first one") def switch_to_previous_tab(self): self.cp.close_current_tab() self.cp.switch_to_tab(1) # NOT AUTOMATED STEPS - 6-7