Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 162 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Sprint_6
В файле test_main_page.py находятся тесты на проверку вопросов/ответов, а также проверки кликов по логотипам Яндекса
и самоката
В файле test_order_page.py тесты на проверку кнопок "Заказать" в шапке и в середине главной странице, а также тест на
весь флоу оформления заказа с двумя наборами данных
9 changes: 9 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pytest
from selenium import webdriver


@pytest.fixture
def driver():
driver = webdriver.Firefox()
yield driver
driver.quit()
14 changes: 14 additions & 0 deletions data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ANSWER_TEXTS = ['Сутки — 400 рублей. Оплата курьеру — наличными или картой.',
'Пока что у нас так: один заказ — один самокат. Если хотите покататься с друзьями,'
' можете просто сделать несколько заказов — один за другим.',
'Допустим, вы оформляете заказ на 8 мая. Мы привозим самокат 8 мая в течение дня. '
'Отсчёт времени аренды начинается с момента, когда вы оплатите заказ курьеру. '
'Если мы привезли самокат 8 мая в 20:30, суточная аренда закончится 9 мая в 20:30.',
'Только начиная с завтрашнего дня. Но скоро станем расторопнее.',
'Пока что нет! Но если что-то срочное — всегда можно позвонить в поддержку по красивому номеру 1010.',
'Самокат приезжает к вам с полной зарядкой. '
'Этого хватает на восемь суток — даже если будете кататься без передышек и во сне. '
'Зарядка не понадобится.',
'Да, пока самокат не привезли. Штрафа не будет, объяснительной записки тоже не попросим. Все же свои.',
'Да, обязательно. Всем самокатов! И Москве, и Московской области.']

6 changes: 6 additions & 0 deletions helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import random


class Helpers:
def random_phone_number(self):
return random.randint(10000000000, 9999999999999)
Empty file added locators/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions locators/header_locators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from selenium.webdriver.common.by import By


class HeaderLocators:
SCOOTER_LOGO_BUTTON = By.XPATH, './/img[@alt ="Scooter"]'
YANDEX_LOGO_BUTTON = By.XPATH, './/img[@alt ="Yandex"]'
SEARCH_BUTTON_ON_DZEN_PAGE = By.XPATH, './/button[contains(text(),"Найти")]'
14 changes: 14 additions & 0 deletions locators/main_page_locators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from selenium.webdriver.common.by import By


class MainPageLocators:

QUESTION_LOCATOR = By.XPATH, '//*[@id = "accordion__heading-{}"]'
ANSWER_LOCATOR = By.XPATH, '//*[@id="accordion__panel-{}"]'
QUESTION_LOCATOR_8 = By.XPATH, '//*[@id="accordion__heading-7"]'
COOKIE_LOCATOR = By.XPATH, '//*[@id="rcc-confirm-button"]'
UPPER_ORDER_BUTTON = By.CLASS_NAME, 'Button_Button__ra12g'
LOWER_ORDER_BUTTON = By.XPATH, './/button[@class="Button_Button__ra12g Button_Middle__1CSJM"]'
QUESTIONS_HEADER_LOCATOR = By.XPATH, './/div[contains(text(),"Вопросы о важном")]'
HOME_PAGE_HEADER = By.XPATH, './/div[@class="Home_Header__iJKdX"]'

20 changes: 20 additions & 0 deletions locators/order_page_locators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from selenium.webdriver.common.by import By


class OrderPageLocators:
STATION_INPUT_LOCATOR = By.XPATH, './/input[@placeholder ="* Станция метро"]'
STATION_LOCATOR = By.XPATH, '//div[text()="Черкизовская" ]/parent::button'
NAME_INPUT_LOCATOR = By.XPATH, './/input[@placeholder ="* Имя"]'
LAST_NAME_INPUT_LOCATOR = By.XPATH, './/input[@placeholder ="* Фамилия"]'
ADRESS_INPUT_LOCATOR = By.XPATH, './/input[@placeholder ="* Адрес: куда привезти заказ"]'
PHONE_INPUT_LOCATOR = By.XPATH, './/input[@placeholder ="* Телефон: на него позвонит курьер"]'
NEXT_PAGE_BUTTON_LOCATOR = By.XPATH, './/button[contains(text(),"Далее")]'
DELIVERY_DAY_INPUT_LOCATOR = By.XPATH, './/input[@placeholder ="* Когда привезти самокат"]'
DURATION_CHOICE_LOCATOR = By.XPATH, './/span[@class="Dropdown-arrow"]'
ONE_DAY_LOCATOR = By.XPATH, './/div[contains(text(),"сутки")]'
COLOR_CHECKBOX_LOCATOR = By.ID, 'black'
ORDER_BUTTON_LOCATOR = By.XPATH, './/button[@class="Button_Button__ra12g Button_Middle__1CSJM"]'
CONFIRMATION_BUTTON_LOCATOR = By.XPATH, './/button[contains(text(),"Да")]'
ORDER_CONFIRMATION_TEXT_LOCATOR = By.CLASS_NAME, 'Order_ModalHeader__3FDaJ'
ORDER_PAGE_HEADER_LOCATOR = By.CLASS_NAME, 'Order_Header__BZXOb'

