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
18 changes: 9 additions & 9 deletions pages/specialists_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ def check_grid_visibility(self):
return self.element_is_visible(self.locators.PAGE_GRID)

@allure.step("Check the 'All Specialists' link on the 3rd level of nesting is present on the page")
def check_all_specialists_link_presence(self):
def check_all_spec_link_presence(self):
return self.element_is_present(self.locators.ALL_SPECIALISTS_LINK)

@allure.step("Check the 'All Specialists' link on the 3rd level of nesting is visible")
def check_all_specialists_link_visibility(self):
def check_all_spec_link_visibility(self):
return self.element_is_visible(self.locators.ALL_SPECIALISTS_LINK)

@allure.step("Get the list of specialist cards on the 3rd level of nesting on the page")
Expand Down Expand Up @@ -178,24 +178,24 @@ def get_profession_values_in_cards(self):
return [profession.text for profession in self.get_list_of_professions_in_cards()]

@allure.step("Get text in the 'All Specialists' link")
def get_text_in_all_specialists_link(self):
def get_text_in_all_spec_link(self):
return self.get_text(self.locators.ALL_SPECIALISTS_LINK)

# Checking the 'All Specialists' link
@allure.step("Check the 'All Specialists' link is clickable")
def check_all_specialists_link_clickability(self):
def check_all_spec_link_clickability(self):
return self.element_is_clickable(self.locators.ALL_SPECIALISTS_LINK)

@allure.step("Get attribute 'href' of the 'All Specialists' link")
def get_all_specialists_link_href(self):
def get_all_spec_link_href(self):
return self.get_link_href(self.locators.ALL_SPECIALISTS_LINK)

@allure.step("Get status code of the 'All Specialists' link")
def get_all_specialists_link_status_code(self):
return requests.head(self.get_all_specialists_link_href()).status_code
def get_all_spec_link_status_code(self):
return requests.head(self.get_all_spec_link_href()).status_code

@allure.step("Click on the 'All Specialists' link and thereby open the corresponding web page in a new tab")
def click_all_specialists_link(self):
def click_all_spec_link(self):
self.element_is_present_and_clickable(self.locators.ALL_SPECIALISTS_LINK).click()
self.switch_to_new_window()
return self.get_current_tab_url()
Expand Down Expand Up @@ -228,7 +228,7 @@ def check_size_changes_of_images1(self):
for i in range(len(images)):
changed.append(i) if images_sizes_before[i] != images_sizes_after[i] else unchanged.append(i)
lost.append(i) if images_sizes_after[i] == {'height': 0, 'width': 0} else None
print('All images have changed sizes' if len(changed) == len(images) else 'Not all images have changed sizes')
# print('All images have changed sizes' if len(changed) == len(images) else 'Not all images have changed sizes')
return changed

@allure.step("Check changes of images sizes after resizing")
Expand Down
10 changes: 5 additions & 5 deletions test_data/specialists_page_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ class SpecialistsPageData:
"The BrainUp training program was developed jointly with the best specialists "
"in the field of deaf education from Russia and Belarus")

