Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions pages/footer_page.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import allure
import requests
from selenium.webdriver.support.wait import WebDriverWait as Wait
from urllib.parse import urlparse
from selenium.common import TimeoutException
from locators.footer_page_locators import FooterLocators
from pages.base_page import BasePage
Expand Down Expand Up @@ -34,7 +36,6 @@ def check_elements_visibility_on_1st_level_on_page(self):
@allure.step("Get structure of the 2nd level of nesting in the Footer")
def get_structure_of_2nd_level(self):
elements = self.elements_are_present(self.locators.FOOTER_SECOND_LEVEL_ELEMENTS)
# tags = [element.tag_name for element in elements]
return elements

@allure.step("Check if elements of the 2nd level of nesting are visible")
Expand All @@ -44,7 +45,6 @@ def check_elements_visibility_on_2nd_level_on_page(self):
@allure.step("Get structure of the 3rd level of nesting in the Footer")
def get_structure_of_3rd_level(self):
elements = self.elements_are_present(self.locators.FOOTER_THIRD_LEVEL_ELEMENTS)
# tags = [element.tag_name for element in elements]
return elements

@allure.step("Check if elements of the 3rd level of nesting are visible")
Expand All @@ -54,7 +54,6 @@ def check_elements_visibility_on_3rd_level_on_page(self):
@allure.step("Get structure of the 4th level of nesting in the Footer")
def get_structure_of_4th_level(self):
elements = self.elements_are_present(self.locators.FOOTER_FOURTH_LEVEL_ELEMENTS)
# tags = [element.tag_name for element in elements]
return elements

@allure.step("Check if elements of the 4th level of nesting are visible")
Expand All @@ -64,7 +63,6 @@ def check_elements_visibility_on_4th_level_on_page(self):
@allure.step("Get structure of the 5th level of nesting in the Footer")
def get_structure_of_5th_level(self):
elements = self.elements_are_present(self.locators.FOOTER_FIFTH_LEVEL_ELEMENTS)
# tags = [element.tag_name for element in elements]
return elements

@allure.step("Check if elements of the 5th level of nesting are visible")
Expand All @@ -74,7 +72,6 @@ def check_elements_visibility_on_5th_level_on_page(self):
@allure.step("Get structure of the 6th level of nesting in the Footer")
def get_structure_of_6th_level(self):
elements = self.elements_are_present(self.locators.FOOTER_SIXTH_LEVEL_ELEMENTS)
# tags = [element.tag_name for element in elements]
return elements

@allure.step("Check if elements of the 6th level of nesting are visible")
Expand All @@ -84,7 +81,6 @@ def check_elements_visibility_on_6th_level_on_page(self):
@allure.step("Get structure of the 7th level of nesting in the Footer")
def get_structure_of_7th_level(self):
elements = self.elements_are_present(self.locators.FOOTER_SEVENTH_LEVEL_ELEMENTS)
# tags = [element.tag_name for element in elements]
return elements

@allure.step("Check if elements of the 7th level of nesting are visible")
Expand Down Expand Up @@ -165,24 +161,29 @@ def get_supporter_links_status_codes(self):

@allure.step("Click on links in the Footer and thereby open corresponding web pages on new tabs")
def click_on_links(self):
new_tabs = [link.click() for link in self.get_list_of_supporter_links()]
# print(f'Opened tabs: {len(new_tabs)}')
new_tabs_urls, count1, count2, count3 = [], 0, 0, 0
for i in range(1, len(new_tabs) + 1):
footer_links = self.get_list_of_supporter_links()

for link in footer_links:
link.click()

domains = []
for i in range(1, len(footer_links) + 1):
try:
self.driver.switch_to.window(self.driver.window_handles[i])
new_tab_url = self.get_current_tab_url()
if new_tab_url:
new_tabs_urls.append(new_tab_url)
count1 += 1
else:
print(f"The tab url {i} has not been defined during the allotted time")
count2 += 1
Wait(self.driver, 10).until(lambda d: d.current_url not in ('', 'about:blank'))
current_url = self.driver.current_url
parsed_url = urlparse(current_url)
domain = parsed_url.netloc

if domain.startswith('www.'):
domain = domain[4:]
domains.append(domain)

except TimeoutException:
print(f"The tab {i} has not been loaded during the allotted time")
count3 += 1
# print(f'{new_tabs_urls}\nDefined tabs urls: {count1}\nUndefined tabs urls: {count2}\nUnloaded tabs: {count3}')
return new_tabs_urls
print(f"Tab {i} did not load within the allotted time")
continue

return domains

@allure.step("Click on the 'Contact us' link in the Footer and thereby open an email client")
def click_contact_us_link(self):
Expand Down
13 changes: 5 additions & 8 deletions test_data/footer_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ class FooterData:
link1 = "https://arasaac.org/"
link2 = "mailto:brainupproject@yandex.ru?subject=BrainUp"
link3 = "https://epam.com/"
link4 = "https://www.epam.com/"
link5 = "https://www.jetbrains.com/"
link6 = "https://reg.ru/"
link7 = "https://www.reg.ru/"
link8 = f"{link7}?utm_source=brainup.site&utm_medium=referral&utm_campaign=brainup.site&utm_referrer=brainup.site"
link9 = "https://selectel.ru/"
link4 = "https://www.jetbrains.com/"
link5 = "https://reg.ru/"
link6 = "https://selectel.ru/"

links_href = (link1, link2, link3, link5, link6, link9)
links_href = (link1, link2, link3, link4, link5, link6)

link_status_codes = (200, 403)

Expand All @@ -32,4 +29,4 @@ class FooterData:
images_alt = ("ARASAAC", "EPAM", "JetBrains", "Регистратор доменных имен РЕГ.РУ", "Selectel")

# Related web pages urls
pages_urls = (link1, link3, link4, link5, link6, link7, link8, link9)
domains = ['arasaac.org', 'epam.com', 'jetbrains.com', 'reg.ru', 'selectel.ru'] # the list of domains
6 changes: 3 additions & 3 deletions tests/footer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ def test_fp_03_01_verify_footer_links(self, driver, main_page_open):
@allure.title("Verify that links in the Footer lead to correct pages after clicking")
def test_fp_03_02_verify_links_lead_to_the_correct_pages(self, driver, main_page_open):
page = fPage(driver)
new_tabs_urls = page.click_on_links()
assert all(element in fPD.pages_urls for element in new_tabs_urls), \
"Links in the Footer lead to invalid pages after clicking or don't load during the allotted time"
actual_domains = page.click_on_links()
assert all(domain in fPD.domains for domain 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")
def test_fp_03_03_verify_contact_us_link_calls_an_email_client(self, driver, main_page_open):
Expand Down
Loading