Добавлен bat-файл для запуска тестов скроллинга в уменьшенном окне браузера

pull/1/head
nsubbot 2025-08-14 12:42:25 +03:00
parent 1ed835c730
commit 88e7e27c4a
3 changed files with 16 additions and 7 deletions

View File

@ -4,7 +4,7 @@
в тестах pytest, включая настройку параметров запуска. в тестах pytest, включая настройку параметров запуска.
""" """
import ast
import pytest import pytest
from playwright.sync_api import Browser, BrowserContext, Page, sync_playwright, Playwright from playwright.sync_api import Browser, BrowserContext, Page, sync_playwright, Playwright
from _pytest.config.argparsing import Parser from _pytest.config.argparsing import Parser
@ -30,14 +30,14 @@ def pytest_addoption(parser: Parser):
help="Choose browser: chrome, remote_chrome or firefox") help="Choose browser: chrome, remote_chrome or firefox")
parser.addoption('--h', action='store', default=False, parser.addoption('--h', action='store', default=False,
help='Choose headless: True or False') help='Choose headless: True or False')
parser.addoption('--s', action='store', default={'width': 1600, 'height': 900}, parser.addoption('--s', action='store', default="{'width': 1600, 'height': 900}",
help='Size window: width,height') help='Size window: width,height')
# Закомментированные альтернативные размеры окон # Закомментированные альтернативные размеры окон
# parser.addoption('--s', action='store', default={'width': 1920, 'height': 1080}, # parser.addoption('--s', action='store', default="{'width': 1920, 'height': 1080}",
# help='Size window: width,height') # help='Size window: width,height')
# parser.addoption('--s', action='store', default={'width': 1920, 'height': 300}, # parser.addoption('--s', action='store', default="{'width': 1920, 'height': 300}",
# help='Size window: width,height') # help='Size window: width,height')
# parser.addoption('--s', action='store', default={'width': 300, 'height': 420}, # parser.addoption('--s', action='store', default="{'width': 300, 'height': 420}",
# help='Size window: width,height') # help='Size window: width,height')
parser.addoption('--slow', action='store', default=200, parser.addoption('--slow', action='store', default=200,
help='Choose slow_mo for robot action') help='Choose slow_mo for robot action')
@ -160,9 +160,11 @@ def get_context(browser: Browser, request: FixtureRequest, start: str) -> Browse
""" """
if start == 'local': if start == 'local':
# current_viewport = json.loads(request.config.getoption('--s'))
context = browser.new_context( context = browser.new_context(
# no_viewport=True, # no_viewport=True,
viewport=request.config.getoption('s'), viewport= ast.literal_eval(request.config.getoption('--s')),
locale=request.config.getoption('l') locale=request.config.getoption('l')
) )
context.set_default_timeout( context.set_default_timeout(
@ -174,7 +176,7 @@ def get_context(browser: Browser, request: FixtureRequest, start: str) -> Browse
elif start == 'remote': elif start == 'remote':
context = browser.new_context( context = browser.new_context(
viewport=request.config.getoption('s'), viewport=ast.literal_eval(request.config.getoption('--s')),
locale=request.config.getoption('l') locale=request.config.getoption('l')
) )
context.set_default_timeout( context.set_default_timeout(

4
tests/components/run.bat Normal file
View File

@ -0,0 +1,4 @@
pytest -s -v --s="{'width': 300, 'height': 420}" test_navigation_panel.py
pytest -s -v --s="{'width': 300, 'height': 420}" test_services_table.py
pytest -s -v --s="{'width': 300, 'height': 420}" test_json_container.py
pytest -s -v --s="{'width': 300, 'height': 420}" test_user_modal_window.py

View File

@ -1,5 +1,8 @@
tests/componets tests/componets
run.bat
- файл для запуска тестов скроллинга компонент в уменьшенном окне браузера
test_json_container.py test_json_container.py
Изменения включают: Изменения включают:
- Добавлены docstring для класса и всех методов в Google-формате - Добавлены docstring для класса и всех методов в Google-формате