specialists_names = ("Гарбарук Екатерина Сергеевна", "Прошина Любовь Александровна", "Березкина Ксения Сергеевна",
spec_names = ("Гарбарук Екатерина Сергеевна", "Прошина Любовь Александровна", "Березкина Ксения Сергеевна",
"Метельская Наталья Николаевна", "Королева Инна Васильевна", "Юлия Кибалова",
"Платоненко Дарья Сергеевна", "Сивенкова Кристина Александровна",
"Ekaterina Garbaruk", "Lubov Proshina", "Ksenia Berezkina", "Natalia Metelskaya",
"Inna Koroleva", "Yulia Kibalova", "Daria Platonenko", "Kristina Sivenkova")

specialists_professions = (
spec_professions = (
"Кандидат биологических наук, специалист Лаборатории слуха и речи ПСПбГМУ, специалист "
"в области диагностики слуховых нарушений",
"Сурдопедагог, РНПЦ оториноларингологии, опыт работы более 10 лет",
Expand All @@ -43,11 +43,11 @@ class SpecialistsPageData:
"3+ years of experience",
"Teacher of the deaf, Saint Petersburg Center of Otorhinolaryngology, young professional")

all_specialists_link_text = ("Все Специалисты", "All Specialists")
all_spec_link_text = ("Все Специалисты", "All Specialists")

all_specialists_link_href = f"{Links.URL_MAIN_PAGE}specialists#"
all_spec_link_href = f"{Links.URL_MAIN_PAGE}specialists#"

all_specialists_link_status_code = (200,)
all_spec_link_status_code = (200,)

s = 'https://brnup.s3.eu-north-1.amazonaws.com/pictures/specialists/'
e = '.png'
Expand Down
96 changes: 43 additions & 53 deletions tests/specialists_page_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Auto tests for verifying web elements on the 'Specialists' page"""
import allure
from pages.specialists_page import SpecialistsPage
from test_data.specialists_page_data import SpecialistsPageData
from test_data.start_unauthorized_page_data import StartUnauthorizedPageData
from pages.specialists_page import SpecialistsPage as sPage
from test_data.specialists_page_data import SpecialistsPageData as sPD
from test_data.start_unauthorized_page_data import StartUnauthorizedPageData as suPD


# @pytest.mark.skip(reason="unsupported preconditions")
Expand All @@ -11,7 +11,7 @@ class TestSpecialistsPage:
class TestSpecialistsPageStructure:
@allure.title("Verify presence and visibility of content on the page")
def test_sp_01_01_verify_page_presence_and_visibility(self, driver, specialists_page_open):
page = SpecialistsPage(driver)
page = sPage(driver)
page_content_presence = page.check_presence_of_page_content()
page_content_visibility = page.check_visibility_of_page_content()
assert page_content_presence, "The page content is absent in DOM"
Expand All @@ -20,7 +20,7 @@ def test_sp_01_01_verify_page_presence_and_visibility(self, driver, specialists_
@allure.title("""Verify the composition and visibility of elements
on the 1st-6th levels of nesting on the page""")
def test_sp_01_02_verify_page_structure_and_visibility(self, driver, specialists_page_open):
page = SpecialistsPage(driver)
page = sPage(driver)
structure_of_1st_level = page.get_structure_of_1st_level()
visibility_of_elements_on_1st_level = page.check_elements_visibility_on_1st_level_on_page()
structure_of_2nd_level = page.get_structure_of_2nd_level()
Expand All @@ -47,15 +47,15 @@ def test_sp_01_02_verify_page_structure_and_visibility(self, driver, specialists
@allure.title("""Verify presence, visibility of the title, text, link, grid, cards and images
on the 2nd, 3rd, 5th, 6th levels of nesting on the page""")
def test_sp_01_03_verify_page_structural_elements(self, driver, specialists_page_open):
page = SpecialistsPage(driver)
page = sPage(driver)
title_on_2nd_level = page.check_title_presence()
title_visibility = page.check_title_visibility()
text_on_2nd_level = page.check_text_presence()
text_visibility = page.check_text_visibility()
grid_on_2nd_level = page.check_grid_presence()
grid_visibility = page.check_grid_visibility()
link_on_3rd_level = page.check_all_specialists_link_presence()
link_visibility = page.check_all_specialists_link_visibility()
link_on_3rd_level = page.check_all_spec_link_presence()
link_visibility = page.check_all_spec_link_visibility()
cards_on_3rd_level = page.get_list_of_cards()
cards_visibility = page.check_cards_visibility()
images_on_5th_level = page.get_list_of_card_images()
Expand Down Expand Up @@ -84,101 +84,91 @@ def test_sp_01_03_verify_page_structural_elements(self, driver, specialists_page
class TestSpecialistPageText:
@allure.title("Verify value of the title of the tab")
def test_sp_02_01_verify_tab_title(self, driver, specialists_page_open):
page = SpecialistsPage(driver)
page = sPage(driver)
tab_title_value = page.get_value_of_tab_title()
assert tab_title_value, "The title value of the tab is empty"
assert tab_title_value in SpecialistsPageData.tab_title, \
"The title value of the tab mismatches the valid value"
assert tab_title_value in sPD.tab_title, "The title value of the tab mismatches the valid value"

@allure.title("Verify value of title with tag 'h2' on the page")
def test_sp_02_02_verify_page_title(self, driver, specialists_page_open):
page = SpecialistsPage(driver)
page = sPage(driver)
title_value = page.get_value_of_page_title()
assert title_value, "The title value on the page is empty"
assert title_value in SpecialistsPageData.page_title, "The title on the page mismatches the valid value"
assert title_value in sPD.page_title, "The title on the page mismatches the valid value"

@allure.title("Verify value of text on the page")
def test_sp_02_03_verify_page_text(self, driver, specialists_page_open):
page = SpecialistsPage(driver)
page = sPage(driver)
text_content = page.get_text_content_on_page()
assert text_content, "Text content on the page is empty"
assert text_content in SpecialistsPageData.text_on_page, "Text content mismatches the valid value"
assert text_content in sPD.text_on_page, "Text content mismatches the valid value"

@allure.title("Verify values of names and professions in specialist cards in the grid")
def test_sp_02_04_verify_name_and_profession_in_cards(self, driver, specialists_page_open):
page = SpecialistsPage(driver)
page = sPage(driver)
name_values = page.get_name_values_in_cards()
profession_values = page.get_profession_values_in_cards()
assert name_values, "Name values in cards are empty"
assert all(element in SpecialistsPageData.specialists_names for element in name_values), \
"Names in specialist cards mismatch valid values"
assert all(element in sPD.spec_names for element in name_values), "Names in cards mismatch valid values"
assert profession_values, "Profession values in cards are empty"
assert all(element in SpecialistsPageData.specialists_professions for element in profession_values), \
"Professions in specialist cards mismatch valid values"
assert all(element in sPD.spec_professions for element in profession_values), \
"Professions in cards mismatch valid values"

@allure.title("Verify text in the 'All Specialists' link")
def test_sp_02_05_verify_text_in_link(self, driver, specialists_page_open):
page = SpecialistsPage(driver)
link_text = page.get_text_in_all_specialists_link()
page = sPage(driver)
link_text = page.get_text_in_all_spec_link()
assert link_text, "Text in the 'All Specialists' link is empty"
assert link_text in SpecialistsPageData.all_specialists_link_text, \
f"Text in the 'All Specialists' link mismatches any valid values"
assert link_text in sPD.all_spec_link_text, "Text in the 'All Specialists' link mismatches any valid values"

class TestSpecialistPageLinks:
@allure.title("Verify clickability, href, status code of the 'All Specialists' link")
def test_sp_03_01_verify_all_specialists_link(self, driver, specialists_page_open):
page = SpecialistsPage(driver)
link_clickability = page.check_all_specialists_link_clickability()
link_href = page.get_all_specialists_link_href()
link_status_code = page.get_all_specialists_link_status_code()
def test_sp_03_01_verify_all_spec_link(self, driver, specialists_page_open):
page = sPage(driver)
link_clickability = page.check_all_spec_link_clickability()
link_href = page.get_all_spec_link_href()
link_status_code = page.get_all_spec_link_status_code()
assert link_clickability, "The 'All Specialists' link is unclickable"
assert link_href, "Link href is empty"
assert link_href == SpecialistsPageData.all_specialists_link_href, \
"The attribute 'href' of the link mismatches the valid value"
assert link_status_code in SpecialistsPageData.all_specialists_link_status_code, \
"The status code of the link mismatches the valid value"
assert link_href in sPD.all_spec_link_href, "The attribute 'href' of the link mismatches the valid value"
assert link_status_code in sPD.all_spec_link_status_code, "The link status code mismatches the valid value"

@allure.title("""Verify that the 'All Specialists' link leads an unauthorized user
to the correct page after clicking""")
def test_sp_03_02_verify_all_specialists_link_leads_unauthorized_user_to_the_correct_page(
self, driver, specialists_page_open):
page = SpecialistsPage(driver)
new_tab_url = page.click_all_specialists_link()
def test_sp_03_02_verify_all_spec_link_navigation_for_unauthorized_user(self, driver, specialists_page_open):
page = sPage(driver)
new_tab_url = page.click_all_spec_link()
text_on_new_tab = page.get_element_text_on_new_tab()
assert new_tab_url == StartUnauthorizedPageData.page_url, \
"The 'All Specialists' link leads to an incorrect page after clicking"
assert text_on_new_tab in StartUnauthorizedPageData.text_on_page["text_in_section1"], \
"The opened page does not load correctly after clicking on the 'All Specialists' link"
assert new_tab_url == suPD.page_url, "The link leads to an incorrect page after clicking"
assert text_on_new_tab in suPD.text_on_page["text_in_section1"], \
"The opened page does not load correctly after clicking on the link"

@allure.title("""Verify that the 'All Specialists' link leads an authorized user
to the correct page after clicking""")
def test_sp_03_03_verify_all_specialists_link_leads_authorized_user_to_the_correct_page(
self, driver, auto_test_user_authorized):
page = SpecialistsPage(driver)
def test_sp_03_03_verify_all_spec_link_navigation_for_authorized_user(self, driver, auto_test_user_authorized):
page = sPage(driver)
page.open_specialists_page()
new_tab_url = page.click_all_specialists_link()
new_tab_url = page.click_all_spec_link()
text_on_new_tab = page.get_value_of_page_title()
assert new_tab_url == SpecialistsPageData.page_url, \
"The 'All Specialists' link leads to an incorrect page after clicking"
assert text_on_new_tab in SpecialistsPageData.page_title, \
"The opened page does not load correctly after clicking on the 'All Specialists' link"
assert new_tab_url == sPD.page_url, "The link leads to an invalid page after clicking"
assert text_on_new_tab in sPD.page_title, "The opened page does not load correctly after clicking the link"

class TestSpecialistCardImages:
@allure.title("Verify attributes of images in specialist cards in the grid")
def test_sp_04_01_verify_images_attributes_in_cards(self, driver, specialists_page_open):
page = SpecialistsPage(driver)
page = sPage(driver)
images_src = page.get_images_src()
images_alt = page.get_images_alt()
assert images_src, "The 'src' attribute value of some card images is empty"
assert all(element in SpecialistsPageData.images_src for element in images_src), \
assert all(element in sPD.images_src for element in images_src), \
"The 'src' attribute of the card images mismatches valid values"
assert images_alt, "The 'alt' attribute value of some card images is empty"
assert all(element == SpecialistsPageData.images_alt for element in images_alt), \
assert all(element == sPD.images_alt for element in images_alt), \
"The 'alt' attribute value of some card images is empty or mismatches valid values"

@allure.title("Verify sizes of images in specialist cards in the grid")
def test_sp_04_02_verify_images_sizes_in_cards(self, driver, specialists_page_open):
page = SpecialistsPage(driver)
page = sPage(driver)
images_size = page.get_images_sizes()
images_size_changed = page.check_size_changes_of_images()
assert images_size != 0, "Images in specialist cards have not sizes"
Expand Down
Loading