From 8b4bd7e44cdb6c870388799fe03d171cc9a81cd5 Mon Sep 17 00:00:00 2001 From: ilshat Date: Mon, 30 Dec 2024 15:12:17 +0300 Subject: [PATCH] task 5 --- .gitignore | 3 ++ README.md | 37 +++++++++++++++++++ .../test_click_through_button_constructor.py | 29 +++++++++++++++ ...t_click_through_button_personal_account.py | 29 +++++++++++++++ ...test_click_through_logo_stellar_burgers.py | 29 +++++++++++++++ tests/test_click_through_section_fillings.py | 17 +++++++++ tests/test_click_through_section_rolls.py | 20 ++++++++++ tests/test_click_through_section_sauces.py | 15 ++++++++ tests/test_log_in_from_registration_form.py | 20 ++++++++++ ...st_log_in_with_button_log_in_to_account.py | 18 +++++++++ ...st_log_in_with_button_password_recovery.py | 20 ++++++++++ ...est_log_in_with_button_personal_account.py | 18 +++++++++ tests/test_log_out_with_button_exit.py | 34 +++++++++++++++++ tests/test_successful_registration.py | 20 ++++++++++ tests/test_wrong_password.py | 17 +++++++++ 15 files changed, 326 insertions(+) create mode 100644 README.md create mode 100644 tests/test_click_through_button_constructor.py create mode 100644 tests/test_click_through_button_personal_account.py create mode 100644 tests/test_click_through_logo_stellar_burgers.py create mode 100644 tests/test_click_through_section_fillings.py create mode 100644 tests/test_click_through_section_rolls.py create mode 100644 tests/test_click_through_section_sauces.py create mode 100644 tests/test_log_in_from_registration_form.py create mode 100644 tests/test_log_in_with_button_log_in_to_account.py create mode 100644 tests/test_log_in_with_button_password_recovery.py create mode 100644 tests/test_log_in_with_button_personal_account.py create mode 100644 tests/test_log_out_with_button_exit.py create mode 100644 tests/test_successful_registration.py create mode 100644 tests/test_wrong_password.py diff --git a/.gitignore b/.gitignore index e69de29..6ed7f1f 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,3 @@ +venv +.idea +*\__pycache__ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..5f73383 --- /dev/null +++ b/README.md @@ -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 + + + + + + + + diff --git a/tests/test_click_through_button_constructor.py b/tests/test_click_through_button_constructor.py new file mode 100644 index 0000000..9a00b6f --- /dev/null +++ b/tests/test_click_through_button_constructor.py @@ -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("NikolayKluchnikov1004@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("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() \ No newline at end of file diff --git a/tests/test_click_through_button_personal_account.py b/tests/test_click_through_button_personal_account.py new file mode 100644 index 0000000..d5da156 --- /dev/null +++ b/tests/test_click_through_button_personal_account.py @@ -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() \ No newline at end of file diff --git a/tests/test_click_through_logo_stellar_burgers.py b/tests/test_click_through_logo_stellar_burgers.py new file mode 100644 index 0000000..aa28f8b --- /dev/null +++ b/tests/test_click_through_logo_stellar_burgers.py @@ -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() \ No newline at end of file diff --git a/tests/test_click_through_section_fillings.py b/tests/test_click_through_section_fillings.py new file mode 100644 index 0000000..98c157b --- /dev/null +++ b/tests/test_click_through_section_fillings.py @@ -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() + +driver.quit() \ No newline at end of file diff --git a/tests/test_click_through_section_rolls.py b/tests/test_click_through_section_rolls.py new file mode 100644 index 0000000..ae35f9d --- /dev/null +++ b/tests/test_click_through_section_rolls.py @@ -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() \ No newline at end of file diff --git a/tests/test_click_through_section_sauces.py b/tests/test_click_through_section_sauces.py new file mode 100644 index 0000000..5fcddfd --- /dev/null +++ b/tests/test_click_through_section_sauces.py @@ -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() \ No newline at end of file diff --git a/tests/test_log_in_from_registration_form.py b/tests/test_log_in_from_registration_form.py new file mode 100644 index 0000000..2a9a30e --- /dev/null +++ b/tests/test_log_in_from_registration_form.py @@ -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() \ No newline at end of file diff --git a/tests/test_log_in_with_button_log_in_to_account.py b/tests/test_log_in_with_button_log_in_to_account.py new file mode 100644 index 0000000..cecac23 --- /dev/null +++ b/tests/test_log_in_with_button_log_in_to_account.py @@ -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() \ No newline at end of file diff --git a/tests/test_log_in_with_button_password_recovery.py b/tests/test_log_in_with_button_password_recovery.py new file mode 100644 index 0000000..a4e80e3 --- /dev/null +++ b/tests/test_log_in_with_button_password_recovery.py @@ -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() \ No newline at end of file diff --git a/tests/test_log_in_with_button_personal_account.py b/tests/test_log_in_with_button_personal_account.py new file mode 100644 index 0000000..26548b4 --- /dev/null +++ b/tests/test_log_in_with_button_personal_account.py @@ -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() \ No newline at end of file diff --git a/tests/test_log_out_with_button_exit.py b/tests/test_log_out_with_button_exit.py new file mode 100644 index 0000000..50f595e --- /dev/null +++ b/tests/test_log_out_with_button_exit.py @@ -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() \ No newline at end of file diff --git a/tests/test_successful_registration.py b/tests/test_successful_registration.py new file mode 100644 index 0000000..0cfe6cb --- /dev/null +++ b/tests/test_successful_registration.py @@ -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") +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() \ No newline at end of file diff --git a/tests/test_wrong_password.py b/tests/test_wrong_password.py new file mode 100644 index 0000000..43e4a4a --- /dev/null +++ b/tests/test_wrong_password.py @@ -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() \ No newline at end of file