-
Notifications
You must be signed in to change notification settings - Fork 0
task 5 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
task 5 #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| venv | ||
| .idea | ||
| *\__pycache__ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Sprint_5 | ||
|
|
||
|
|
||
|
|
||
| Описание локаторов: | ||
|
|
||
| "Личный Кабинет" — кнопка личный кабинет на главной странице сайта | ||
| .//a[@href='/register'] — кнопка зарегистрироваться | ||
| .//fieldset[1]/div/div/input — поле ввода "Имя" на странице регистрации | ||
| .//fieldset[2]/div/div/input — поле ввода "Email" на странице регистрации | ||
| .//fieldset[3]/div/div/input - поле ввода "Пароль" на странице регистрации | ||
| .//button[text()='Зарегистрироваться'] — кнопка "Зарегистрироваться" на странице регистрации | ||
| .//input[@name='name'] — поле ввода "Email" на странице входа в личный кабинет | ||
| .//input[@name='Пароль'] — полле ввода "Пароль" на странице входа в личный кабинет | ||
| .//button[text()='Войти'] — кнопка "Войти" на странице входа в личный кабинет | ||
| "Конструктор" — кнопка конструктор на главной странице сайта | ||
| .//p[text()='Некорректный пароль'] — тест "Некорректный пароль" на странице регистрации при вводе неверного пароля | ||
| .//button[text()='Выход'] — кнопка "Выход" в личном кабинете пользователя | ||
| .//button[text()='Оформить заказ'] — кнопка "Оформить заказ" на главной странице сайта, видна только зарегистрированому пользователю | ||
| "Восстановить пароль" — кнопка восстановления пароля | ||
| "Войти" — кнопка входа на странице "Вход" | ||
| .//button[text()='Войти в аккаунт'] — кнопка входа в аккаунт на главной странице сайта | ||
| .//span[text()='Соусы'] — раздел Соусы на главной странице сайта | ||
| .//p[text()='Соус Spicy-X'] — наименование товара в разделе Соусы | ||
| .//span[text()='Булки'] — раздел Булки на главной странице сайта | ||
| .//p[text()='Флюоресцентная булка R2-D3'] — наименование товара в разделе Булки | ||
| .//span[text()='Начинки'] — раздел Начинка на главной странице сайта | ||
| .//p[text()='Мясо бессмертных моллюсков Protostomia'] — наименований товара в разделе Начинки | ||
| AppHeader_header__logo__2D0X2 — логотип Stellar Burgers | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| from selenium import webdriver | ||
| from selenium.webdriver.common.by import By | ||
| import time | ||
|
|
||
| driver = webdriver.Chrome() | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: здесь и далее: тестовые сценарии должны быть оформлены в тестовых классах и тестовых методах. Такая реализация позволяет объединять несколько сценариев в сьюты в рамках одного модуля.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: здесь и далее: инициализация/закрытие драйвера должна происходить в рамках фикстур. Такая реализация позволяет избежать дублирования кода. |
||
|
|
||
| driver.get("https://stellarburgers.nomoreparties.site/") | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Можно лучше: здесь и далее: урлы стоит хранить в отдельном модуле и конкатенировать с базовым, так будет проще поддерживать несколько стендов |
||
|
|
||
| driver.find_element(By.LINK_TEXT, "Личный Кабинет").click() | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: здесь и далее: локаторы должны быть записаны в переменные и хранится отдельно от тестов в модуле locators для удобства дальнейшего переиспользования. |
||
| driver.find_element(By.XPATH, ".//a[@href='/register']").click() | ||
| driver.find_element(By.XPATH, ".//fieldset[1]/div/div/input").send_keys("Nikolay") | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: здесь и далее: использование в локаторе порядкового номера элемента в dom, поиск от html, root, main и абсолютного пути порождает нестабильность локаторов (необходимо привязываться к атрибутам конкретного элемента) |
||
| 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") | ||
|
Comment on lines
+11
to
+13
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Можно лучше: здесь и далее: тестовые данные стоит хранить отдельно в data модуле, так поддерживать и переиспользовать будет проще |
||
| driver.find_element(By.XPATH, ".//button[text()='Зарегистрироваться']").click() | ||
|
|
||
| time.sleep(1) | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: здесь и далее: sleep в тестах плохая практика, т.к. для загрузки страницы/элемента может потребоваться меньше или больше времени. Для ожиданий нужно использовать модуль expected_condition. |
||
|
|
||
| driver.find_element(By.XPATH, ".//input[@name='name']").send_keys("NikolayKluchnikov1004@mail.ru") | ||
| driver.find_element(By.XPATH, ".//input[@name='Пароль']").send_keys("123456") | ||
| driver.find_element(By.XPATH, ".//button[text()='Войти']").click() | ||
|
|
||
| driver.find_element(By.LINK_TEXT, "Личный Кабинет").click() | ||
| driver.find_element(By.LINK_TEXT, "Конструктор").click() | ||
|
|
||
| time.sleep(1) | ||
|
|
||
| assert driver.current_url == 'https://stellarburgers.nomoreparties.site/' | ||
|
|
||
| driver.quit() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| from selenium import webdriver | ||
| from selenium.webdriver.common.by import By | ||
| import time | ||
|
|
||
| driver = webdriver.Chrome() | ||
|
|
||
| driver.get("https://stellarburgers.nomoreparties.site/") | ||
|
|
||
| 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("NikolayKluchnikov1003@mail.ru") | ||
| driver.find_element(By.XPATH, ".//fieldset[3]/div/div/input").send_keys("123456") | ||
| driver.find_element(By.XPATH, ".//button[text()='Зарегистрироваться']").click() | ||
|
|
||
| time.sleep(1) | ||
|
|
||
| driver.find_element(By.XPATH, ".//input[@name='name']").send_keys("NikolayKluchnikov1003@mail.ru") | ||
| driver.find_element(By.XPATH, ".//input[@name='Пароль']").send_keys("123456") | ||
| driver.find_element(By.XPATH, ".//button[text()='Войти']").click() | ||
|
|
||
|
|
||
| driver.find_element(By.LINK_TEXT, "Личный Кабинет").click() | ||
|
|
||
| time.sleep(1) | ||
|
|
||
| assert driver.current_url == 'https://stellarburgers.nomoreparties.site/account/profile' | ||
|
|
||
| driver.quit() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| from selenium import webdriver | ||
| from selenium.webdriver.common.by import By | ||
| import time | ||
|
|
||
| driver = webdriver.Chrome() | ||
|
|
||
| driver.get("https://stellarburgers.nomoreparties.site/") | ||
|
|
||
| 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("NikolayKluchnikov1002@mail.ru") | ||
| driver.find_element(By.XPATH, ".//fieldset[3]/div/div/input").send_keys("123456") | ||
| driver.find_element(By.XPATH, ".//button[text()='Зарегистрироваться']").click() | ||
|
|
||
| time.sleep(1) | ||
|
|
||
| driver.find_element(By.XPATH, ".//input[@name='name']").send_keys("NikolayKluchnikov1002@mail.ru") | ||
| driver.find_element(By.XPATH, ".//input[@name='Пароль']").send_keys("123456") | ||
| driver.find_element(By.XPATH, ".//button[text()='Войти']").click() | ||
|
|
||
| driver.find_element(By.LINK_TEXT, "Личный Кабинет").click() | ||
| driver.find_element(By.CLASS_NAME, "AppHeader_header__logo__2D0X2").click() | ||
|
|
||
| time.sleep(1) | ||
|
|
||
| assert driver.current_url == 'https://stellarburgers.nomoreparties.site/' | ||
|
|
||
| driver.quit() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| from selenium import webdriver | ||
| from selenium.webdriver.common.by import By | ||
| import time | ||
|
|
||
| driver = webdriver.Chrome() | ||
|
|
||
| driver.get("https://stellarburgers.nomoreparties.site/") | ||
|
|
||
| time.sleep(2) | ||
|
|
||
| driver.find_element(By.XPATH, ".//span[text()='Начинки']").click() | ||
|
|
||
| time.sleep(2) | ||
|
|
||
| assert driver.find_element(By.XPATH, ".//p[text()='Мясо бессмертных моллюсков Protostomia']").is_displayed() | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: здесь и далее для тестов переходов по табам: данный элемент появляется в dom с самого начала загрузки страницы. Проверка переключения таба по нему будет недостоверной. Нужно использовать другой способ, например, проверка изменения атрибута class у элемента. |
||
|
|
||
| driver.quit() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| from selenium import webdriver | ||
| from selenium.webdriver.common.by import By | ||
| import time | ||
|
|
||
| driver = webdriver.Chrome() | ||
|
|
||
| driver.get("https://stellarburgers.nomoreparties.site/") | ||
|
|
||
|
|
||
| driver.find_element(By.XPATH, ".//span[text()='Соусы']").click() | ||
|
|
||
| time.sleep(2) | ||
|
|
||
| driver.find_element(By.XPATH, ".//span[text()='Булки']").click() | ||
|
|
||
| time.sleep(2) | ||
|
|
||
| assert driver.find_element(By.XPATH, ".//p[text()='Флюоресцентная булка R2-D3']").is_displayed() | ||
|
|
||
| driver.quit() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| from selenium import webdriver | ||
| from selenium.webdriver.common.by import By | ||
| import time | ||
|
|
||
| driver = webdriver.Chrome() | ||
|
|
||
| driver.get("https://stellarburgers.nomoreparties.site/") | ||
|
|
||
| driver.find_element(By.XPATH, ".//span[text()='Соусы']").click() | ||
|
|
||
| time.sleep(2) | ||
|
|
||
| assert driver.find_element(By.XPATH, ".//p[text()='Соус Spicy-X']").is_displayed() | ||
|
|
||
| driver.quit() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| from selenium import webdriver | ||
| from selenium.webdriver.common.by import By | ||
| import time | ||
|
|
||
| driver = webdriver.Chrome() | ||
|
|
||
| driver.get("https://stellarburgers.nomoreparties.site/") | ||
|
|
||
| driver.find_element(By.LINK_TEXT, "Личный Кабинет").click() | ||
| driver.find_element(By.XPATH, ".//a[@href='/register']").click() | ||
| driver.find_element(By.LINK_TEXT, "Войти").click() | ||
| driver.find_element(By.XPATH, ".//input[@name='name']").send_keys("NikolayKluchnikov1000@mail.ru") | ||
| driver.find_element(By.XPATH, ".//input[@name='Пароль']").send_keys("123456") | ||
| driver.find_element(By.XPATH, ".//button[text()='Войти']").click() | ||
|
|
||
| time.sleep(2) | ||
|
|
||
| assert driver.find_element(By.XPATH, ".//button[text()='Оформить заказ']").text == 'Оформить заказ' | ||
|
|
||
| driver.quit() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| from selenium import webdriver | ||
| from selenium.webdriver.common.by import By | ||
| import time | ||
|
|
||
| driver = webdriver.Chrome() | ||
|
|
||
| driver.get("https://stellarburgers.nomoreparties.site/") | ||
|
|
||
| driver.find_element(By.XPATH, ".//button[text()='Войти в аккаунт']").click() | ||
| driver.find_element(By.XPATH, ".//input[@name='name']").send_keys("NikolayKluchnikov1000@mail.ru") | ||
| driver.find_element(By.XPATH, ".//input[@name='Пароль']").send_keys("123456") | ||
| driver.find_element(By.XPATH, ".//button[text()='Войти']").click() | ||
|
|
||
| time.sleep(2) | ||
|
|
||
| assert driver.find_element(By.XPATH, ".//button[text()='Оформить заказ']").text == 'Оформить заказ' | ||
|
|
||
| driver.quit() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| from selenium import webdriver | ||
| from selenium.webdriver.common.by import By | ||
| import time | ||
|
|
||
| driver = webdriver.Chrome() | ||
|
|
||
| driver.get("https://stellarburgers.nomoreparties.site/") | ||
|
|
||
| driver.find_element(By.LINK_TEXT, "Личный Кабинет").click() | ||
| driver.find_element(By.LINK_TEXT, "Восстановить пароль").click() | ||
| driver.find_element(By.LINK_TEXT, "Войти").click() | ||
| driver.find_element(By.XPATH, ".//input[@name='name']").send_keys("NikolayKluchnikov1000@mail.ru") | ||
| driver.find_element(By.XPATH, ".//input[@name='Пароль']").send_keys("123456") | ||
| driver.find_element(By.XPATH, ".//button[text()='Войти']").click() | ||
|
|
||
| time.sleep(2) | ||
|
|
||
| assert driver.find_element(By.XPATH, ".//button[text()='Оформить заказ']").text == 'Оформить заказ' | ||
|
|
||
| driver.quit() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| from selenium import webdriver | ||
| from selenium.webdriver.common.by import By | ||
| import time | ||
|
|
||
| driver = webdriver.Chrome() | ||
|
|
||
| driver.get("https://stellarburgers.nomoreparties.site/") | ||
|
|
||
| driver.find_element(By.LINK_TEXT, "Личный Кабинет").click() | ||
| driver.find_element(By.XPATH, ".//input[@name='name']").send_keys("NikolayKluchnikov1000@mail.ru") | ||
| driver.find_element(By.XPATH, ".//input[@name='Пароль']").send_keys("123456") | ||
| driver.find_element(By.XPATH, ".//button[text()='Войти']").click() | ||
|
|
||
| time.sleep(2) | ||
|
|
||
| assert driver.find_element(By.XPATH, ".//button[text()='Оформить заказ']").text == 'Оформить заказ' | ||
|
|
||
| driver.quit() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| from selenium import webdriver | ||
| from selenium.webdriver.common.by import By | ||
| import time | ||
|
|
||
| driver = webdriver.Chrome() | ||
|
|
||
| driver.get("https://stellarburgers.nomoreparties.site/") | ||
|
|
||
| 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("NikolayKluchnikov1001@mail.ru") | ||
| driver.find_element(By.XPATH, ".//fieldset[3]/div/div/input").send_keys("123456") | ||
| driver.find_element(By.XPATH, ".//button[text()='Зарегистрироваться']").click() | ||
|
|
||
| time.sleep(1) | ||
|
|
||
| driver.find_element(By.XPATH, ".//input[@name='name']").send_keys("NikolayKluchnikov1001@mail.ru") | ||
| driver.find_element(By.XPATH, ".//input[@name='Пароль']").send_keys("123456") | ||
| driver.find_element(By.XPATH, ".//button[text()='Войти']").click() | ||
|
|
||
| time.sleep(2) | ||
|
|
||
| driver.find_element(By.LINK_TEXT, "Личный Кабинет").click() | ||
|
|
||
| time.sleep(2) | ||
|
|
||
| driver.find_element(By.XPATH, ".//button[text()='Выход']").click() | ||
|
|
||
| time.sleep(2) | ||
|
|
||
| assert driver.current_url == 'https://stellarburgers.nomoreparties.site/login' | ||
|
|
||
| driver.quit() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| from selenium import webdriver | ||
| from selenium.webdriver.common.by import By | ||
| import time | ||
|
|
||
| driver = webdriver.Chrome() | ||
|
|
||
| driver.get("https://stellarburgers.nomoreparties.site/") | ||
|
|
||
| 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") | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: при использовании захардкоженного email тест пройдет только первый раз, т.к. функционал не позволяет регистрировать пользователей с одинаковым email . Нужно использовать рандомную генерацию email для каждого теста. |
||
| driver.find_element(By.XPATH, ".//fieldset[3]/div/div/input").send_keys("123456") | ||
| driver.find_element(By.XPATH, ".//button[text()='Зарегистрироваться']").click() | ||
|
|
||
| time.sleep(1) | ||
|
|
||
| assert driver.current_url == 'https://stellarburgers.nomoreparties.site/login' | ||
|
|
||
| driver.quit() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| from selenium import webdriver | ||
| from selenium.webdriver.common.by import By | ||
|
|
||
| driver = webdriver.Chrome() | ||
|
|
||
| driver.get("https://stellarburgers.nomoreparties.site/") | ||
|
|
||
| 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") | ||
| driver.find_element(By.XPATH, ".//fieldset[3]/div/div/input").send_keys("222") | ||
| driver.find_element(By.XPATH, ".//button[text()='Зарегистрироваться']").click() | ||
|
|
||
| assert driver.find_element(By.XPATH, ".//p[text()='Некорректный пароль']").text == 'Некорректный пароль' | ||
|
|
||
| driver.quit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно лучше: readme используется не по назначению