Skip to content

Sprint 6#2

Open
Airflp wants to merge 10 commits intomasterfrom
sprint_6
Open

Sprint 6#2
Airflp wants to merge 10 commits intomasterfrom
sprint_6

Conversation

@Airflp
Copy link
Owner

@Airflp Airflp commented Mar 5, 2026

No description provided.

@@ -0,0 +1,15 @@
[

Choose a reason for hiding this comment

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

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

Comment on lines +4 to +5
ORDER_BUTTON_TOP = (By.XPATH, "//button[contains(text(), 'Заказать')]")
ORDER_BUTTON_BOTTOM = (By.XPATH, "//button[contains(text(), 'Заказать')]")

Choose a reason for hiding this comment

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

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



class BasePage:
BASE_URL = "https://qa-scooter.praktikum-services.ru/"

Choose a reason for hiding this comment

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

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

def __init__(self, driver):
self.driver = driver

def find_element(self, locator, time=10):

Choose a reason for hiding this comment

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

Необходимо исправить здесь и далее: не хватает аннотации allure для шага - allure.step


# Локаторы для кнопок заказа
ORDER_BUTTON_TOP = (By.XPATH, "//button[@class='Button_Button__ra12g']")
ORDER_BUTTON_BOTTOM = (By.XPATH, "(//button[text()='Заказать'])[2]")

Choose a reason for hiding this comment

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

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

@@ -0,0 +1,9 @@
from locators.main_page_locators import MainPageLocators

class MainPageLocators:

Choose a reason for hiding this comment

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

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

Comment on lines +101 to +104
for domain in ['dzen.ru', 'yandex.ru', 'ya.ru']:
if self.wait_for_url_contains(domain, timeout=5):
return True

Choose a reason for hiding this comment

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

Необходимо исправить: проверка для теста получилась не атомарной. Стоит проверять редирект на конкретный адрес

Comment on lines +47 to +50
if order_button == "top":
main_page.click_order_button_top()
else:
main_page.click_order_button_bottom()

Choose a reason for hiding this comment

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

Нужно исправить: использование условных блоков в теле теста лишает их атомарности. Можно попробовать, например, расширить количество параметров или их переработать дабы избежать этой ситуации. Если не получается объединить их все, то отдельные можно разместить отдельно исключив из параметризации

assert main_page.check_yandex_redirect_url(), "Не открылась страница Яндекса/Дзена"

# Закрываем новое окно и возвращаемся к основному
main_page.close_current_window_and_switch_to(main_window) No newline at end of file

Choose a reason for hiding this comment

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

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

def __init__(self, driver):
self.driver = driver

def find_element(self, locator, timeout=10):

Choose a reason for hiding this comment

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

Необходимо исправить здесь и далее: не хватает аннотации allure для шага - allure.step

Comment on lines +60 to +67
WebDriverWait(self.driver, 10).until(
EC.number_of_windows_to_be(2)
)

for window in self.driver.window_handles:
if window != main_window:
self.driver.switch_to.window(window)
break No newline at end of file

Choose a reason for hiding this comment

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

Необходимо исправить здесь и далее: все вызовы к driver/WebDriverWait должны быть описаны в методах BasePage, а затем вызываться через эти методы в *Page-классах через наследование. Стоит посмотреть в сторону EC.new_window_is_opened

Comment on lines +41 to +44
if button == "top":
main_page.click_order_button_top()
else:
main_page.click_order_button_bottom()

Choose a reason for hiding this comment

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

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

main_page.click_order_button_top()
main_page.click_scooter_logo()

assert "scooter" in driver.current_url

Choose a reason for hiding this comment

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

Нужно исправить: здесь и далее, все вызовы к driver/WebDriverWait напрямую из теста или фикстуры не допустимы (кроме get). Необходимо реализовать соответствующий метод в BasePage и вызывать его

Comment on lines +69 to +73
main_window = driver.current_window_handle

main_page.click_yandex_logo_and_wait_for_new_window(main_window)

assert "dzen" in driver.current_url No newline at end of file

Choose a reason for hiding this comment

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

Нужно исправить: здесь и далее, все вызовы к driver/WebDriverWait напрямую из теста или фикстуры не допустимы (кроме get). Необходимо реализовать соответствующий метод в BasePage и вызывать его

from selenium import webdriver


@pytest.fixture(scope="class")

Choose a reason for hiding this comment

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

Необходимо исправить: такой скоуп создает зависимые тесты. Стоит использовать скоуп function

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