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
1 change: 0 additions & 1 deletion locators/exercises_ru_words_page_locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class ExercisesRuWordsPageLocators:
PAGE_SIXTH_LEVEL_ELEMENTS = (By.XPATH, "//main/*/*/*/*/*/*")
PAGE_SEVENTH_LEVEL_ELEMENTS = (By.XPATH, "//main/*/*/*/*/*/*/*")
PAGE_LIST1 = (By.XPATH, '//ul[@aria-label="Breadcrumbs"]//a')
# PAGE_LIST1 = (By.XPATH, "//main//div/li")
PAGE_LIST2 = (By.XPATH, "//aside//button")
PAGE_LIST3 = (By.XPATH, '//div[contains(@class, "series-page")]//a')
# PAGE_LIST3 = (By.XPATH, "//main//div/a")
Expand Down
30 changes: 19 additions & 11 deletions pages/exercises_ru_words_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def check_elements_visibility_on_7th_level(self):
return all(element.is_displayed() for element in self.get_structure_of_7th_level())

@allure.step("Check the list1 on the 4th level of nesting is present on the page")
def check_list1_presence(self):
def get_list1_of_links(self):
elements = self.elements_are_present(self.locators.PAGE_LIST1)
# tags = [element.tag_name for element in elements]
return elements
Expand All @@ -99,7 +99,7 @@ def check_list1_visibility(self):
return self.element_is_visible(self.locators.PAGE_LIST1)

@allure.step("Check the list2 on the 4th level of nesting is present on the page")
def check_list2_presence(self):
def get_list2_of_links(self):
elements = self.elements_are_present(self.locators.PAGE_LIST2)
# tags = [element.tag_name for element in elements]
return elements
Expand All @@ -109,7 +109,7 @@ def check_list2_visibility(self):
return self.element_is_visible(self.locators.PAGE_LIST2)

@allure.step("Check the list3 on the 5th level of nesting is present on the page")
def check_list3_presence(self):
def get_list3_of_links(self):
elements = self.elements_are_present(self.locators.PAGE_LIST3)
# tags = [element.tag_name for element in elements]
return elements
Expand All @@ -119,7 +119,7 @@ def check_list3_visibility(self):
return self.element_is_visible(self.locators.PAGE_LIST3)

@allure.step("Check the list4 on the 6th level of nesting is present on the page")
def check_list4_presence(self):
def get_list4_of_links(self):
elements = self.elements_are_present(self.locators.CARD_IMAGES_LIST4)
# tags = [element.tag_name for element in elements]
# style = [element.get_attribute("style") for element in elements]
Expand All @@ -140,35 +140,43 @@ def get_value_of_tab_title(self):

@allure.step("Get value of the breadcrumbs on the page")
def get_value_of_breadcrumbs(self):
breadcrumbs_text = [element.text for element in self.check_list1_presence()]
breadcrumbs_text = [element.text for element in self.get_list1_of_links()]
print(len(breadcrumbs_text), breadcrumbs_text, sep='\n')
return breadcrumbs_text

@allure.step("Get text in group links on the page")
def get_group_links_text(self):
links_text = [element.text for element in self.check_list2_presence()]
links_text = [element.text for element in self.get_list2_of_links()]
print(len(links_text), *links_text, sep='\n')
return links_text

@allure.step("Get text in cards on the page")
def get_cards_text(self):
cards_text = [element.text for element in self.check_list3_presence()]
cards_text = [element.text for element in self.get_list3_of_links()]
print(len(cards_text), cards_text, sep='\n')
return cards_text

# Checking links on the page
@allure.step("Check if breadcrumbs are clickable")
def check_breadcrumbs_clickability(self):
return all(link.is_enabled() for link in self.check_list1_presence())
return all(link.is_enabled() for link in self.get_list1_of_links())

@allure.step("Get attribute 'href' of links in breadcrumbs")
def get_breadcrumbs_links_href(self):
return [element.get_attribute("href") for element in self.check_list1_presence()]
breadcrumbs_links_href = [element.get_attribute("href") for element in self.get_list1_of_links()]
print(len(breadcrumbs_links_href), *breadcrumbs_links_href, sep='\n')
return breadcrumbs_links_href

