Skip to content

Commit ec0343b

Browse files
update specialists_page_test.py, specialists_page.py, specialists_page_data.py
1 parent 041de47 commit ec0343b

File tree

3 files changed

+57
-67
lines changed

3 files changed

+57
-67
lines changed

pages/specialists_page.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ def check_grid_visibility(self):
111111
return self.element_is_visible(self.locators.PAGE_GRID)
112112

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

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

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

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

184184
# Checking the 'All Specialists' link
185185
@allure.step("Check the 'All Specialists' link is clickable")
186-
def check_all_specialists_link_clickability(self):
186+
def check_all_spec_link_clickability(self):
187187
return self.element_is_clickable(self.locators.ALL_SPECIALISTS_LINK)
188188

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

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

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

234234
@allure.step("Check changes of images sizes after resizing")

test_data/specialists_page_data.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ class SpecialistsPageData:
1212
"The BrainUp training program was developed jointly with the best specialists "
1313
"in the field of deaf education from Russia and Belarus")
1414

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

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

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

48-
all_specialists_link_href = f"{Links.URL_MAIN_PAGE}specialists#"
48+
all_spec_link_href = f"{Links.URL_MAIN_PAGE}specialists#"
4949

50-
all_specialists_link_status_code = (200,)
50+
all_spec_link_status_code = (200,)
5151

5252
s = 'https://brnup.s3.eu-north-1.amazonaws.com/pictures/specialists/'
5353
e = '.png'

tests/specialists_page_test.py

