Skip to content

Comments

Sprint_5#1

Open
DimPonLe wants to merge 2 commits intomainfrom
develop
Open

Sprint_5#1
DimPonLe wants to merge 2 commits intomainfrom
develop

Conversation

@DimPonLe
Copy link
Owner

No description provided.

Choose a reason for hiding this comment

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

Необходимо исправить: эта директория лишняя в проекте. Необходимо убрать её из ветки и добавить в .gitignore в корне проекта

Choose a reason for hiding this comment

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

Необходимо исправить: эта директория лишняя в проекте. Необходимо убрать её из ветки и добавить в .gitignore в корне проекта

conftest.py Outdated
# Фикстура для страницы регистрации
@pytest.fixture()
def page_register(browser):
browser.get("https://stellarburgers.education-services.ru/register")

Choose a reason for hiding this comment

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

Можно лучше здесь и далее: адреса лучше вынести во внешний модуль(например, urls). Они могут измениться, что затруднит поддержку тестов

conftest.py Outdated
@pytest.fixture()
def logged_in_account(page_home):
# Переход на страницу входа
page_home.find_element(By.XPATH, ".//button[text()='Войти в аккаунт']").click()

Choose a reason for hiding this comment

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

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

conftest.py Outdated
page_home.find_element(By.XPATH, ".//button[text()='Войти в аккаунт']").click()
WebDriverWait(page_home, 5).until(expected_conditions.text_to_be_present_in_element((By.XPATH, ".//h2"), "Вход"))
# Ввод данных пользователя
page_home.find_element(By.XPATH, ".//fieldset[1]//input").send_keys("1234567890@ya.ru") # поле Email

Choose a reason for hiding this comment

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

Можно лучше: во всех тестах лучше выносить тестовые данные во внешний модуль (например, data). Это позволит облегчить их поддержку


# проверка перехода в Булки, Соусы, Начинки через скроллинг
# @pytest.mark.parametrize("index,text", [(1, "Булки"), (2, "Соусы"), (3, "Начинки")])
def test_scrolling_bread_sauce_topping(logged_in_account, index, text):

Choose a reason for hiding this comment

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

Нужно исправить здесь и далее: Для корректного запуска тестов необходимо код с шагами теста поместить в тестовый метод (нейминг начинается с test_), а метод - в тестовый класс (нейминг начинается с Test). Необходимо привести к такому формату все модули внутри пакета tests

def test_button_go_in_accaunt_valid_existing_email_password_construction_section(page_home):
page_home.find_element(By.XPATH, ".//button[text()='Войти в аккаунт']").click()
WebDriverWait(page_home, 5).until(expected_conditions.text_to_be_present_in_element((By.XPATH, ".//h2"), "Вход")) # второй заголовок Вход
page_home.find_element(By.XPATH, ".//fieldset[1]//input").send_keys("1234567890@ya.ru") # поле Email

Choose a reason for hiding this comment

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

Необходимо исправить здесь и далее: не стоит использовать в локаторах путь от рута, абсолютный путь или индексы элемента. Это делает локатор очень хрупким

page_home.find_element(By.NAME, "Пароль").send_keys("qwerty") # поле Пароль
page_home.find_element(By.XPATH, ".//button[text()='Войти']").click() # кнопка Войти
WebDriverWait(page_home, 5).until(expected_conditions.text_to_be_present_in_element((By.XPATH, ".//section[2]//button"), "Оформить заказ"))
assert page_home.find_element(By.XPATH, ".//h2").text != "Регистрация", "Заголовок 'Регистрация' остался на странице!"

Choose a reason for hiding this comment

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

Необходимо исправить здесь и далее: проверки должны быть атомарными и однозначными

Comment on lines 39 to 50
try:
WebDriverWait(page_register, 3).until(expected_conditions.visibility_of_element_located((By.XPATH, "//p[contains(text(), 'Такой пользователь уже существует')]")))
# Если сообщение появилось, меняем имя пользователя и повторяем попытку
new_name = f"{user_data['name']} ({random.randint(100, 999)})"
user_data["name"] = new_name
# Повторная попытка регистрации
page_register.find_element(By.XPATH, ".//fieldset[1]//input").clear()
page_register.find_element(By.XPATH, ".//fieldset[1]//input").send_keys(new_name) # новое имя
page_register.find_element(By.XPATH, ".//button[text()='Зарегистрироваться']").click() # кнопка Зарегистрироваться
except TimeoutException:
pass # Если сообщение не появилось, продолжаем
# Ждём заголовок Вход

Choose a reason for hiding this comment

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

Необходимо исправить: можно вынести эти вызовы в фикстуру или в функцию модуля helpers

Comment on lines 21 to 31
try:
WebDriverWait(page_register, 3).until(expected_conditions.visibility_of_element_located((By.XPATH, "//p[contains(text(), 'Такой пользователь уже существует')]")))
# Если сообщение появилось, меняем имя пользователя и повторяем попытку
new_name = f"{user_data['name']}{random.randint(100, 999)}"
user_data["name"] = new_name
# Повторная попытка регистрации
page_register.find_element(By.XPATH, ".//fieldset[1]//input").clear()
page_register.find_element(By.XPATH, ".//fieldset[1]//input").send_keys(new_name) # новое имя
page_register.find_element(By.XPATH, ".//button[text()='Зарегистрироваться']").click() # кнопка Зарегистрироваться
except TimeoutException:
pass # Если сообщение не появилось, продолжаем

Choose a reason for hiding this comment

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

Необходимо исправить: можно вынести эти вызовы в фикстуру или в функцию модуля helpers

Choose a reason for hiding this comment

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

Необходимо исправить: эта директория лишняя в проекте. Необходимо убрать её из ветки и добавить в .gitignore в корне проекта

Choose a reason for hiding this comment

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

Необходимо исправить: эта директория лишняя в проекте. Необходимо убрать её из ветки и добавить в .gitignore в корне проекта

Comment on lines +6 to +9
REG_INPUT_NAME = (By.XPATH, ".//fieldset[1]//input")
# поле Email
REG_INPUT_EMAIL = (By.XPATH, ".//fieldset[2]//input")
# поле Пароль

Choose a reason for hiding this comment

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

Необходимо исправить здесь и далее: не стоит использовать в локаторах путь от рута, абсолютный путь или индексы элемента. Это делает локатор очень хрупким

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