Skip to content

Commit 8838aae

Browse files
Merge pull request #716 from Brain-up/issue_268
Issue_268_HEADER_links
2 parents b2ee720 + c88f294 commit 8838aae

2 files changed

Lines changed: 58 additions & 38 deletions

File tree

pages/header_page.py

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def check_elements_invisibility_on_6th_level_in_header(self):
7676
def get_list_of_links_unauth(self):
7777
return self.elements_are_present(self.locators.HEADER_LINKS_UNAUTH)
7878

79-
@allure.step("Get the list of links on different levels of nesting in the Header for an authorized user")
80-
def get_list_of_links_auth(self):
79+
@allure.step("Get the list of links on different levels of nesting in the Header for an authorized user -- ACTUAL")
80+
def get_links_auth_list(self):
8181
return self.elements_are_present(self.locators1.HEADER_LINKS_AUTH)
8282

8383
@allure.step("""Get the list of the 'About', 'Telegram', 'Registration', 'Logo' links (direct links) in the Header
@@ -89,25 +89,37 @@ def get_list_of_direct_links_unauth(self):
8989
direct_links.append(links[i])
9090
return direct_links
9191

92-
@allure.step("""Get the list of the 'Groups', 'Statistics', 'About', 'Telegram', 'Profile', 'Logo' links
93-
(direct links) in the Header for an authorized user""")
94-
def get_list_of_direct_links_auth(self):
95-
links = self.get_list_of_links_auth()
92+
@allure.step("""Get the list of the 'Groups', 'Statistics' (x2), 'About', 'Telegram', 'Profile', 'Logo' links
93+
(direct links) in the Header for an AUTHORIZED user -- ACTUAL""")
94+
def get_direct_links_auth_list(self):
95+
links = self.get_links_auth_list()
9696
direct_links = []
97-
# for i in [1, 2, 3, 4, 11, 0]:
98-
for i in [1, 2, 3, 4, 17, 0]:
97+
for i in [1, 2, 3, 4, 16, 17, 0]:
9998
direct_links.append(links[i])
100-
# print(*direct_links)
10199
return direct_links
102100

101+
@allure.step("""Get the list of the 'Groups', 'Statistics' (x2), 'About', 'Profile', 'Logo' links
102+
(direct internal links) in the Header for an AUTHORIZED user -- ACTUAL""")
103+
def get_direct_internal_links_auth_list(self):
104+
direct_links = self.get_direct_links_auth_list()
105+
direct_internal_links = []
106+
for i in [0, 1, 2, 4, 5, 6]:
107+
direct_internal_links.append(direct_links[i])
108+
att1 = [element.get_attribute("href") for element in direct_links]
109+
print(*att1, len(att1), sep='\n')
110+
att2 = [element.get_attribute("href") for element in direct_internal_links]
111+
print(*att2, len(att2), sep='\n')
112+
return direct_internal_links
113+
114+
103115
@allure.step("Check the 'About', 'Telegram', 'Registration', 'Logo' links are visible for an unauthorized user")
104116
def check_direct_links_visibility_unauth(self):
105117
return all(link.is_displayed() for link in self.get_list_of_direct_links_unauth())
106118

107119
@allure.step("""Check the 'Groups', 'Statistics', 'About', 'Telegram', 'Registration', 'Logo' links are visible "
108120
for an authorized user""")
109121
def check_direct_links_visibility_auth(self):
110-
return all(link.is_displayed() for link in self.get_list_of_direct_links_auth())
122+
return all(link.is_displayed() for link in self.get_direct_links_auth_list())
111123

112124
@allure.step("""Get the list of the 'Contacts', 'Specialists', 'Contributors', 'Used Resources', "
113125
'Donate', 'GitHub' links in the 'More' dropdown in the Header for every user""")
@@ -138,7 +150,12 @@ def check_links_visibility_in_more(self):
138150
@allure.step("""Get the list of the 'Contacts', 'Specialists', 'Contributors', 'Used Resources' links "
139151
(internal links) in the 'More' dropdown for every user""")
140152
def get_list_of_internal_links_in_more(self):
141-
return self.get_list_of_links_in_more()[2:]
153+
links = self.get_list_of_links_in_more()[2:]
154+
print(links)
155+
att = [element.get_attribute("href") for element in links]
156+
print(*att, len(att), sep='\n')
157+
return links
158+
# return self.get_list_of_links_in_more()[2:]
142159

143160
@allure.step("""Get the list of the 'Donate', 'GitHub' links (external links)
144161
in the 'More' dropdown for every user""")
@@ -183,7 +200,7 @@ def get_list_of_direct_internal_links_unauth(self):
183200
@allure.step("""Get the list of the 'Statistics', 'Groups', 'About', 'Profile', 'Logo' links (direct internal links)
184201
in the Header for an authorized user""")
185202
def get_list_of_direct_internal_links_auth(self):
186-
links = self.get_list_of_links_auth()
203+
links = self.get_links_auth_list()
187204
direct_internal_links = []
188205
for i in [2, 1, 3, 11, 0]:
189206
direct_internal_links.append(links[i])
@@ -295,10 +312,9 @@ def get_text_in_direct_links_unauth(self):
295312
@allure.step("""Get text in the 'Groups', 'Statistics', 'About', 'Telegram' links in the Header
296313
for an authorized user""")
297314
def get_text_in_direct_links_auth(self):
298-
direct_links_text = [link.text for link in self.get_list_of_direct_links_auth()[:4]]
315+
direct_links_text = [link.text for link in self.get_direct_links_auth_list()[:4]]
299316
print(*direct_links_text, len(direct_links_text), sep='\n')
300317
return direct_links_text
301-
# return [link.text for link in self.get_list_of_direct_links_auth()[:5]]
302318

303319
@allure.step("""Get text in the 'Donate', 'GitHub', 'Contacts', 'Specialists', 'Contributors', 'Used Resources'
304320
links in the Header""")
@@ -328,7 +344,7 @@ def check_links_clickability_unauth(self):
328344

329345
@allure.step("Check if links are clickable in the Header for an authorized user")
330346
def check_links_clickability_auth(self):
331-
return all(link.is_enabled() for link in self.get_list_of_links_auth())
347+
return all(link.is_enabled() for link in self.get_links_auth_list())
332348

333349
@allure.step("Get attribute 'title' of the 'Telegram' link in the Header")
334350
def get_tg_link_title(self):
@@ -340,7 +356,7 @@ def get_links_href_unauth(self):
340356

341357
@allure.step("Get attribute 'href' of links in the Header for an authorized user")
342358
def get_links_href_auth(self):
343-
att = [element.get_attribute("href") for element in self.get_list_of_links_auth()]
359+
att = [element.get_attribute("href") for element in self.get_links_auth_list()]
344360
# print(*att, len(att), sep='\n')
345361
return att
346362
# return [element.get_attribute("href") for element in self.get_list_of_links_auth()]
@@ -371,8 +387,8 @@ def click_on_internal_links_in_header_unauth(self):
371387
opened_pages.append(self.get_current_tab_url())
372388
return opened_pages
373389

374-
@allure.step("""Click on internal links in the Header and thereby open corresponding web pages in the same tab
375-
for an authorized user""")
390+
@allure.step("""Click on internal links in the Header
391+
and thereby open corresponding web pages in the same tab for an AUTHORIZED user -- unusable till changing UI""")
376392
def click_on_internal_links_in_header_auth1(self):
377393
opened_pages = []
378394
# Click on the 'Statistics', 'Groups', 'About', 'Profile', 'Logo' links
@@ -392,7 +408,7 @@ def click_on_internal_links_in_header_auth1(self):
392408
return opened_pages
393409

394410
@allure.step("""Click on direct internal links in the Header
395-
and thereby open corresponding web pages in the same tab for an authorized user""")
411+
and thereby open corresponding web pages in the same tab for an AUTHORIZED user""")
396412
def click_on_direct_internal_links_in_header_auth(self):
397413
opened_pages = []
398414
current_url = self.get_current_tab_url()
@@ -430,32 +446,32 @@ def click_on_direct_internal_links_in_header_auth(self):
430446