Empty file added pages/__init__.py
Empty file.
31 changes: 31 additions & 0 deletions pages/base_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait


class BasePage:

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

def find_element_with_wait(self, locator):
WebDriverWait(self.driver, 5).until(expected_conditions.visibility_of_element_located(locator))
return self.driver.find_element(*locator)

def click_to_element(self, locator):
WebDriverWait(self.driver, 5).until(expected_conditions.element_to_be_clickable(locator))
self.driver.find_element(*locator).click()

def add_text_to_element(self, locator, text):
self.find_element_with_wait(locator).send_keys(text)

def get_text_from_element(self, locator):
return self.find_element_with_wait(locator).text

def scroll_to_element(self, locator):
element = self.find_element_with_wait(locator)
self.driver.execute_script("arguments[0].scrollIntoView();", element)

def format_locators(self, locator_1, num):
method, locator = locator_1
locator = locator.format(num)
return method, locator
19 changes: 19 additions & 0 deletions pages/main_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from pages.base_page import BasePage
from locators.main_page_locators import (MainPageLocators)
import allure


class MainPage(BasePage):

@allure.step('Получаем текст с ответа')
def get_answer_text(self, num):
locator_q_formatted = self.format_locators(MainPageLocators.QUESTION_LOCATOR, num)
locator_a_formatted = self.format_locators(MainPageLocators.ANSWER_LOCATOR, num)
self.scroll_to_element(MainPageLocators.QUESTION_LOCATOR_8)
self.find_element_with_wait(locator_q_formatted)
self.click_to_element(locator_q_formatted)
self.find_element_with_wait(locator_a_formatted)
return self.get_text_from_element(locator_a_formatted)



27 changes: 27 additions & 0 deletions pages/order_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from pages.base_page import BasePage
from locators.order_page_locators import (OrderPageLocators)
import allure
from helpers import Helpers


class OrderPage(BasePage):

@allure.step('Создаем заказ')
def set_order(self, name, last_name, address, day):
self.click_to_element(OrderPageLocators.STATION_INPUT_LOCATOR)
self.click_to_element(OrderPageLocators.STATION_LOCATOR)
self.add_text_to_element(OrderPageLocators.NAME_INPUT_LOCATOR, name)
self.add_text_to_element(OrderPageLocators.LAST_NAME_INPUT_LOCATOR, last_name)
self.add_text_to_element(OrderPageLocators.ADRESS_INPUT_LOCATOR, address)
self.add_text_to_element(OrderPageLocators.PHONE_INPUT_LOCATOR, Helpers.random_phone_number(self))
self.click_to_element(OrderPageLocators.NEXT_PAGE_BUTTON_LOCATOR)
self.add_text_to_element(OrderPageLocators.DELIVERY_DAY_INPUT_LOCATOR, day)
self.click_to_element(OrderPageLocators.DURATION_CHOICE_LOCATOR)
self.click_to_element(OrderPageLocators.ONE_DAY_LOCATOR)
self.click_to_element(OrderPageLocators.COLOR_CHECKBOX_LOCATOR)
self.click_to_element(OrderPageLocators.ORDER_BUTTON_LOCATOR)
self.click_to_element(OrderPageLocators.CONFIRMATION_BUTTON_LOCATOR)

@allure.step('Проверяем, что заказ создался')
def check_order(self):
return self.get_text_from_element(OrderPageLocators.ORDER_CONFIRMATION_TEXT_LOCATOR)
23 changes: 23 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
allure-pytest==2.13.5
allure-python-commons==2.13.5
attrs==24.2.0
certifi==2024.8.30
exceptiongroup==1.2.2
h11==0.14.0
idna==3.10
iniconfig==2.0.0
outcome==1.3.0.post0
packaging==24.1
pluggy==1.5.0
PySocks==1.7.1
pytest==8.3.3
selenium==4.25.0
sniffio==1.3.1
sortedcontainers==2.4.0
tomli==2.0.2
trio==0.26.2
trio-websocket==0.11.1
typing_extensions==4.12.2
urllib3==2.2.3
websocket-client==1.8.0
wsproto==1.2.0
Empty file added tests/__init__.py
Empty file.
Loading