From 569dd13ef966bace7e68e49ce60bd5de3507662e Mon Sep 17 00:00:00 2001 From: Alena Krauch Date: Wed, 25 Jun 2025 14:36:35 +0300 Subject: [PATCH] ref test_gp_03_06_verify_en_links_lead_to_proper_pages update groups_page_test.py, groups_page.py, conftest.py, footer_test.py --- pages/groups_page.py | 23 +++++++++++++++-------- tests/conftest.py | 2 +- tests/footer_test.py | 2 +- tests/groups_page_test.py | 11 ++++++----- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/pages/groups_page.py b/pages/groups_page.py index 0da9bbe1fa..c732d2085f 100644 --- a/pages/groups_page.py +++ b/pages/groups_page.py @@ -2,6 +2,8 @@ import time import allure import requests +from selenium.webdriver.common.by import By +from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.wait import WebDriverWait as Wait from pages.base_page import BasePage @@ -191,17 +193,22 @@ def click_on_links_on_ru_local(self): @allure.step("Click on links on the 'en' local and thereby open corresponding web pages in the same tab") def click_on_links_on_en_local(self): opened_pages = [] - # print(self.get_current_tab_url()) - self.element_is_present_and_clickable(self.locators.PAGE_LINK1).click() - time.sleep(5) + + link1 = self.element_is_present_and_clickable(self.locators.PAGE_LINK1) + current_url = self.driver.current_url + link1.click() + Wait(self.driver, 10).until(EC.url_changes(current_url)) opened_pages.append(self.get_current_tab_url()) - # print(self.get_current_tab_url()) + self.driver.back() - # print(self.get_current_tab_url()) - self.element_is_present_and_clickable(self.locators.PAGE_LINK2).click() - time.sleep(5) + 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 + link2.click() + Wait(self.driver, 10).until(EC.url_changes(current_url)) opened_pages.append(self.get_current_tab_url()) - # print(self.get_current_tab_url()) + return opened_pages # Checking images on the page diff --git a/tests/conftest.py b/tests/conftest.py index f9fadeeadd..f97e0909ef 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -67,7 +67,7 @@ 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) - Wait(driver, 10).until(subtitles_changed) + Wait(driver, 20).until(subtitles_changed) page.elements_are_visible(GroupsPageLocators.PAGE_SUBTITLES) diff --git a/tests/footer_test.py b/tests/footer_test.py index cbffcfc654..8c650f043c 100644 --- a/tests/footer_test.py +++ b/tests/footer_test.py @@ -101,7 +101,7 @@ def test_fp_03_01_verify_footer_links(self, driver, main_page_open): def test_fp_03_02_verify_links_lead_to_the_correct_pages(self, driver, main_page_open): page = fPage(driver) actual_domains = page.click_on_links() - assert all(domain in fPD.domains for domain in actual_domains), \ + assert all(element in fPD.domains for element in actual_domains), \ "Links in the Footer lead to invalid pages after clicking or don't load within the allotted time" @allure.title("Verify that the 'Contact us' link in the Footer calls an email client") diff --git a/tests/groups_page_test.py b/tests/groups_page_test.py index e10d99ac43..3adc673678 100644 --- a/tests/groups_page_test.py +++ b/tests/groups_page_test.py @@ -123,7 +123,7 @@ def test_gp_03_01_verify_links(self, driver, groups_ru_page_open): "Status codes of links mismatch valid values" @allure.title("Verify title of links on the 'ru' local") - def test_gp_03_02_01_verify_links_ru_title(self, driver, groups_ru_page_open): + def test_gp_03_02_verify_links_ru_title(self, driver, groups_ru_page_open): page = gPage(driver) link_titles_ru = page.get_links_titles_ru() assert link_titles_ru, "Link titles values are empty on the 'ru' local" @@ -131,7 +131,7 @@ def test_gp_03_02_01_verify_links_ru_title(self, driver, groups_ru_page_open): "Link titles mismatch any valid values on the 'ru' local" @allure.title("Verify href of links on the 'ru' local") - def test_gp_03_02_02_verify_links_ru_href(self, driver, groups_ru_page_open): + def test_gp_03_03_verify_links_ru_href(self, driver, groups_ru_page_open): page = gPage(driver) links_href_ru = page.get_links_href_ru() assert links_href_ru, "Links href are empty on the 'ru' local" @@ -139,7 +139,7 @@ def test_gp_03_02_02_verify_links_ru_href(self, driver, groups_ru_page_open): "Attributes 'href' of links on the 'ru' local mismatch valid values" @allure.title("Verify title, href of links on the 'en' local") - def test_gp_03_03_verify_links_en(self, driver, groups_en_page_open): + def test_gp_03_04_verify_links_en(self, driver, groups_en_page_open): page = gPage(driver) link_titles_en = page.get_links_titles_en() links_href_en = page.get_links_href_en() @@ -151,7 +151,7 @@ def test_gp_03_03_verify_links_en(self, driver, groups_en_page_open): "Attributes 'href' of links on the 'en' local mismatch valid values" @allure.title("""Verify if links on the 'ru' local lead to correct pages after clicking""") - def test_gp_03_04_verify_ru_links_lead_to_proper_pages(self, driver, groups_ru_page_open): + def test_gp_03_05_verify_ru_links_lead_to_proper_pages(self, driver, groups_ru_page_open): page = gPage(driver) opened_pages = page.click_on_links_on_ru_local() assert opened_pages, "Transitions to exercises pages have not performed" @@ -159,9 +159,10 @@ def test_gp_03_04_verify_ru_links_lead_to_proper_pages(self, driver, groups_ru_p "Some links lead to incorrect pages after clicking" @allure.title("""Verify if links on the 'en' local lead to correct pages after clicking""") - def test_gp_03_05_verify_en_links_lead_to_proper_pages(self, driver, groups_en_page_open): + def test_gp_03_06_verify_en_links_lead_to_proper_pages(self, driver, groups_en_page_open): page = gPage(driver) opened_pages = page.click_on_links_on_en_local() + print(opened_pages) # Temporarily for refactoring assert opened_pages, "Transitions to exercises pages have not performed" assert all(element in gPD.pages_urls for element in opened_pages), \ "Some links lead to incorrect pages after clicking"