@allure.step("Get status code of links")
@allure.step("Get status code of links in breadcrumbs")
def get_link_status_codes_in_breadcrumbs(self):
return [requests.head(link_href).status_code for link_href in self.get_breadcrumbs_links_href()]

@allure.step("Check if group links are clickable")
def check_group_links_clickability(self):
return all(link.is_enabled() for link in self.check_list2_presence())
return all(link.is_enabled() for link in self.get_list2_of_links())

@allure.step("Get attribute 'title' of group links")
def get_group_link_titles(self):
group_link_titles = [element.get_attribute("title") for element in self.get_list2_of_links()]
print(len(group_link_titles), *group_link_titles, sep='\n')
return group_link_titles
7 changes: 7 additions & 0 deletions test_data/exercises_ru_words_page_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ class ExercisesRuWordsPageData:
tab_title_ru = "Речевые упражнения (готовы для занятий) | BrainUp"

breadcrumbs = ['', 'Речевые упражнения (готовы для занятий)', 'Слова']

group_links_text = ['СЛОВА', 'СЛОВА КОРОЛЁВОЙ', 'ПОХОЖИЕ ФРАЗЫ', 'ГРУППА СЛОВ', 'ПРЕДЛОЖЕНИЯ',
'ДИХОТИЧЕСКОЕ СЛУШАНИЕ', 'СЛОВА С ЧАСТОТНОЙ ГРУППИРОВКОЙ']

cards_text = ['Семья', 'Любимый дом', 'Что я ем', 'Одежда', 'В школе', 'Математика', 'Домашние питомцы',
'Мир животных', 'Транспорт', 'Цвета и форма', 'В городе', 'В деревне', 'На прогулке', 'Погода',
'Стану кем хочу', 'Тело человека', 'Развлечения', 'Путешествия', 'В больнице', 'Что я чувствую',
Expand All @@ -18,6 +20,11 @@ class ExercisesRuWordsPageData:
'Спорт', 'В магазине', 'Парнокопытные', 'Породы собак', 'Канцелярские принадлежности', 'Цветы',
'Русский язык и литература', 'Физика', 'Биология', 'Инструменты']

group_link_titles = ['Распознавание слов',
'Слова по методическому пособию Инны Васильевны Королевой Учусь слушать и говорить',
'Распознавание похожих фраз', 'Распознавание последовательности слов',
'Распознавание предложений', 'Дихотическое слушание', 'Слова с частотной группировкой']