431447
return opened_pages
432448

433-
@allure.step("Click on the 'Groups' link #2 for authorized user")
449+
@allure.step("Click on the 'Groups' link #2 for AUTHORIZED user")
434450
def click_on_Groups_link_auth2(self):
435451
self.click_more_button()
436452
self.element_is_present_and_clickable(self.locators1.LINK_GROUPS_AUTH2).click()
437453
current_tab_url = self.get_current_tab_url()
438454
print(current_tab_url)
439455
return current_tab_url
440456

441-
@allure.step("Click on the 'Statistics' link #2 for authorized user")
457+
@allure.step("Click on the 'Statistics' link #2 for AUTHORIZED user")
442458
def click_on_Statistics_link_auth2(self):
443459
self.click_more_button()
444460
self.element_is_present_and_clickable(self.locators1.LINK_STATISTICS_AUTH2).click()
445461
current_tab_url = self.get_current_tab_url()
446462
# print(current_tab_url)
447463
return current_tab_url
448464

449-
@allure.step("Click on the 'About' link #2 for authorized user")
465+
@allure.step("Click on the 'About' link #2 for AUTHORIZED user")
450466
def click_on_About_link_auth2(self):
451467
self.click_more_button()
452468
self.element_is_present_and_clickable(self.locators1.LINK_ABOUT_AUTH2).click()
453469
current_tab_url = self.get_current_tab_url()
454470
print(current_tab_url)
455471
return current_tab_url
456472

457-
@allure.step("""Click on external links in the Header and thereby open corresponding web pages on new tabs
458-
for authorized user -- unusable till changing UI""")
473+
@allure.step("""Click on external links in the Header
474+
and thereby open corresponding web pages on new tabs for AUTHORIZED user -- unusable till changing UI""")
459475
def click_on_auth_external_links_in_header(self):
460476
opened_pages = []
461477
# Click on the 'Telegram' link
@@ -474,15 +490,15 @@ def click_on_auth_external_links_in_header(self):
474490
print(*opened_pages)
475491
return opened_pages
476492

