import logging import random import time 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 from ui_automation_framework.utils import logger as cl from app.api_client import ApiClient from app.src.pages.album_page import AlbumPage 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): log = cl.Logger(logging.DEBUG) @pytest.fixture(autouse=True) def classSetup(self): self.loginPage = LoginPage(self.driver) self.tp = TrackPage(self.driver) self.cp = TrackComparisonPage(self.driver) self.ap = AlbumPage(self.driver) self.api_client = ApiClient() self.ts = TestStatus(self.driver) @allure.story("AP-5194") @allure.severity(allure.severity_level.NORMAL) @allure.title("[4913] [YT > New Video Page] Deep-linking verification. STEPS 1-4, 18-20") @allure.description( """TC verifies deep-linking functionality for chosen Video Page filters settings so that user can use predefined links to view streaming data coming from YOUTUBE. STEPS 1-4, 18-20""" ) def test_youtube_nvp_deep_linking_steps_1_4(self): self.loginPage.login_with_worker() track = random.choice(["track40", "track6"]) self.tp.open_spotify_track_page_with_market_id(track_id=AppConfig.get(track)["id"], market_id=AppConfig.get("market")["global"]["url"]) # step 1, 18 self.tp.open_video_page_from_tab() market = self.tp.graph_get_selected_market() assert_that(market).is_equal_to(self.tp.all_markets) self.cp.open_new_tab() self.tp.open_current_url_in_new_tab() market = self.tp.graph_get_selected_market() assert_that(market).is_equal_to(self.tp.all_markets) self.cp.switch_to_tab(1) # step 2, 19-20 self.tp.open_spotify_track_page_with_market_id(track_id=AppConfig.get(track)["id"], market_id=AppConfig.get("market")["global"]["url"]) self.tp.td_switch_to_youtube_tab() self.tp.td_open_video_page() market = self.tp.graph_get_selected_market() assert_that(market).is_equal_to(self.tp.all_markets) self.tp.open_current_url_in_new_tab() market = self.tp.graph_get_selected_market() assert_that(market).is_equal_to(self.tp.all_markets) self.tp.change_param_in_url_new(self.tp.market, AppConfig.get("market")["canada"]["url"]) market = self.tp.graph_get_selected_market() assert_that(market).is_equal_to(self.tp.all_markets) self.tp.replace_param_in_url(self.tp.market, AppConfig.get("market")["canada"]["url"], "test") time.sleep(2) self.tp.verify_params_in_url({self.tp.str_gr_type: 2, self.tp.str_gr_source: "all_key_sources,all_other_sources", self.tp.str_gr_country: 0, self.tp.str_gr_view: 2, self.tp.str_gr_video: "all", self.tp.str_gr_tab: 4, self.tp.market: 14}) self.cp.close_current_tab() self.cp.switch_to_tab(1) # step 3 self.tp.market_dd_choose_few_countries(param=[AppConfig.get("market")["us"]["name"]], tab="youtube_nvp") self.tp.verify_params_in_url({self.tp.str_gr_country: AppConfig.get("market")["us"]["market"]}) self.tp.graph_get_selected_market() self.tp.refresh() market = self.tp.graph_get_selected_market() assert_that(market).is_equal_to(AppConfig.get("market")["us"]["name"]) self.tp.replace_param_in_url(self.tp.str_gr_country, "us", "ca") market = self.tp.graph_get_selected_market() assert_that(market).is_equal_to(AppConfig.get("market")["canada"]["name"]) self.tp.replace_param_in_url(self.tp.str_gr_country, AppConfig.get("market")["canada"]["market"], "test") time.sleep(2) self.tp.verify_params_in_url({self.tp.str_gr_type: 2, self.tp.str_gr_source: "all_key_sources,all_other_sources", self.tp.str_gr_country: 0, self.tp.str_gr_view: 2, self.tp.str_gr_video: "all", self.tp.str_gr_tab: 4, self.tp.market: 14}) # step 4 self.tp.stream_and_source_choose_region(param=self.tp.REGION_ASIA, dd="youtube_nvp") self.tp.verify_params_in_url({self.tp.str_gr_region: "ras"}) self.tp.graph_get_selected_market() self.tp.refresh() market = self.tp.graph_get_selected_market() assert_that(market).is_equal_to(self.tp.REGION_ASIA) self.tp.replace_param_in_url(self.tp.str_gr_region, "ras", "roc") market = self.tp.graph_get_selected_market() assert_that(market).is_equal_to(self.tp.REGION_OCEANIA) default_url = self.tp.get_url() self.tp.replace_param_in_url(self.tp.str_gr_region, "ras", "test") self.verify_url(default_url) @allure.issue("https://data-analytics.atlassian.net/browse/AP-9874") @pytest.mark.flaky(reruns=0) @allure.story("AP-5194") @allure.severity(allure.severity_level.NORMAL) @allure.title("[4913] [YT > New Video Page] Deep-linking verification. STEPS 5-9, 18-20") @allure.description( """TC verifies deep-linking functionality for chosen Video Page filters settings so that user can use predefined links to view streaming data coming from YOUTUBE. STEPS 5-9, 18-20""" ) def test_youtube_nvp_deep_linking_steps_5_9(self): self.loginPage.login_with_worker() track = random.choice(["track40", "track6"]) self.tp.open_youtube_video_page(isrc=AppConfig.get(track)["isrc"], market=AppConfig.get("market")["global"]["url"]) self.tp.stream_and_source_choose_region(param=self.tp.REGION_ASIA, dd="youtube_nvp") # step 5 self.tp.stream_and_source_deselect_countries(market_name="Hong Kong", dd="youtube_nvp") market_list = "kh,fj,in,id,jp,la,mo,my,np,pg,ph,sg,kr,lk,tw,th,vn" self.tp.verify_params_in_url({self.tp.str_gr_country: market_list}) self.cp.open_new_tab() self.tp.open_current_url_in_new_tab() market = self.tp.graph_get_selected_market() assert_that(market).is_equal_to(f"{len(market_list.split(','))} Markets") self.cp.switch_to_tab(1) # # step 6 self.tp.select_market(AppConfig.get("market")["canada"]["name"]) self.tp.market_dd_choose_few_countries(param=[AppConfig.get("market")["us"]["name"]], tab="youtube_nvp") self.tp.market_dd_choose_few_countries(param=[AppConfig.get("market")["canada"]["name"]], tab="youtube_nvp") default_url = self.tp.get_url() self.tp.verify_params_in_url({self.tp.market: AppConfig.get("market")["canada"]["url"]}) self.tp.open_current_url_in_new_tab() market = self.tp.graph_get_selected_market() assert_that(market).is_equal_to(AppConfig.get("market")["canada"]["name"]) self.cp.switch_to_tab(1) # step 7 self.tp.market_dd_choose_few_countries(param=[AppConfig.get("market")["canada"]["name"], AppConfig.get("market")["us"]["name"]], tab="youtube_nvp") ca_us = "ca,us" self.tp.verify_params_in_url({self.tp.str_gr_country: ca_us}) self.tp.open_current_url_in_new_tab() market = self.tp.graph_get_selected_market() assert_that(market).is_equal_to(f"{len(ca_us.split(','))} Markets") self.cp.close_current_tab() self.cp.switch_to_tab(1) # step 8 self.tp.choose_graph_view_area_graph_percentage() self.tp.verify_params_in_url({self.tp.str_gr_view: 3}) self.cp.open_new_tab() self.tp.open_current_url_in_new_tab() self.tp.is_graph_period_displayed() self.tp.verify_graph_view_chosen("Area Graph, %") self.tp.replace_param_in_url(self.tp.str_gr_view, 3, 2) self.tp.verify_graph_view_chosen("Area Graph") self.tp.replace_param_in_url(self.tp.str_gr_view, 2, 8) self.verify_url(default_url) self.cp.switch_to_tab(1) # step 9 self.tp.choose_graph_view_area_graph() self.tp.verify_params_in_url({self.tp.str_gr_view: 2}) self.tp.open_current_url_in_new_tab() self.tp.verify_graph_view_chosen("Area Graph") self.cp.switch_to_tab(1) @allure.story("AP-5194") @allure.severity(allure.severity_level.NORMAL) @allure.title("[4913] [YT > New Video Page] Deep-linking verification. STEPS 10-12, 18-20") @allure.description( """TC verifies deep-linking functionality for chosen Video Page filters settings so that user can use predefined links to view streaming data coming from YOUTUBE. STEPS 10-12, 18-20""" ) def test_youtube_nvp_deep_linking_steps_10_12(self): self.loginPage.login_with_worker() track = random.choice(["track40", "track6"]) self.tp.open_youtube_video_page(isrc=AppConfig.get(track)["isrc"], market=AppConfig.get("market")["global"]["url"]) self.tp.market_dd_choose_few_countries(param=[AppConfig.get("market")["us"]["name"]], tab="youtube_nvp") self.tp.market_dd_choose_few_countries(param=[self.tp.all_markets], tab="youtube_nvp") default_url = self.tp.get_url() # step 10 self.tp.vp_youtube_change_source_view(AppConfig.get("source")["by_video"]) self.tp.verify_params_in_url({self.tp.str_gr_type: 4, self.tp.str_gr_view: 1}) self.cp.open_new_tab() self.tp.open_current_url_in_new_tab() self.tp.is_graph_period_displayed() source_type_ui = self.tp.get_source_type() assert_that(source_type_ui).is_equal_to(AppConfig.get("source")["by_video"]) self.cp.close_current_tab() self.cp.switch_to_tab(1) # step 11 for source, param in [ (AppConfig.get("source")["all_views"], 1), # (AppConfig.get("source")["by_avg_view_duration"], 5), (AppConfig.get("source")["by_likes"], 6), (AppConfig.get("source")["by_dislikes"], 7), (AppConfig.get("source")["by_comments"], 8), (AppConfig.get("source")["by_shares"], 9), ]: self.tp.vp_youtube_change_source_view(source) self.tp.is_graph_period_displayed() time.sleep(2) self.tp.verify_params_in_url({self.tp.str_gr_type: param}) self.cp.open_new_tab() self.tp.open_current_url_in_new_tab() time.sleep(2) self.tp.is_graph_period_displayed() time.sleep(2) source_type_ui = self.tp.get_source_type() assert_that(source_type_ui).is_equal_to(source) self.tp.verify_params_in_url({self.tp.str_gr_type: param}) if param == 9: self.tp.replace_param_in_url(self.tp.str_gr_type, param, 6) self.tp.graph_get_selected_market() self.tp.is_graph_period_displayed() source_type_ui = self.tp.get_source_type() assert_that(source_type_ui).is_equal_to("By Likes") self.tp.verify_params_in_url({self.tp.str_gr_type: 6}) self.tp.replace_param_in_url(self.tp.str_gr_type, 6, 10) self.verify_url(default_url) self.cp.close_current_tab() self.cp.switch_to_tab(1) # step 12 self.tp.vp_youtube_change_source_view(AppConfig.get("source")["by_source"]) self.tp.nvp_youtube_check_videos(count=2) current_url = self.tp.get_url() self.ts.markFinal("str_gr_video" in current_url, current_url) @allure.story("AP-5194") @allure.severity(allure.severity_level.NORMAL) @allure.title("[4913] [YT > New Video Page] Deep-linking verification. STEPS 13-17") @allure.description( """TC verifies deep-linking functionality for chosen Video Page filters settings so that user can use predefined links to view streaming data coming from YOUTUBE. STEPS 13-17""" ) def test_youtube_nvp_deep_linking_steps_13_17(self): self.loginPage.login_with_worker() track = random.choice(["track40", "track6"]) self.tp.open_youtube_video_page(isrc=AppConfig.get(track)["isrc"], market=AppConfig.get("market")["global"]["url"]) # step 13 self.tp.youtube_change_sources(param=["Playlists", "Suggested Videos"], dd="nvp") self.tp.verify_params_in_url({self.tp.str_gr_source: "playlists,suggested_videos"}) # step 14 self.tp.youtube_switch_to_views_by_market_tab() self.tp.verify_params_in_url({self.tp.str_gr_tab: 5}) # step 15 self.tp.youtube_change_sources(param=["Playlists", "Notifications"], dd="vbm") self.tp.verify_params_in_url({self.tp.str_gr_source: "notifications,playlists"}) # step 16 self.tp.market_dd_choose_few_countries([self.tp.all_markets], "youtube_vbm") self.tp.verify_params_in_url({self.tp.str_gr_country: "0"}) # step 17 self.tp.vdm_choose_graph_view_bar_chart() self.tp.verify_params_in_url({self.tp.str_gr_view: 4}) @allure.step("Verify url") def verify_url(self, url_exp): self.tp.is_graph_period_displayed() url_current = self.tp.get_url() assert_that(url_exp).is_equal_to(url_current)