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: 1 addition & 0 deletions locators/groups_page_locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class GroupsPageLocators:
PAGE_TILES = (By.CSS_SELECTOR, ".list-item")
PAGE_TITLE = (By.TAG_NAME, "h3")
PAGE_SUBTITLES = (By.XPATH, "//button/h4")
PAGE_SUBTITLE2 = (By.XPATH, "(//button/h4)[2]")


class HeaderLocators:
Expand Down
53 changes: 36 additions & 17 deletions pages/groups_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,49 +171,71 @@ def get_links_status_codes(self):
@allure.step("Click on links on the 'ru' local and thereby open corresponding web pages in the same tab")
def click_on_links_on_ru_local(self):
opened_pages = []
starting_url = self.driver.current_url
print(starting_url)

link1 = self.element_is_present_and_clickable(self.locators.PAGE_LINK1)
current_url = self.driver.current_url
# current_url = self.driver.current_url
link1.click()
Wait(self.driver, 10).until(EC.url_changes(current_url))

# Waiting for the first URL change (intermediate page)
Wait(self.driver, 10).until(EC.url_changes(starting_url))
intermediate_url = self.driver.current_url
print(intermediate_url)

# Waiting for the second URL change (aimed page)
Wait(self.driver, 10).until(EC.url_changes(intermediate_url))
current_url = self.driver.current_url
print(current_url)

opened_pages.append(self.get_current_tab_url())

self.element_is_present_and_clickable(self.locators1.LOGO_LINK).click()
starting_url = self.driver.current_url
print(starting_url)

# Waiting for the starting page loading
Wait(self.driver, 10).until(EC.presence_of_element_located((By.TAG_NAME, "h3")))

link2 = self.element_is_present_and_clickable(self.locators.PAGE_LINK2)
current_url = self.driver.current_url
# current_url = self.driver.current_url
link2.click()
Wait(self.driver, 10).until(EC.url_changes(current_url))

# Waiting for the first URL change (intermediate page)
Wait(self.driver, 10).until(EC.url_changes(starting_url))
intermediate_url = self.driver.current_url
print(intermediate_url)

# Waiting for the second URL change (aimed page)
Wait(self.driver, 10).until(EC.url_changes(intermediate_url))
current_url = self.driver.current_url
print(current_url)

# Wait(self.driver, 10).until(EC.url_changes(current_url))

opened_pages.append(self.get_current_tab_url())
print(opened_pages)

return opened_pages

@allure.step("Click on links on the 'en' local and thereby open corresponding web pages in the same tab")
def click_on_links_on_en_local(self):
opened_pages = []
starting_url = self.driver.current_url
print(starting_url)

link1 = self.element_is_present_and_clickable(self.locators.PAGE_LINK1)
link1.click()

# Waiting for the first URL change (intermediate page)
Wait(self.driver, 10).until(EC.url_changes(starting_url))
intermediate_url = self.driver.current_url
print(intermediate_url)

# Waiting for the second URL change (aimed page)
Wait(self.driver, 10).until(EC.url_changes(intermediate_url))
current_url = self.driver.current_url
print(current_url)

opened_pages.append(self.get_current_tab_url())

self.driver.back()
intermediate_url = self.driver.current_url
print(intermediate_url)

self.driver.back()
starting_url = self.driver.current_url
print(starting_url)

# Waiting for the starting page loading
Wait(self.driver, 10).until(EC.presence_of_element_located((By.TAG_NAME, "h3")))
Expand All @@ -224,12 +246,9 @@ def click_on_links_on_en_local(self):
# Waiting for the first URL change (intermediate page)
Wait(self.driver, 10).until(EC.url_changes(starting_url))
intermediate_url = self.driver.current_url
print(intermediate_url)

# Waiting for the second URL change (aimed page)
Wait(self.driver, 10).until(EC.url_changes(intermediate_url))
current_url = self.driver.current_url
print(current_url)

opened_pages.append(self.get_current_tab_url())
print(opened_pages)
Expand Down
11 changes: 6 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from pages.contributors_page import ContributorsPage
from pages.groups_page import GroupsPage
from pages.profile_page import ProfilePage
from test_data.groups_page_data import GroupsPageData
from test_data.links import MainPageLinks, ExercisesUrls

load_dotenv()
Expand Down Expand Up @@ -60,14 +61,14 @@ def description_page_open(driver):
def groups_ru_page_open(driver, auto_test_user_authorized):
page = GroupsPage(driver)
ru_button = page.element_is_present_and_clickable(huLocators.RU_BUTTON)
subtitles_before = [el.text for el in page.elements_are_located(GroupsPageLocators.PAGE_SUBTITLES)]
ru_button.click()

def subtitles_changed(driver):
current_subtitles = [el.text for el in page.elements_are_located(GroupsPageLocators.PAGE_SUBTITLES)]
return current_subtitles != subtitles_before and all(current_subtitles)
def subtitle2(driver):
subtitle2 = driver.find_element(*GroupsPageLocators.PAGE_SUBTITLE2).text
print(subtitle2)
return subtitle2 in GroupsPageData.page_subtitles_ru

Wait(driver, 20).until(subtitles_changed)
Wait(driver, 20).until(subtitle2)
page.elements_are_visible(GroupsPageLocators.PAGE_SUBTITLES)


Expand Down
Loading