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
4 changes: 4 additions & 0 deletions locators/exercises_ru_words_page_locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class ExercisesRuWordsPageLocators:
PAGE_LIST1_3 = (By.XPATH, '(//ul[@aria-label="Breadcrumbs"]//a)[3]')
PAGE_LIST2 = (By.XPATH, "//aside//button")
PAGE_LIST3 = (By.XPATH, '//div[contains(@class, "series-page")]//a')
PAGE_LIST3_1 = (By.XPATH, '(//div[contains(@class, "series-page")]//a)[1]')
PAGE_LIST3_2 = (By.XPATH, '(//div[contains(@class, "series-page")]//a)[2]')
PAGE_LIST3_3 = (By.XPATH, '(//div[contains(@class, "series-page")]//a)[3]')
PAGE_LIST3_4 = (By.XPATH, '(//div[contains(@class, "series-page")]//a)[4]')
# PAGE_LIST3 = (By.XPATH, "//main//div/a")
CARD_IMAGES_LIST4 = (By.XPATH, '//div[contains(@style, "svg")]')

Expand Down
22 changes: 11 additions & 11 deletions pages/base_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ def get_current_url(self):
print('Current url: ' + get_url)
return get_url

def element_is_present(self, locator):
return Wait(self.driver, self.timeout).until(
ec.presence_of_element_located(locator), message=f"Can't find element by locator {locator}")

def element_is_clickable(self, locator):
return Wait(self.driver, self.timeout).until(
ec.element_to_be_clickable(locator), message=f"Can't find element by locator {locator}")

def element_is_present_and_clickable(self, locator):
return (Wait(self.driver, self.timeout).until(
ec.visibility_of_element_located(locator), message=f"Can't find element by locator {locator}") and
Expand All @@ -38,26 +46,18 @@ def element_is_visible(self, locator):
return Wait(self.driver, self.timeout).until(
ec.visibility_of_element_located(locator), message=f"Can't find element by locator {locator}")

def elements_are_visible(self, locator):
return Wait(self.driver, self.timeout).until(
ec.visibility_of_all_elements_located(locator),
message=f"Can't find elements by locator {locator}")

def element_is_not_visible(self, locator):
return Wait(self.driver, self.timeout).until(
ec.invisibility_of_element_located(locator), message=f"The element located by {locator} is invisible")

def element_is_present(self, locator):
return Wait(self.driver, self.timeout).until(
ec.presence_of_element_located(locator), message=f"Can't find element by locator {locator}")

def elements_are_present(self, locator):
return Wait(self.driver, self.timeout).until(
ec.presence_of_all_elements_located(locator), message=f"Can't find elements by locator {locator}")

def element_is_clickable(self, locator):
def elements_are_visible(self, locator):
return Wait(self.driver, self.timeout).until(
ec.element_to_be_clickable(locator), message=f"Can't find element by locator {locator}")
ec.visibility_of_all_elements_located(locator),
message=f"Can't find elements by locator {locator}")

def go_to_element(self, element):
return self.driver.execute_script("arguments[0].scrollIntoView({ block: 'center'});", element)
Expand Down
40 changes: 40 additions & 0 deletions pages/exercises_ru_words_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,43 @@ def click_on_group_links(self):
opened_pages.append(self.get_current_tab_url())
print(*opened_pages, sep='\n')
return opened_pages

@allure.step("Click on subgroup link 'Family' and thereby open corresponding web pages in the same tab")
def click_on_subgroup_link_family(self):
opened_pages = []
self.element_is_present_and_clickable(self.locators.PAGE_LIST3_1).click()
time.sleep(1)
opened_pages.append(self.get_current_tab_url())
self.driver.back()
# self.element_is_present_and_clickable(self.locators.PAGE_LIST3_2).click()
opened_pages.append(self.get_current_tab_url())
# self.driver.back()
print(*opened_pages, sep='\n')
return opened_pages

@allure.step("""Click on subgroup links 'Beloved Home', 'Food', 'Clothes'
and thereby open corresponding web pages in the same tab""")
def click_on_subgroup_link_beloved_home_food_clothes(self):
opened_pages = []
self.element_is_present_and_clickable(self.locators.PAGE_LIST3_2).click()
time.sleep(1)
opened_pages.append(self.get_current_tab_url())
self.driver.back()
time.sleep(1)
opened_pages.append(self.get_current_tab_url())
self.element_is_present_and_clickable(self.locators.PAGE_LIST3_3).click()
time.sleep(1)
opened_pages.append(self.get_current_tab_url())
self.driver.back()
time.sleep(1)
opened_pages.append(self.get_current_tab_url())
self.element_is_present_and_clickable(self.locators.PAGE_LIST3_4).click()
time.sleep(1)
opened_pages.append(self.get_current_tab_url())
self.driver.back()
time.sleep(1)
opened_pages.append(self.get_current_tab_url())
print(*opened_pages, sep='\n')
return opened_pages


2 changes: 1 addition & 1 deletion test_data/exercises_ru_words_page_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ExercisesRuWordsPageData:
f"{Links.URL_GROUPS_PAGE}/2/series/6"
]

subgroup_links_href = [
subgroup_link_urls = [
f"{ExUrls.URL_EXERCISES_RU_WORDS_PAGE}/subgroup/1",
f"{ExUrls.URL_EXERCISES_RU_WORDS_PAGE}/subgroup/2",
f"{ExUrls.URL_EXERCISES_RU_WORDS_PAGE}/subgroup/3",
Expand Down
10 changes: 9 additions & 1 deletion tests/exercises_ru_words_page_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_erw_03_03_verify_subgroup_links(self, driver, exercises_ru_words_page_o
assert subgroup_link_titles, "Subgroup link titles values are empty"
assert all(element in ExRuWoPaData.subgroup_link_titles for element in subgroup_link_titles), \
"Subgroup link titles mismatch valid values"
assert all(href in ExRuWoPaData.subgroup_links_href for href in subgroup_links_href), \
assert all(href in ExRuWoPaData.subgroup_link_urls for href in subgroup_links_href), \
"Attributes 'href' of subgroup links mismatch valid values"
assert all(element == ExRuWoPaData.links_status_code for element in subgroup_links_status_codes), \
"Status codes of subgroup links mismatch valid values"
Expand All @@ -158,3 +158,11 @@ def test_erw_03_05_verify_group_links_lead_to_correct_pages(self, driver, exerci
assert opened_pages, "Transitions to pages have not performed"
assert all(page in ExRuWoPaData.group_link_urls for page in opened_pages), \
"Some group links lead to incorrect pages after clicking"

@allure.title("Verify if subgroup links lead to correct pages after clicking")
def test_erw_03_06_verify_subgroup_links_lead_to_correct_pages(self, driver, exercises_ru_words_page_open):
page = ExercisesRuWordsPage(driver)
opened_pages1 = page.click_on_subgroup_link_family()
opened_pages2_4 = page.click_on_subgroup_link_beloved_home_food_clothes()
assert opened_pages1, "Transition to the page has not performed"
assert opened_pages2_4, "Transitions to pages have not performed"
Loading