+43-53
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""Auto tests for verifying web elements on the 'Specialists' page"""
22
import allure
3-
from pages.specialists_page import SpecialistsPage
4-
from test_data.specialists_page_data import SpecialistsPageData
5-
from test_data.start_unauthorized_page_data import StartUnauthorizedPageData
3+
from pages.specialists_page import SpecialistsPage as sPage
4+
from test_data.specialists_page_data import SpecialistsPageData as sPD
5+
from test_data.start_unauthorized_page_data import StartUnauthorizedPageData as suPD
66

77

88
# @pytest.mark.skip(reason="unsupported preconditions")
@@ -11,7 +11,7 @@ class TestSpecialistsPage:
1111
class TestSpecialistsPageStructure:
1212
@allure.title("Verify presence and visibility of content on the page")
1313
def test_sp_01_01_verify_page_presence_and_visibility(self, driver, specialists_page_open):
14-
page = SpecialistsPage(driver)
14+
page = sPage(driver)
1515
page_content_presence = page.check_presence_of_page_content()
1616
page_content_visibility = page.check_visibility_of_page_content()
1717
assert page_content_presence, "The page content is absent in DOM"
@@ -20,7 +20,7 @@ def test_sp_01_01_verify_page_presence_and_visibility(self, driver, specialists_
2020
@allure.title("""Verify the composition and visibility of elements
2121
on the 1st-6th levels of nesting on the page""")
2222
def test_sp_01_02_verify_page_structure_and_visibility(self, driver, specialists_page_open):
23-
page = SpecialistsPage(driver)
23+
page = sPage(driver)
2424
structure_of_1st_level = page.get_structure_of_1st_level()
2525
visibility_of_elements_on_1st_level = page.check_elements_visibility_on_1st_level_on_page()
2626
structure_of_2nd_level = page.get_structure_of_2nd_level()
@@ -47,15 +47,15 @@ def test_sp_01_02_verify_page_structure_and_visibility(self, driver, specialists
4747
@allure.title("""Verify presence, visibility of the title, text, link, grid, cards and images
4848
on the 2nd, 3rd, 5th, 6th levels of nesting on the page""")
4949
def test_sp_01_03_verify_page_structural_elements(self, driver, specialists_page_open):
50-
page = SpecialistsPage(driver)
50+
page = sPage(driver)
5151
title_on_2nd_level = page.check_title_presence()
5252
title_visibility = page.check_title_visibility()
5353
text_on_2nd_level = page.check_text_presence()
5454
text_visibility = page.check_text_visibility()
5555
grid_on_2nd_level = page.check_grid_presence()
5656
grid_visibility = page.check_grid_visibility()
57-
link_on_3rd_level = page.check_all_specialists_link_presence()
58-
link_visibility = page.check_all_specialists_link_visibility()
57+
link_on_3rd_level = page.check_all_spec_link_presence()
58+
link_visibility = page.check_all_spec_link_visibility()
5959
cards_on_3rd_level = page.get_list_of_cards()
6060
cards_visibility = page.check_cards_visibility()
6161
images_on_5th_level = page.get_list_of_card_images()
@@ -84,101 +84,91 @@ def test_sp_01_03_verify_page_structural_elements(self, driver, specialists_page
8484
class TestSpecialistPageText:
8585
@allure.title("Verify value of the title of the tab")
8686
def test_sp_02_01_verify_tab_title(self, driver, specialists_page_open):
87-
page = SpecialistsPage(driver)
87+
page = sPage(driver)
8888
tab_title_value = page.get_value_of_tab_title()
8989
assert tab_title_value, "The title value of the tab is empty"
90-
assert tab_title_value in SpecialistsPageData.tab_title, \
91-
"The title value of the tab mismatches the valid value"
90+
assert tab_title_value in sPD.tab_title, "The title value of the tab mismatches the valid value"
9291

9392
@allure.title("Verify value of title with tag 'h2' on the page")
9493
def test_sp_02_02_verify_page_title(self, driver, specialists_page_open):
95-
page = SpecialistsPage(driver)
94+
page = sPage(driver)
9695
title_value = page.get_value_of_page_title()
9796
assert title_value, "The title value on the page is empty"
98-
assert title_value in SpecialistsPageData.page_title, "The title on the page mismatches the valid value"
97+
assert title_value in sPD.page_title, "The title on the page mismatches the valid value"
9998

10099
@allure.title("Verify value of text on the page")
101100
def test_sp_02_03_verify_page_text(self, driver, specialists_page_open):
102-
page = SpecialistsPage(driver)
101+
page = sPage(driver)
103102
text_content = page.get_text_content_on_page()
104103
assert text_content, "Text content on the page is empty"
105-
assert text_content in SpecialistsPageData.text_on_page, "Text content mismatches the valid value"
104+
assert text_content in sPD.text_on_page, "Text content mismatches the valid value"
106105

107106
@allure.title("Verify values of names and professions in specialist cards in the grid")
108107
def test_sp_02_04_verify_name_and_profession_in_cards(self, driver, specialists_page_open):
109-
page = SpecialistsPage(driver)
108+
page = sPage(driver)
110109
name_values = page.get_name_values_in_cards()
111110
profession_values = page.get_profession_values_in_cards()
112111
assert name_values, "Name values in cards are empty"
113-
assert all(element in SpecialistsPageData.specialists_names for element in name_values), \
114-
"Names in specialist cards mismatch valid values"
112+
assert all(element in sPD.spec_names for element in name_values), "Names in cards mismatch valid values"
115113
assert profession_values, "Profession values in cards are empty"
116-
assert all(element in SpecialistsPageData.specialists_professions for element in profession_values), \
117-
"Professions in specialist cards mismatch valid values"
114+
assert all(element in sPD.spec_professions for element in profession_values), \
115+
"Professions in cards mismatch valid values"
118116

119117
@allure.title("Verify text in the 'All Specialists' link")
120118
def test_sp_02_05_verify_text_in_link(self, driver, specialists_page_open):
121-
page = SpecialistsPage(driver)
122-
link_text = page.get_text_in_all_specialists_link()
119+
page = sPage(driver)
120+
link_text = page.get_text_in_all_spec_link()
123121
assert link_text, "Text in the 'All Specialists' link is empty"
124-
assert link_text in SpecialistsPageData.all_specialists_link_text, \
125-
f"Text in the 'All Specialists' link mismatches any valid values"
122+
assert link_text in sPD.all_spec_link_text, "Text in the 'All Specialists' link mismatches any valid values"
126123

127124
class TestSpecialistPageLinks:
128125
@allure.title("Verify clickability, href, status code of the 'All Specialists' link")
129-
def test_sp_03_01_verify_all_specialists_link(self, driver, specialists_page_open):
130-
page = SpecialistsPage(driver)
131-
link_clickability = page.check_all_specialists_link_clickability()
132-
link_href = page.get_all_specialists_link_href()
133-
link_status_code = page.get_all_specialists_link_status_code()
126+
def test_sp_03_01_verify_all_spec_link(self, driver, specialists_page_open):
127+
page = sPage(driver)
128+
link_clickability = page.check_all_spec_link_clickability()
129+
link_href = page.get_all_spec_link_href()
130+
link_status_code = page.get_all_spec_link_status_code()
134131
assert link_clickability, "The 'All Specialists' link is unclickable"
135132
assert link_href, "Link href is empty"
136-
assert link_href == SpecialistsPageData.all_specialists_link_href, \
137-
"The attribute 'href' of the link mismatches the valid value"
138-
assert link_status_code in SpecialistsPageData.all_specialists_link_status_code, \
139-
"The status code of the link mismatches the valid value"
133+
assert link_href in sPD.all_spec_link_href, "The attribute 'href' of the link mismatches the valid value"
134+
assert link_status_code in sPD.all_spec_link_status_code, "The link status code mismatches the valid value"
140135

141136
@allure.title("""Verify that the 'All Specialists' link leads an unauthorized user
142137
to the correct page after clicking""")
143-
def test_sp_03_02_verify_all_specialists_link_leads_unauthorized_user_to_the_correct_page(
144-
self, driver, specialists_page_open):
145-
page = SpecialistsPage(driver)
146-
new_tab_url = page.click_all_specialists_link()
138+
def test_sp_03_02_verify_all_spec_link_navigation_for_unauthorized_user(self, driver, specialists_page_open):
139+
page = sPage(driver)
140+
new_tab_url = page.click_all_spec_link()
147141
text_on_new_tab = page.get_element_text_on_new_tab()
148-
assert new_tab_url == StartUnauthorizedPageData.page_url, \
149-
"The 'All Specialists' link leads to an incorrect page after clicking"
150-
assert text_on_new_tab in StartUnauthorizedPageData.text_on_page["text_in_section1"], \
151-
"The opened page does not load correctly after clicking on the 'All Specialists' link"
142+
assert new_tab_url == suPD.page_url, "The link leads to an incorrect page after clicking"
143+
assert text_on_new_tab in suPD.text_on_page["text_in_section1"], \
144+
"The opened page does not load correctly after clicking on the link"
152145

153146
@allure.title("""Verify that the 'All Specialists' link leads an authorized user
154147
to the correct page after clicking""")
155-
def test_sp_03_03_verify_all_specialists_link_leads_authorized_user_to_the_correct_page(
156-
self, driver, auto_test_user_authorized):
157-
page = SpecialistsPage(driver)
148+
def test_sp_03_03_verify_all_spec_link_navigation_for_authorized_user(self, driver, auto_test_user_authorized):
149+
page = sPage(driver)
158150
page.open_specialists_page()
159-
new_tab_url = page.click_all_specialists_link()
151+
new_tab_url = page.click_all_spec_link()
160152
text_on_new_tab = page.get_value_of_page_title()
161-
assert new_tab_url == SpecialistsPageData.page_url, \
162-
"The 'All Specialists' link leads to an incorrect page after clicking"
163-
assert text_on_new_tab in SpecialistsPageData.page_title, \
164-
"The opened page does not load correctly after clicking on the 'All Specialists' link"
153+
assert new_tab_url == sPD.page_url, "The link leads to an invalid page after clicking"
154+
assert text_on_new_tab in sPD.page_title, "The opened page does not load correctly after clicking the link"
165155

166156
class TestSpecialistCardImages:
167157
@allure.title("Verify attributes of images in specialist cards in the grid")
168158
def test_sp_04_01_verify_images_attributes_in_cards(self, driver, specialists_page_open):
169-
page = SpecialistsPage(driver)
159+
page = sPage(driver)
170160
images_src = page.get_images_src()
171161
images_alt = page.get_images_alt()
172162
assert images_src, "The 'src' attribute value of some card images is empty"
173-
assert all(element in SpecialistsPageData.images_src for element in images_src), \
163+
assert all(element in sPD.images_src for element in images_src), \
174164
"The 'src' attribute of the card images mismatches valid values"
175165
assert images_alt, "The 'alt' attribute value of some card images is empty"
176-
assert all(element == SpecialistsPageData.images_alt for element in images_alt), \
166+
assert all(element == sPD.images_alt for element in images_alt), \
177167
"The 'alt' attribute value of some card images is empty or mismatches valid values"
178168

179169
@allure.title("Verify sizes of images in specialist cards in the grid")
180170
def test_sp_04_02_verify_images_sizes_in_cards(self, driver, specialists_page_open):
181-
page = SpecialistsPage(driver)
171+
page = sPage(driver)
182172
images_size = page.get_images_sizes()
183173
images_size_changed = page.check_size_changes_of_images()
184174
assert images_size != 0, "Images in specialist cards have not sizes"

0 commit comments

Comments
 (0)