Skip to content

diplom 3#6

Open
ShamilovR wants to merge 1 commit intomasterfrom
diplom_3
Open

diplom 3#6
ShamilovR wants to merge 1 commit intomasterfrom
diplom_3

Conversation

@ShamilovR
Copy link
Copy Markdown
Owner

No description provided.

Comment on lines +9 to +14
ANY_INPUT_LOCATOR = ".//main//form//input"
EMAIL_OR_NAME_LOCATOR = ".//main//form//input[@name='name']"
PASSWORD_LOCATOR = ".//main//form//input[@name='Пароль']"
REGISTER_BUTTON_LOCATOR = ".//main//form/button"
EMAIL_LOCATOR = ".//main//form//input[@name='name']"
LOGIN_BUTTON_LOCATOR = ".//button[text()='Войти']"
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Нужно исправить: здесь и далее: локаторы должны быть записаны в переменные и хранится отдельно от тестов в модуле locators для удобства дальнейшего переиспользования.

@pytest.fixture()
def driver_registered(driver, random_email, random_password):
driver.get(REGISTER_URL)
WebDriverWait(driver, 3).until(
Copy link
Copy Markdown
Owner Author

@ShamilovR ShamilovR Jan 12, 2025

Choose a reason for hiding this comment

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

Нужно исправить: здесь и далее: в тестах, фисктурах и методах пейджей не должно быть обращений к драйверу и использований WebdriverWait. Все подобные реализации должны находиться в рамках базового класса пейджей.

Comment on lines +53 to +54
yield driver
driver.quit()
Copy link
Copy Markdown
Owner Author

@ShamilovR ShamilovR Jan 12, 2025

Choose a reason for hiding this comment

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

Нужно исправить: здесь и далее: закрытие драйвера должно происходить в фикстуре, где инициализируется драйвер

Comment on lines +8 to +37
def test_open_profile_from_header(self, driver):
constructor_page = ConstructorPage(driver)
constructor_page.open_login_page()
constructor_page.click_to_open_constructor_page()
constructor_page.check_constructor_page_opens()

@allure.title('Проверка открытия попапа ингредиента')
def test_open_profile_from_header(self, driver):
constructor_page = ConstructorPage(driver)
constructor_page.open_main_page()
constructor_page.click_to_open_ingredient_popup()
constructor_page.check_ingredient_popup_open()

@allure.title('Проверка закрытия попапа ингредиента')
def test_open_profile_from_header(self, driver):
constructor_page = ConstructorPage(driver)
constructor_page.open_main_page()
constructor_page.click_to_open_ingredient_popup()
constructor_page.click_to_close_ingredient_popup()
constructor_page.check_ingredient_popup_close()

@allure.title('Проверка увеличения счетчика ингредиента')
def test_increment_ingredient_counter(self, driver):
constructor_page = ConstructorPage(driver)
constructor_page.open_main_page()
constructor_page.move_ingredient_to_basket()
constructor_page.check_ingredient_counter_increases()

@allure.title('Проверка создания заказа для залогиненного пользователя')
def test_increment_ingredient_counter(self, driver_logged_in):
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Нужно исправить: в рамках тестового класса присутствуют одноименные тестовые методы

constructor_page.create_order()
constructor_page.open_main_page()
feed_page.click_to_open_feed_page()
time.sleep(3)
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Нужно исправить: здесь и далее: sleep в тестах плохая практика, т.к. для загрузки страницы/элемента может потребоваться меньше или больше времени. Для ожиданий нужно использовать модуль expected_condition.

from urls.urls import REGISTER_URL, LOGIN_URL, BASE_URL
from faker import Faker

ANY_INPUT_LOCATOR = ".//main//form//input"
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Нужно исправить: здесь и далее: использование в локаторе порядкового номера элемента в dom, поиск от html, root, main и абсолютного пути порождает нестабильность локаторов (необходимо привязываться к атрибутам конкретного элемента)

Comment on lines +17 to +24
@pytest.fixture()
def random_email():
return Faker().email()


@pytest.fixture()
def random_password():
return Faker().password()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Нужно исправить: фикстуры не занимаются прокидыванием данных в тест и выполнением примитивной логики, они выполняют сложную логику предусловий\постусловий. Эти методы необходимо описать в модуле helpers и оттуда вызывать в тестах и методах

Comment on lines +53 to +67
@allure.step('Открытие страницы логина')
def open_login_page(self):
self.driver.get(LOGIN_URL)
self.wait_for_url_change(LOGIN_URL)

@allure.step('Открытие страницы восстановления пароля')
def open_forgot_password_page(self):
self.driver.get(FORGOT_PASSWORD_URL)
self.wait_for_url_change(FORGOT_PASSWORD_URL)

@allure.step('Открытие страницы конструктора')
def open_main_page(self):
self.driver.get(BASE_URL)
self.wait_for_url_change(BASE_URL)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Нужно исправить: эти методы необходимо разместить в соответствующих пейджах а не в base


@allure.step('Проверка закрытия попапа ингредиента')
def check_ingredient_popup_close(self):
assert self.find_element(self.close_ingredient_modal).is_displayed() is False
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно лучше: assert not self.find_element(self.close_ingredient_modal).is_displayed()

self.wait_to_be_clickable(self.forgot_password_page_link)
self.find_element(self.forgot_password_page_link).click()
self.wait_for_url_change(FORGOT_PASSWORD_URL)
assert self.driver.current_url == FORGOT_PASSWORD_URL
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Нужно исправить: здесь и далее по проекту: все прямые обращения к driver необходимо вынести в base, там описать методы взаимодействия с ними и оттуда за счет наследования классов страниц от base переиспользовать

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants