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
2 changes: 1 addition & 1 deletion locators/groups_page_locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class GroupsPageLocators:
# PAGE_TILES = (By.XPATH, "//ol/li")
PAGE_TILES = (By.CSS_SELECTOR, ".list-item")
PAGE_TITLE = (By.TAG_NAME, "h3")
PAGE_SUBTITLES = (By.TAG_NAME, "h4")
PAGE_SUBTITLES = (By.XPATH, "//button/h4")


class HeaderLocators:
Expand Down
14 changes: 13 additions & 1 deletion pages/base_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,23 @@ 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 elements_are_visible(self, locator):
def elements_are_visible1(self, locator):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 точно нужна в конце названия?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this method is scheduled for removal, but has been left for now for obvious comparison.

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

def elements_are_visible(self, locator, timeout=10):
try:
return Wait(self.driver, timeout).until(ec.visibility_of_all_elements_located(locator))
except TimeoutException:
raise TimeoutException(f"Elements have not become visible at locator {locator} within {timeout} seconds")

def elements_are_located(self, locator, timeout=10):
try:
return Wait(self.driver, timeout).until(ec.presence_of_all_elements_located(locator))
except TimeoutException:
raise TimeoutException(f"Elements were not found at locator {locator} within {timeout} seconds")

def go_to_element(self, element):
return self.driver.execute_script("arguments[0].scrollIntoView({ block: 'center'});", element)

Expand Down
2 changes: 1 addition & 1 deletion pages/groups_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def check_links_clickability(self):
@allure.step("Get attribute 'title' of links on the 'ru' local")
def get_links_titles_ru(self):
elements = self.get_list_of_links()
WebDriverWait(self.driver, 10).until(ec.visibility_of_all_elements_located(self.locators.PAGE_IMAGES))
# WebDriverWait(self.driver, 10).until(ec.visibility_of_all_elements_located(self.locators.PAGE_IMAGES))
return [element.get_attribute('title') for element in elements]

@allure.step("Get attribute 'title' of links on the 'en' local")
Expand Down
21 changes: 18 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import allure
import pytest
from dotenv import load_dotenv
from selenium.webdriver.support.wait import WebDriverWait

from locators.contacts_page_locators import ContactsPageLocators
from locators.contributors_page_locators import ContributorsPageLocators
Expand All @@ -12,12 +13,10 @@
from locators.login_page_locators import LoginPageLocators
from locators.main_page_locators import MainPageLocators
from locators.start_unauthorized_page_locators import StartUnauthorizedPageLocators

from pages.base_page import BasePage
from pages.contributors_page import ContributorsPage
from pages.groups_page import GroupsPage
from pages.profile_page import ProfilePage

from test_data.links import MainPageLinks, ExercisesUrls

load_dotenv()
Expand Down Expand Up @@ -54,14 +53,30 @@ def description_page_open(driver):

@pytest.fixture()
@allure.step(f'Open page: {ExercisesUrls.STARTING_POINT}')
def groups_ru_page_open(driver, auto_test_user_authorized):
def groups_ru_page_open1(driver, auto_test_user_authorized):
page = GroupsPage(driver)
page.element_is_present_and_clickable(huLocators.RU_BUTTON).click()
page.element_is_visible(GroupsPageLocators.PAGE_SUBTITLES)
page.check_expected_link(ExercisesUrls.STARTING_POINT)
page.loader_checking()


@pytest.fixture()
@allure.step(f'Open page: {ExercisesUrls.STARTING_POINT} on the "ru" local')
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)

WebDriverWait(driver, 10).until(subtitles_changed)
page.elements_are_visible(GroupsPageLocators.PAGE_SUBTITLES)


@pytest.fixture()
@allure.step(f'Open page: {ExercisesUrls.STARTING_POINT}')
def groups_en_page_open(driver, auto_test_user_authorized):
Expand Down