breadcrumbs_links_href = [
f"{Links.URL_MAIN_PAGE}groups",
f"{Links.URL_MAIN_PAGE}groups/2",
Expand Down
38 changes: 20 additions & 18 deletions tests/exercises_ru_words_page_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Auto tests for verifying web elements on the 'Exercises "Words"' page on the 'ru' local"""
import allure
from pages.exercises_ru_words_page import ExercisesRuWordsPage
from test_data.exercises_ru_words_page_data import ExercisesRuWordsPageData
from test_data.exercises_ru_words_page_data import ExercisesRuWordsPageData as ExRuWoPaData


@allure.epic("The Exercises 'Words' Page on the 'ru' local")
Expand Down Expand Up @@ -51,13 +51,13 @@ def test_erw_01_02_verify_page_structure_and_visibility(self, driver, exercises_
@allure.title("Verify presence, visibility of lists on the page")
def test_erw_01_03_verify_page_structural_elements(self, driver, exercises_ru_words_page_open):
page = ExercisesRuWordsPage(driver)
list1_on_4th_level = page.check_list1_presence()
list1_on_4th_level = page.get_list1_of_links()
list1_visibility = page.check_list1_visibility()
list2_on_4th_level = page.check_list2_presence()
list2_on_4th_level = page.get_list2_of_links()
list2_visibility = page.check_list2_visibility()
list3_on_5th_level = page.check_list3_presence()
list3_on_5th_level = page.get_list3_of_links()
list3_visibility = page.check_list3_visibility()
list4_on_6th_level = page.check_list4_presence()
list4_on_6th_level = page.get_list4_of_links()
list4_visibility = page.check_list4_visibility()
assert list1_on_4th_level, "The list1 on the 4th level is absent on the page"
assert list1_visibility, "The list1 on the 4th level is invisible"
Expand All @@ -74,32 +74,30 @@ def test_erw_02_01_verify_tab_title(self, driver, exercises_ru_words_page_open):
page = ExercisesRuWordsPage(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 == ExercisesRuWordsPageData.tab_title_ru, \
"The title on the tab doesn't match the valid value"
assert tab_title_value == ExRuWoPaData.tab_title_ru, "The title on the tab doesn't match the valid value"

@allure.title("Verify value of the breadcrumbs on the page")
def test_erw_02_02_verify_page_breadcrumbs_text(self, driver, exercises_ru_words_page_open):
page = ExercisesRuWordsPage(driver)
breadcrumbs_text = page.get_value_of_breadcrumbs()
assert breadcrumbs_text, "The breadcrumbs value on the page are empty"
assert all(element in ExercisesRuWordsPageData.breadcrumbs for element in breadcrumbs_text), \
"The breadcrumbs on the page mismatch the valid values"
assert all(text in ExRuWoPaData.breadcrumbs for text in breadcrumbs_text), \
"Text in breadcrumbs mismatches valid values"

@allure.title("Verify text in group links on the page")
def test_erw_02_03_verify_group_links_text(self, driver, exercises_ru_words_page_open):
page = ExercisesRuWordsPage(driver)
links_text = page.get_group_links_text()
assert links_text, "Text in group links is absent"
assert all(element in ExercisesRuWordsPageData.group_links_text for element in links_text), \
"Text in group links mismatch the valid values"
assert all(text in ExRuWoPaData.group_links_text for text in links_text), \
"Text in group links mismatches valid values"

@allure.title("Verify text in cards on the page")
def test_erw_02_04_verify_cards_text(self, driver, exercises_ru_words_page_open):
page = ExercisesRuWordsPage(driver)
cards_text = page.get_cards_text()
assert cards_text, "Text in cards is absent"
assert all(element in ExercisesRuWordsPageData.cards_text for element in cards_text), \
"Text in cards mismatch the valid values"
assert all(text in ExRuWoPaData.cards_text for text in cards_text), "Text in cards mismatches valid values"

class TestExercisesRuWordsPageLinks:
@allure.title("Verify clickability, href, status code of links in breadcrumbs on the page")
Expand All @@ -109,13 +107,17 @@ def test_erw_03_01_verify_breadcrumbs_links(self, driver, exercises_ru_words_pag
breadcrumbs_links_href = page.get_breadcrumbs_links_href()
breadcrumbs_link_status_codes = page.get_link_status_codes_in_breadcrumbs()
assert breadcrumbs_clickability, "Breadcrumbs are unclickable"
assert all(href in ExercisesRuWordsPageData.breadcrumbs_links_href for href in breadcrumbs_links_href), \
"Attributes 'href' of links in breadcrumbs mismatch the valid values"
assert all(el == ExercisesRuWordsPageData.links_status_code for el in breadcrumbs_link_status_codes), \
assert all(href in ExRuWoPaData.breadcrumbs_links_href for href in breadcrumbs_links_href), \
"Attributes 'href' of links in breadcrumbs mismatch valid values"
assert all(element == ExRuWoPaData.links_status_code for element in breadcrumbs_link_status_codes), \
"Status codes of links in breadcrumbs mismatch valid values"

@allure.title("Verify clickability of group links on the page")
def test_erw_03_02_verify_group_links_text(self, driver, exercises_ru_words_page_open):
@allure.title("Verify clickability, titles of group links on the page")
def test_erw_03_02_verify_group_links(self, driver, exercises_ru_words_page_open):
page = ExercisesRuWordsPage(driver)
group_links_clickability = page.check_group_links_clickability()
group_link_titles = page.get_group_link_titles()
assert group_links_clickability, "Group links are unclickable"
assert group_link_titles, "Group link titles values are empty"
assert all(element in ExRuWoPaData.group_link_titles for element in group_link_titles), \
"Group link titles mismatch valid values"
Loading