done
This commit is contained in:
2
.env.example
Normal file
2
.env.example
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
STEPIK_LOGIN=user@example.com
|
||||||
|
STEPIK_PASSWORD=password
|
||||||
10
Pages.py
10
Pages.py
@@ -1,8 +1,5 @@
|
|||||||
from BaseApp import BasePage
|
from BaseApp import BasePage
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
from selenium.webdriver.common.action_chains import ActionChains
|
|
||||||
|
|
||||||
from conftest import browser
|
|
||||||
|
|
||||||
|
|
||||||
class Locators:
|
class Locators:
|
||||||
@@ -15,6 +12,7 @@ class Locators:
|
|||||||
LOCATOR_LOGIN_FORM = (By.ID, "login_form")
|
LOCATOR_LOGIN_FORM = (By.ID, "login_form")
|
||||||
LOCATOR_LOGIN_FORM_MESSAGES_LIST = (By.CLASS_NAME, "sign-form__messages")
|
LOCATOR_LOGIN_FORM_MESSAGES_LIST = (By.CLASS_NAME, "sign-form__messages")
|
||||||
LOCATOR_LOGIN_FORM_MESSAGE = (By.TAG_NAME, "li")
|
LOCATOR_LOGIN_FORM_MESSAGE = (By.TAG_NAME, "li")
|
||||||
|
LOCATOR_USER_PROFILE_TOGGLER = (By.CLASS_NAME, "navbar__profile-toggler")
|
||||||
LOCATOR_COURSE_PROMO_FAV_BUTTON = (
|
LOCATOR_COURSE_PROMO_FAV_BUTTON = (
|
||||||
By.XPATH,
|
By.XPATH,
|
||||||
"/html/body/main/section[3]/div/div[2]/button",
|
"/html/body/main/section[3]/div/div[2]/button",
|
||||||
@@ -37,6 +35,9 @@ class MainPage(BasePage):
|
|||||||
def check_search_result_message(self):
|
def check_search_result_message(self):
|
||||||
return self.find_element(Locators.LOCATOR_SEARCH_RESULT_MESSAGE, time=5)
|
return self.find_element(Locators.LOCATOR_SEARCH_RESULT_MESSAGE, time=5)
|
||||||
|
|
||||||
|
def check_search_input_text(self):
|
||||||
|
return self.find_element(Locators.LOCATOR_SEARCH_INPUT).text
|
||||||
|
|
||||||
|
|
||||||
class LoginPage(BasePage):
|
class LoginPage(BasePage):
|
||||||
def __init__(self, driver):
|
def __init__(self, driver):
|
||||||
@@ -61,6 +62,9 @@ class LoginPage(BasePage):
|
|||||||
Locators.LOCATOR_LOGIN_FORM_MESSAGES_LIST
|
Locators.LOCATOR_LOGIN_FORM_MESSAGES_LIST
|
||||||
).find_elements(*Locators.LOCATOR_LOGIN_FORM_MESSAGE)
|
).find_elements(*Locators.LOCATOR_LOGIN_FORM_MESSAGE)
|
||||||
|
|
||||||
|
def check_login_success(self):
|
||||||
|
return len(self.find_elements(Locators.LOCATOR_USER_PROFILE_TOGGLER)) == 1
|
||||||
|
|
||||||
|
|
||||||
class CoursePromoPage(BasePage):
|
class CoursePromoPage(BasePage):
|
||||||
def __init__(self, driver):
|
def __init__(self, driver):
|
||||||
|
|||||||
46
Tests.py
46
Tests.py
@@ -1,13 +1,21 @@
|
|||||||
|
import os
|
||||||
from Pages import LoginPage, MainPage, CoursePromoPage
|
from Pages import LoginPage, MainPage, CoursePromoPage
|
||||||
|
import dotenv
|
||||||
|
|
||||||
|
dotenv.load_dotenv()
|
||||||
|
|
||||||
|
STEPIK_LOGIN = os.getenv("STEPIK_LOGIN")
|
||||||
|
STEPIK_PASSWORD = os.getenv("STEPIK_PASSWORD")
|
||||||
|
|
||||||
|
|
||||||
def test_positive_courses_search(browser):
|
def test_positive_courses_search(browser):
|
||||||
page = MainPage(browser)
|
page = MainPage(browser)
|
||||||
page.go_to_site()
|
page.go_to_site()
|
||||||
page.enter_word("математика")
|
q = "математика"
|
||||||
|
page.enter_word(q)
|
||||||
page.click_on_the_search_button()
|
page.click_on_the_search_button()
|
||||||
items = page.check_search_result_items()
|
items = page.check_search_result_items()
|
||||||
assert len(items) > 0
|
assert len(items) > 0, f'Курсы по запросу "{q}" не найдены'
|
||||||
|
|
||||||
|
|
||||||
def test_negative_courses_search(browser):
|
def test_negative_courses_search(browser):
|
||||||
@@ -23,7 +31,24 @@ def test_negative_courses_search(browser):
|
|||||||
+ "» ничего не найдено.\n"
|
+ "» ничего не найдено.\n"
|
||||||
+ "Попробуйте изменить параметры поиска."
|
+ "Попробуйте изменить параметры поиска."
|
||||||
in search_result_message.text
|
in search_result_message.text
|
||||||
)
|
), f'По запросу "{search_phrase}" были найдены курсы'
|
||||||
|
|
||||||
|
|
||||||
|
def test_add_course_to_favourite(browser):
|
||||||
|
page = CoursePromoPage(browser)
|
||||||
|
page.go_to_site()
|
||||||
|
assert not page.check_course_is_favourite(), "Курс изначально в избранном"
|
||||||
|
page.click_button_favourite()
|
||||||
|
assert page.check_course_is_favourite(), "Курс не добавился в избранное"
|
||||||
|
|
||||||
|
|
||||||
|
def test_search_form_input_persist(browser):
|
||||||
|
page = MainPage(browser)
|
||||||
|
page.go_to_site()
|
||||||
|
q = "математика"
|
||||||
|
page.enter_word(q)
|
||||||
|
page.driver.refresh()
|
||||||
|
assert q == page.check_search_input_text(), "Текст в поле поиска не сохранился"
|
||||||
|
|
||||||
|
|
||||||
def test_negative_login(browser):
|
def test_negative_login(browser):
|
||||||
@@ -33,12 +58,15 @@ def test_negative_login(browser):
|
|||||||
page.enter_password("password")
|
page.enter_password("password")
|
||||||
page.submit_login_form()
|
page.submit_login_form()
|
||||||
messages = page.check_login_messages()
|
messages = page.check_login_messages()
|
||||||
assert messages[0].text == "E-mail адрес и/или пароль не верны."
|
assert (
|
||||||
|
messages[0].text == "E-mail адрес и/или пароль не верны."
|
||||||
|
), "Неверный вывод ошибки авторизации"
|
||||||
|
|
||||||
|
|
||||||
def test_add_course_to_favourite(browser):
|
def test_positive_login(browser):
|
||||||
page = CoursePromoPage(browser)
|
page = LoginPage(browser)
|
||||||
page.go_to_site()
|
page.go_to_site()
|
||||||
assert not page.check_course_is_favourite()
|
page.enter_email(STEPIK_LOGIN)
|
||||||
page.click_button_favourite()
|
page.enter_password(STEPIK_PASSWORD)
|
||||||
assert page.check_course_is_favourite()
|
page.submit_login_form()
|
||||||
|
assert page.check_login_success(), "Ошибка авторизации"
|
||||||
|
|||||||
31
poetry.lock
generated
31
poetry.lock
generated
@@ -126,6 +126,20 @@ files = [
|
|||||||
{file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"},
|
{file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dotenv"
|
||||||
|
version = "0.9.9"
|
||||||
|
description = "Deprecated package"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
groups = ["main"]
|
||||||
|
files = [
|
||||||
|
{file = "dotenv-0.9.9-py2.py3-none-any.whl", hash = "sha256:29cf74a087b31dafdb5a446b6d7e11cbce8ed2741540e2339c69fbef92c94ce9"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
python-dotenv = "*"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "h11"
|
name = "h11"
|
||||||
version = "0.16.0"
|
version = "0.16.0"
|
||||||
@@ -255,6 +269,21 @@ pluggy = ">=1.5,<2"
|
|||||||
[package.extras]
|
[package.extras]
|
||||||
dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"]
|
dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "python-dotenv"
|
||||||
|
version = "1.1.0"
|
||||||
|
description = "Read key-value pairs from a .env file and set them as environment variables"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.9"
|
||||||
|
groups = ["main"]
|
||||||
|
files = [
|
||||||
|
{file = "python_dotenv-1.1.0-py3-none-any.whl", hash = "sha256:d7c01d9e2293916c18baf562d95698754b0dbbb5e74d457c45d4f6561fb9d55d"},
|
||||||
|
{file = "python_dotenv-1.1.0.tar.gz", hash = "sha256:41f90bc6f5f177fb41f53e87666db362025010eb28f60a01c9143bfa33a2b2d5"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
cli = ["click (>=5.0)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "selenium"
|
name = "selenium"
|
||||||
version = "4.31.0"
|
version = "4.31.0"
|
||||||
@@ -404,4 +433,4 @@ h11 = ">=0.9.0,<1"
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.1"
|
lock-version = "2.1"
|
||||||
python-versions = ">=3.12"
|
python-versions = ">=3.12"
|
||||||
content-hash = "1fa059942d855f68d8a148c3154737e9f2e128a9366b3064579dd8b38b46581a"
|
content-hash = "2f20f9de987d3a34220e105428639975a582acce8dc59a105356a1689d2a4169"
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ readme = "README.md"
|
|||||||
requires-python = ">=3.12"
|
requires-python = ">=3.12"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"pytest (>=8.3.5,<9.0.0)",
|
"pytest (>=8.3.5,<9.0.0)",
|
||||||
"selenium (>=4.31.0,<5.0.0)"
|
"selenium (>=4.31.0,<5.0.0)",
|
||||||
|
"dotenv (>=0.9.9,<0.10.0)"
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
|
|||||||
Reference in New Issue
Block a user