477-
@allure.step("Click on the 'Telegram' link #1 for authorized user")
493+
@allure.step("Click on the 'Telegram' link #1 for AUTHORIZED user")
478494
def click_on_Telegram_link_auth1(self):
479495
self.element_is_present_and_clickable(self.locators1.LINK_TELEGRAM_AUTH).click()
480496
self.driver.switch_to.window(self.driver.window_handles[1])
481497
current_tab_url = self.get_current_tab_url()
482498
self.driver.switch_to.window(self.driver.window_handles[0])
483499
return current_tab_url
484500

485-
@allure.step("Click on the 'Telegram' link #2 for authorized user")
501+
@allure.step("Click on the 'Telegram' link #2 for AUTHORIZED user")
486502
def click_on_Telegram_link_auth2(self):
487503
self.click_more_button()
488504
self.element_is_present_and_clickable(self.locators1.LINK_TELEGRAM_AUTH2).click()
@@ -491,7 +507,7 @@ def click_on_Telegram_link_auth2(self):
491507
self.driver.switch_to.window(self.driver.window_handles[0])
492508
return current_tab_url
493509

494-
@allure.step("Click on the 'Donate' link for authorized user")
510+
@allure.step("Click on the 'Donate' link for AUTHORIZED user")
495511
def click_on_Donate_link_auth(self):
496512
self.click_more_button()
497513
self.element_is_present_and_clickable(self.locators1.LINK_DONATE_AUTH).click()
@@ -500,7 +516,7 @@ def click_on_Donate_link_auth(self):
500516
self.driver.switch_to.window(self.driver.window_handles[0])
501517
return current_tab_url
502518

503-
@allure.step("Click on the 'GitHub' link for authorized user")
519+
@allure.step("Click on the 'GitHub' link for AUTHORIZED user")
504520
def click_on_GitHub_link_auth(self):
505521
self.click_more_button()
506522
self.element_is_present_and_clickable(self.locators1.LINK_GITHUB_AUTH).click()
@@ -511,8 +527,8 @@ def click_on_GitHub_link_auth(self):
511527
print(self.get_current_tab_url())
512528
return current_tab_url
513529

514-
@allure.step("""Click on external links in the Header and thereby open corresponding web pages on new tabs
515-
for unauthorized user""")
530+
@allure.step("""Click on external links in the Header
531+
and thereby open corresponding web pages on new tabs for unauthorized user""")
516532
def click_on_unauth_external_links_in_header(self):
517533
opened_pages = []
518534
# Click on the 'Telegram' link

tests/header_test.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ def test_hpa_01_02_verify_auth_header_structure_and_visibility(self, driver, aut
253253
@allure.title("Verify presence, visibility of links, buttons in the Header for an authorized user")
254254
def test_hpa_01_03_verify_auth_header_structural_elements(self, driver, auto_test_user_authorized):
255255
page = hPage(driver)
256-
header_links = page.get_list_of_links_auth()
257-
header_direct_links = page.get_list_of_direct_links_auth()
256+
header_links = page.get_links_auth_list()
257+
header_direct_links = page.get_direct_links_auth_list()
258258
header_direct_links_visibility = page.check_direct_links_visibility_auth()
259259
links_in_more_presence = page.get_list_of_links_in_more()
260260
links_in_more_invisibility = page.check_links_invisibility_in_more()
@@ -335,15 +335,19 @@ def test_hpa_03_01_verify_auth_header_links(self, driver, auto_test_user_authori
335335
"Status codes of links mismatch valid values"
336336

337337
@pytest.mark.skip
338-
@allure.title("""test_hpa.03.02 Verify if internal links in the Header for an authorized user
339-
lead to correct pages after clicking""")
340-
def test_hpa_03_02_verify_auth_internal_links_lead_to_proper_pages(self, driver, auto_test_user_authorized):
338+
@allure.title("""test_hpa.03.02 Verify the list of internal links in the Header
339+
for an authorized user""")
340+
def test_hpa_03_02_verify_auth_internal_links_in_more(self, driver, auto_test_user_authorized):
341341
page = hPage(driver)
342342
internal_links_in_more = page.get_list_of_internal_links_in_more()
343-
opened_pages = page.click_on_internal_links_in_header_auth1()
344343
assert internal_links_in_more, "Internal links are not collected in the list"
345-
assert all(element in hPD.set_auth for element in opened_pages), \
346-
"Some of internal links lead to incorrect pages after clicking"
344+
345+
@allure.title("""test_hpa.03.02.00 Verify the list of direct internal links in the Header
346+
for an authorized user """)
347+
def test_hpa_03_02_00_verify_auth_direct_internal_links_list(self, driver, auto_test_user_authorized):
348+
page = hPage(driver)
349+
direct_internal_links = page.get_direct_internal_links_auth_list()
350+
assert direct_internal_links, "Links are not collected in the list"
347351

348352
@allure.title("""test_hpa.03.02.01 Verify if 5 direct internal links in the Header for an authorized user
349353
lead to correct pages after clicking""")

0 commit comments

Comments
 (0)