Skip to content

task 5#1

Open
ShamilovR wants to merge 1 commit intomasterfrom
sprint-5
Open

task 5#1
ShamilovR wants to merge 1 commit intomasterfrom
sprint-5

Conversation

@ShamilovR
Copy link
Owner

No description provided.




Описание локаторов:
Copy link
Owner Author

Choose a reason for hiding this comment

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

Можно лучше: readme используется не по назначению

driver.find_element(By.XPATH, ".//fieldset[3]/div/div/input").send_keys("123456")
driver.find_element(By.XPATH, ".//button[text()='Зарегистрироваться']").click()

time.sleep(1)
Copy link
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 selenium.webdriver.common.by import By
import time

driver = webdriver.Chrome()
Copy link
Owner Author

Choose a reason for hiding this comment

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

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

Copy link
Owner Author

@ShamilovR ShamilovR Dec 30, 2024

Choose a reason for hiding this comment

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

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


driver = webdriver.Chrome()

driver.get("https://stellarburgers.nomoreparties.site/")
Copy link
Owner Author

Choose a reason for hiding this comment

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

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

Comment on lines +11 to +13
driver.find_element(By.XPATH, ".//fieldset[1]/div/div/input").send_keys("Nikolay")
driver.find_element(By.XPATH, ".//fieldset[2]/div/div/input").send_keys("NikolayKluchnikov1004@mail.ru")
driver.find_element(By.XPATH, ".//fieldset[3]/div/div/input").send_keys("123456")
Copy link
Owner Author

Choose a reason for hiding this comment

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

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


driver.get("https://stellarburgers.nomoreparties.site/")

driver.find_element(By.LINK_TEXT, "Личный Кабинет").click()
Copy link
Owner Author

Choose a reason for hiding this comment

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

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


driver.find_element(By.LINK_TEXT, "Личный Кабинет").click()
driver.find_element(By.XPATH, ".//a[@href='/register']").click()
driver.find_element(By.XPATH, ".//fieldset[1]/div/div/input").send_keys("Nikolay")
Copy link
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 и абсолютного пути порождает нестабильность локаторов (необходимо привязываться к атрибутам конкретного элемента)


time.sleep(2)

assert driver.find_element(By.XPATH, ".//p[text()='Мясо бессмертных моллюсков Protostomia']").is_displayed()
Copy link
Owner Author

@ShamilovR ShamilovR Dec 30, 2024

Choose a reason for hiding this comment

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

Нужно исправить: здесь и далее для тестов переходов по табам: данный элемент появляется в dom с самого начала загрузки страницы. Проверка переключения таба по нему будет недостоверной. Нужно использовать другой способ, например, проверка изменения атрибута class у элемента.

driver.find_element(By.LINK_TEXT, "Личный Кабинет").click()
driver.find_element(By.XPATH, ".//a[@href='/register']").click()
driver.find_element(By.XPATH, ".//fieldset[1]/div/div/input").send_keys("Nikolay")
driver.find_element(By.XPATH, ".//fieldset[2]/div/div/input").send_keys("NikolayKluchnikov1000@mail.ru")
Copy link
Owner Author

Choose a reason for hiding this comment

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

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

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.

1 participant