From ac817a0c2d3d485a84dd8f0b2af87af3a3422103 Mon Sep 17 00:00:00 2001 From: Alena Krauch Date: Fri, 17 Apr 2026 19:28:26 +0300 Subject: [PATCH] ref test_gp_03.05 Verifying navigation by links update group_page.py, group_page_locators.py, conftest.py #402 --- locators/groups_page_locators.py | 1 + pages/groups_page.py | 53 ++++++++++++++++++++++---------- tests/conftest.py | 11 ++++--- 3 files changed, 43 insertions(+), 22 deletions(-) diff --git a/locators/groups_page_locators.py b/locators/groups_page_locators.py index 83136a508d..36ca8e7e5e 100644 --- a/locators/groups_page_locators.py +++ b/locators/groups_page_locators.py @@ -18,6 +18,7 @@ class GroupsPageLocators: PAGE_TILES = (By.CSS_SELECTOR, ".list-item") PAGE_TITLE = (By.TAG_NAME, "h3") PAGE_SUBTITLES = (By.XPATH, "//button/h4") + PAGE_SUBTITLE2 = (By.XPATH, "(//button/h4)[2]") class HeaderLocators: diff --git a/pages/groups_page.py b/pages/groups_page.py index c1d666c765..9b6a2f6970 100644 --- a/pages/groups_page.py +++ b/pages/groups_page.py @@ -171,18 +171,50 @@ def get_links_status_codes(self): @allure.step("Click on links on the 'ru' local and thereby open corresponding web pages in the same tab") def click_on_links_on_ru_local(self): opened_pages = [] + starting_url = self.driver.current_url + print(starting_url) link1 = self.element_is_present_and_clickable(self.locators.PAGE_LINK1) - current_url = self.driver.current_url + # current_url = self.driver.current_url link1.click() - Wait(self.driver, 10).until(EC.url_changes(current_url)) + + # Waiting for the first URL change (intermediate page) + Wait(self.driver, 10).until(EC.url_changes(starting_url)) + intermediate_url = self.driver.current_url + print(intermediate_url) + + # Waiting for the second URL change (aimed page) + Wait(self.driver, 10).until(EC.url_changes(intermediate_url)) + current_url = self.driver.current_url + print(current_url) + opened_pages.append(self.get_current_tab_url()) + self.element_is_present_and_clickable(self.locators1.LOGO_LINK).click() + starting_url = self.driver.current_url + print(starting_url) + + # Waiting for the starting page loading + Wait(self.driver, 10).until(EC.presence_of_element_located((By.TAG_NAME, "h3"))) + link2 = self.element_is_present_and_clickable(self.locators.PAGE_LINK2) - current_url = self.driver.current_url + # current_url = self.driver.current_url link2.click() - Wait(self.driver, 10).until(EC.url_changes(current_url)) + + # Waiting for the first URL change (intermediate page) + Wait(self.driver, 10).until(EC.url_changes(starting_url)) + intermediate_url = self.driver.current_url + print(intermediate_url) + + # Waiting for the second URL change (aimed page) + Wait(self.driver, 10).until(EC.url_changes(intermediate_url)) + current_url = self.driver.current_url + print(current_url) + + # Wait(self.driver, 10).until(EC.url_changes(current_url)) + opened_pages.append(self.get_current_tab_url()) + print(opened_pages) return opened_pages @@ -190,7 +222,6 @@ def click_on_links_on_ru_local(self): def click_on_links_on_en_local(self): opened_pages = [] starting_url = self.driver.current_url - print(starting_url) link1 = self.element_is_present_and_clickable(self.locators.PAGE_LINK1) link1.click() @@ -198,22 +229,13 @@ def click_on_links_on_en_local(self): # Waiting for the first URL change (intermediate page) Wait(self.driver, 10).until(EC.url_changes(starting_url)) intermediate_url = self.driver.current_url - print(intermediate_url) # Waiting for the second URL change (aimed page) Wait(self.driver, 10).until(EC.url_changes(intermediate_url)) - current_url = self.driver.current_url - print(current_url) - opened_pages.append(self.get_current_tab_url()) self.driver.back() - intermediate_url = self.driver.current_url - print(intermediate_url) - self.driver.back() - starting_url = self.driver.current_url - print(starting_url) # Waiting for the starting page loading Wait(self.driver, 10).until(EC.presence_of_element_located((By.TAG_NAME, "h3"))) @@ -224,12 +246,9 @@ def click_on_links_on_en_local(self): # Waiting for the first URL change (intermediate page) Wait(self.driver, 10).until(EC.url_changes(starting_url)) intermediate_url = self.driver.current_url - print(intermediate_url) # Waiting for the second URL change (aimed page) Wait(self.driver, 10).until(EC.url_changes(intermediate_url)) - current_url = self.driver.current_url - print(current_url) opened_pages.append(self.get_current_tab_url()) print(opened_pages) diff --git a/tests/conftest.py b/tests/conftest.py index f97e0909ef..cb41b1f92b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -21,6 +21,7 @@ from pages.contributors_page import ContributorsPage from pages.groups_page import GroupsPage from pages.profile_page import ProfilePage +from test_data.groups_page_data import GroupsPageData from test_data.links import MainPageLinks, ExercisesUrls load_dotenv() @@ -60,14 +61,14 @@ def description_page_open(driver): def groups_ru_page_open(driver, auto_test_user_authorized): page = GroupsPage(driver) ru_button = page.element_is_present_and_clickable(huLocators.RU_BUTTON) - subtitles_before = [el.text for el in page.elements_are_located(GroupsPageLocators.PAGE_SUBTITLES)] ru_button.click() - def subtitles_changed(driver): - current_subtitles = [el.text for el in page.elements_are_located(GroupsPageLocators.PAGE_SUBTITLES)] - return current_subtitles != subtitles_before and all(current_subtitles) + def subtitle2(driver): + subtitle2 = driver.find_element(*GroupsPageLocators.PAGE_SUBTITLE2).text + print(subtitle2) + return subtitle2 in GroupsPageData.page_subtitles_ru - Wait(driver, 20).until(subtitles_changed) + Wait(driver, 20).until(subtitle2) page.elements_are_visible(GroupsPageLocators.PAGE_SUBTITLES)