tquality-py-selenium 0.1.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. tquality_py_selenium-0.1.5/.gitignore +17 -0
  2. tquality_py_selenium-0.1.5/CHANGELOG.md +199 -0
  3. tquality_py_selenium-0.1.5/CONTRIBUTING.md +234 -0
  4. tquality_py_selenium-0.1.5/LICENSE +201 -0
  5. tquality_py_selenium-0.1.5/NOTICE +6 -0
  6. tquality_py_selenium-0.1.5/PKG-INFO +322 -0
  7. tquality_py_selenium-0.1.5/README.md +287 -0
  8. tquality_py_selenium-0.1.5/README.ru.md +287 -0
  9. tquality_py_selenium-0.1.5/pyproject.toml +146 -0
  10. tquality_py_selenium-0.1.5/schema/config.schema.json +146 -0
  11. tquality_py_selenium-0.1.5/scripts/install-hooks.sh +67 -0
  12. tquality_py_selenium-0.1.5/src/tquality_selenium/__init__.py +69 -0
  13. tquality_py_selenium-0.1.5/src/tquality_selenium/browser.py +280 -0
  14. tquality_py_selenium-0.1.5/src/tquality_selenium/cli.py +109 -0
  15. tquality_py_selenium-0.1.5/src/tquality_selenium/config.py +104 -0
  16. tquality_py_selenium-0.1.5/src/tquality_selenium/container.py +216 -0
  17. tquality_py_selenium-0.1.5/src/tquality_selenium/elements/__init__.py +8 -0
  18. tquality_py_selenium-0.1.5/src/tquality_selenium/elements/base_element.py +126 -0
  19. tquality_py_selenium-0.1.5/src/tquality_selenium/elements/button.py +13 -0
  20. tquality_py_selenium-0.1.5/src/tquality_selenium/elements/by.py +71 -0
  21. tquality_py_selenium-0.1.5/src/tquality_selenium/elements/checkbox.py +25 -0
  22. tquality_py_selenium-0.1.5/src/tquality_selenium/elements/input.py +40 -0
  23. tquality_py_selenium-0.1.5/src/tquality_selenium/elements/label.py +8 -0
  24. tquality_py_selenium-0.1.5/src/tquality_selenium/os_utils.py +41 -0
  25. tquality_py_selenium-0.1.5/src/tquality_selenium/page_source_plugin.py +97 -0
  26. tquality_py_selenium-0.1.5/src/tquality_selenium/pages/__init__.py +3 -0
  27. tquality_py_selenium-0.1.5/src/tquality_selenium/pages/base_form.py +60 -0
  28. tquality_py_selenium-0.1.5/src/tquality_selenium/py.typed +0 -0
  29. tquality_py_selenium-0.1.5/src/tquality_selenium/schema.py +64 -0
  30. tquality_py_selenium-0.1.5/src/tquality_selenium/screencast_provider.py +249 -0
  31. tquality_py_selenium-0.1.5/src/tquality_selenium/screenshot_provider.py +30 -0
  32. tquality_py_selenium-0.1.5/src/tquality_selenium/services/__init__.py +23 -0
  33. tquality_py_selenium-0.1.5/src/tquality_selenium/services/collection_factory.py +187 -0
  34. tquality_py_selenium-0.1.5/src/tquality_selenium/services/element_factory.py +38 -0
  35. tquality_py_selenium-0.1.5/src/tquality_selenium/services/element_waiter.py +62 -0
  36. tquality_py_selenium-0.1.5/src/tquality_selenium/services/js_actions.py +169 -0
  37. tquality_py_selenium-0.1.5/src/tquality_selenium/services/waiter.py +44 -0
  38. tquality_py_selenium-0.1.5/tests/__init__.py +0 -0
  39. tquality_py_selenium-0.1.5/tests/test_browser_healthcheck.py +93 -0
  40. tquality_py_selenium-0.1.5/tests/test_browser_os_support.py +61 -0
  41. tquality_py_selenium-0.1.5/tests/test_cli.py +73 -0
  42. tquality_py_selenium-0.1.5/tests/test_config.py +87 -0
  43. tquality_py_selenium-0.1.5/tests/test_elements.py +70 -0
  44. tquality_py_selenium-0.1.5/tests/test_page_source_plugin.py +208 -0
  45. tquality_py_selenium-0.1.5/tests/test_schema.py +82 -0
  46. tquality_py_selenium-0.1.5/tests/test_screenshot_provider.py +29 -0
@@ -0,0 +1,17 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.pyc
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .eggs/
8
+ *.egg
9
+ .venv/
10
+ .env
11
+ *.log
12
+ logs/
13
+ .pytest_cache/
14
+ uv.lock
15
+ .idea/
16
+ .vscode/
17
+ report.xml
@@ -0,0 +1,199 @@
1
+ # Changelog
2
+
3
+ Формат по [Keep a Changelog](https://keepachangelog.com/ru/1.1.0/), версии по
4
+ [семантическому версионированию](https://semver.org/lang/ru/).
5
+
6
+ ## [0.1.5] - 2026-05-05
7
+
8
+ **Первая публикация в публичный [PyPI](https://pypi.org/project/tquality-py-selenium/).**
9
+
10
+ ### Добавлено
11
+
12
+ - `By` (`NamedTuple`) и `ByKind` (`str`-Enum) в
13
+ `tquality_selenium.elements.by` - собственные типы локаторов с
14
+ классовыми методами `By.id(...)`, `By.xpath(...)`, `By.css_selector(...)`,
15
+ `By.name(...)`, `By.class_name(...)`, `By.tag_name(...)`,
16
+ `By.link_text(...)`, `By.partial_link_text(...)`. `By` прозрачно
17
+ распаковывается в `(str, str)` для selenium благодаря `ByKind` от `str`.
18
+ - Английский `README.md` (по умолчанию для PyPI), русский переведен в
19
+ `README.ru.md`. В шапке обоих файлов - переключатель языков.
20
+ - Edge помечен поддерживаемым на Linux: Microsoft публикует Edge для
21
+ Linux наравне с macOS/Windows. `OSUtils._BROWSER_OS_SUPPORT[EDGE]`
22
+ расширен до `{linux, darwin, win32}`, `test_edge_smoke` получил
23
+ mark `linux`.
24
+ - CI: добавлены job'ы `publish-pypi` (загрузка в PyPI на git-теге
25
+ `vX.Y.Z`, требует `PYPI_TOKEN`), `tests:linux-browsers-healthcheck`
26
+ и `tests:windows-browsers-healthcheck`. Linux-job использует
27
+ `selenium/standalone-all-browsers:latest` - chrome, firefox, edge
28
+ и matching-драйверы запечены в образ, нет зависимости от
29
+ github.com при запуске.
30
+ - Dev-зависимость `pytest-timeout>=2.3` + `timeout = 120` в
31
+ `[tool.pytest.ini_options]` - бьёт зависшие тесты thread-таймаутом
32
+ с traceback'ом всех потоков, job не упирается в 2h-timeout
33
+ GitLab.
34
+
35
+ ### Изменено
36
+
37
+ - **Breaking.** Сигнатура `BaseElement.__init__(by: str, value: str, name="")`
38
+ заменена на `BaseElement(by: By, name="")`. То же для всех подклассов
39
+ (`Button`, `CheckBox`, `Input`, `Label`) и методов `ElementFactory`:
40
+ `element/button/checkbox/label/input(by: By, name="")`.
41
+ Миграция: `Button(By.ID, "submit", "Войти")` →
42
+ `Button(By.id("submit"), "Войти")`.
43
+ - **Breaking.** `ElementWaiter.until_visible/clickable/present/invisible/`
44
+ `not_present` теперь принимают единый `By`-локатор вместо
45
+ пары `(by: str, value: str)`.
46
+ - Зависимость `tquality-py-core` переехала с git-URL (`@v0.1.3`) на
47
+ публичный PyPI: `tquality-py-core>=0.1.5`. У потребителей `tquality-py-selenium`
48
+ больше нет необходимости в `[tool.hatch.metadata] allow-direct-references`.
49
+ - `pyproject.toml` обогащен PyPI-метаданными: английский `description`,
50
+ `readme = "README.md"`, `keywords`, `classifiers`
51
+ (включая `Framework :: Pytest`, `Typing :: Typed`), `[project.urls]`.
52
+ - sdist дополнительно включает `README.ru.md` и `CHANGELOG.md`.
53
+ - `CollectionFactory` / `DomField` внутри используют свой `ByKind`
54
+ вместо `selenium.By` (внешний API не изменился).
55
+ - Windows-CI `tests:windows-browsers-healthcheck`: PowerShell
56
+ before_script ставит `uv` через `irm https://astral.sh/uv/install.ps1`
57
+ (вместо `throw "uv не установлен"`), а `PYTHONUTF8=1` в `variables`
58
+ заставляет Python читать UTF-8 файлы независимо от системной
59
+ кодовой страницы (на Russian Windows дефолт - cp1251, и
60
+ `tquality-py-core` падал на чтении нашего pyproject.toml с
61
+ кириллическими комментариями).
62
+
63
+ ### Исправлено
64
+
65
+ - `BrowserType.UNDETECTED_CHROME` на Apple Silicon: UC хардкодит
66
+ платформу `mac-x64` в патчере (`patcher.py:113`), из-за чего на
67
+ arm64-runner'ах скачивался x86_64 chromedriver, несовместимый
68
+ с arm64 Chrome. Теперь chromedriver резолвится через Selenium
69
+ Manager (правильная архитектура), копируется в собственный кэш
70
+ `~/.cache/tquality-py-selenium/chromedriver/<platform>/<version>/`
71
+ и патчится там; на macOS дополнительно ad-hoc-подписывается через
72
+ `codesign --force --sign -`, иначе Gatekeeper убивает изменённый
73
+ патчем бинарник сигналом SIGKILL.
74
+ - `uc.Chrome(use_subprocess=True)`: без флага UC закрывает Chrome
75
+ сразу после старта, сессия не успевает подняться. См. UC
76
+ discussion #2282 / issue #2186.
77
+ - `--no-sandbox` и `--disable-dev-shm-usage` применяются только на
78
+ Linux (helper `_apply_linux_docker_chromium_flags`). Это workaround
79
+ под root-юзера в Docker и маленький `/dev/shm`; на Windows/macOS
80
+ они либо не нужны, либо ломают браузер.
81
+
82
+ ### Удалено
83
+
84
+ - Реэкспорт `By` из `tquality_selenium.browser`: используйте
85
+ `from tquality_selenium import By` (свой NamedTuple) или
86
+ `from selenium.webdriver.common.by import By` (если действительно
87
+ нужен селениумовский enum, что больше не требуется в API фреймворка).
88
+ - `[tool.hatch.metadata] allow-direct-references = true` из
89
+ `pyproject.toml` - исчез вместе с git-зависимостью на ядро.
90
+
91
+ ## [0.1.4] - 2026-04-25
92
+
93
+ ### Добавлено
94
+
95
+ - `BaseElement.dismiss_if_visible(close_with=None, timeout=None)` -
96
+ кликнуть и дождаться исчезновения, если элемент виден (иначе no-op).
97
+ Удобно для cookie-баннеров и опциональных попапов.
98
+ - `Input.submit_text(text)` - ввести текст и нажать Enter (для форм
99
+ с отправкой по Enter; оборачивает `type_text(text + Keys.RETURN)`).
100
+ - Pytest-плагин `tquality_selenium.page_source_plugin`, автоматически
101
+ регистрируется через `entry-points.pytest11`. На падении теста (любая
102
+ фаза) прикрепляет `driver.page_source` к allure как HTML-вложение
103
+ `Page source`. Единственный run-time guard - запущен ли браузер; для
104
+ api/db-only тестов плагин - no-op.
105
+ - Если `driver.page_source` сам бросает (мёртвая сессия), вместо HTML
106
+ прикрепляется короткий TEXT-диагностик, чтобы не маскировать исходное
107
+ падение.
108
+ - Поле `SeleniumConfig.attach_page_source_on_failure: bool = True` для
109
+ опт-аута. Управляется через `config.json5` или env
110
+ `TEST_ATTACH_PAGE_SOURCE_ON_FAILURE=false`.
111
+
112
+ ## [0.1.3] - 2026-04-24
113
+
114
+ **Требует tquality-py-core >= 0.1.3** (ядро с `WITH_SCREENCAST`,
115
+ DI-провайдерами Logger и `config.json5`).
116
+
117
+ ### Добавлено
118
+
119
+ - **SeleniumScreencastProvider** - реализация
120
+ `tquality_core.ScreencastProvider`: фоновый поток собирает кадры
121
+ (BiDi → CDP → классический `get_screenshot_as_png` как fallback с
122
+ warning), кодирует в webm (VP9) через imageio-ffmpeg. Обслуживает
123
+ шаги уровня `LogLevel.WITH_SCREENCAST`.
124
+ - Под-блок `screencast` в `SeleniumConfig` с параметрами `fps`,
125
+ `frame_interval`, `max_width`, `max_duration`.
126
+ - Поле-выбор `browser` + * pid=19647 revision=9ffb4aa0 version=18.8.0
127
+ report.xml: found 1 matching artifact files and directories
128
+ Uploading artifacts as "junit" to coordinator... 201 Created correlation_id=01KQW5A3BTKZQ6PJ294QFWPM76 id=7042 responseStatus=201 Created token=64_Vx_xfZ *отдельные под-блоки для каждого браузера**
129
+ (`chrome`, `firefox`, `edge`, `safari`, `undetected_chrome`) со
130
+ структурой `BrowserConfig` (`headless`, `window_width/height`,
131
+ `page_load_timeout`). Все блоки живут одновременно - переключение
132
+ между браузерами делается одной строкой `browser: ...`.
133
+ - `SeleniumConfig.active_browser` - конфиг выбранного браузера.
134
+ - **Апстрим project-agnostic сервисов из grohe-проекта**: `Waiter`,
135
+ `ElementWaiter`, `ElementFactory`, `JsActions` + `ElementJsActions`,
136
+ `CollectionFactory` (фабрика коллекций Pydantic-моделей из DOM)
137
+ + `DomField.css/xpath`.
138
+ - Обогащённые элементы: `BaseElement` получил `text`, `is_displayed`,
139
+ `is_present`, `is_enabled`, `get_attribute`, `wait_until_*` (visible/
140
+ clickable/invisible/not_present) и `js_actions` (лениво резолвится
141
+ к элементу). `Input`, `CheckBox`, `Button` расширены в том же духе.
142
+ - `BaseForm` с `title`, `current_url`, `element_factory`.
143
+ - **Динамический `SELENIUM_SCHEMA_URL`**: релизная установка - `@vX.Y.Z`,
144
+ dev/editable - `@master`. `tquality-selenium-config init` запекает
145
+ в `config.json5` пин на тег - схема стабильна между релизами.
146
+ - Описания и диапазоны валидации у полей `SeleniumConfig`
147
+ (`page_load_timeout >= 1`, `window_width` в 320..7680, и т.д.).
148
+
149
+ ### Изменено
150
+
151
+ - **`Container` → `SeleniumServices`** (composition root). Вместо
152
+ `wire_core_integrations()` - classmethod `SeleniumServices.setup()`,
153
+ принимает опционально `config_dir` (по умолчанию определяется по
154
+ файлу вызывающего, обычно `conftest.py`, для правильной резолюции
155
+ `config.json5` независимо от CWD pytest).
156
+ - **`SeleniumServices.get_service(ServiceType)`** - типобезопасный
157
+ сервис-локатор через DI-контейнер (используется элементами и формами
158
+ для лениво-резолвленных зависимостей).
159
+ - **`is_browser_started()` → `SeleniumServices.is_browser_started()`**
160
+ (classmethod вместо module-level функции).
161
+ - `BrowserService._create_driver` теперь читает параметры из
162
+ `config.active_browser`, а не из общих полей верхнего уровня.
163
+ - Все интерактивные `ElementJsActions` и `Input.type_text/append_text`
164
+ теперь оборачиваются в `maybe_highlight()` - красная рамка на время
165
+ взаимодействия, если `highlight_elements=true`.
166
+ - `SeleniumScreenshotProvider` и `SeleniumScreencastProvider` -
167
+ DI-сервисы `SeleniumServices`, инжектятся в `Logger` через
168
+ `ContextLocalSingleton` (вместо ручной регистрации).
169
+
170
+ ### Удалено
171
+
172
+ - `Container.wire_core_integrations()` (заменено на
173
+ `SeleniumServices.setup()`).
174
+ - Общие поля `headless` / `page_load_timeout` / `window_*` на уровне
175
+ `SeleniumConfig` - переехали в per-browser под-блоки.
176
+
177
+ ## [0.1.2] - 2026-04-24
178
+
179
+ ### Добавлено
180
+
181
+ - Описания и диапазоны валидации у полей `SeleniumConfig`.
182
+ - `SeleniumServices.setup(config_dir=...)` - явная директория для
183
+ резолюции `config.json` (предшественник auto-detect через inspect
184
+ в 0.1.3).
185
+
186
+ ## [0.1.1] - 2026-04-23
187
+
188
+ ### Добавлено
189
+
190
+ - Первый релиз: `SeleniumConfig` (extends core BaseConfig),
191
+ `BrowserService`, `BrowserType` enum со всеми 5 браузерами,
192
+ `OSUtils` с картой поддержки браузеров по ОС.
193
+ - Элементы: `BaseElement`, `Button`, `Input`, `CheckBox`, `Label`
194
+ (Locator-based, минимальный API).
195
+ - `SeleniumScreenshotProvider` для CRITICAL-шагов ядра.
196
+ - Healthcheck-тесты всех 5 браузеров на macos-runner.
197
+ - CLI `tquality-selenium-config` + JSON-схема SeleniumConfig.
198
+ - Публикация в GitLab Package Registry и зеркалирование на GitHub
199
+ по git-тегу `vX.Y.Z`.
@@ -0,0 +1,234 @@
1
+ # Руководство для контрибьюторов
2
+
3
+ ## Требования
4
+
5
+ - Python 3.12+
6
+ - [uv](https://docs.astral.sh/uv/) для управления окружением и зависимостями
7
+
8
+ ## Настройка окружения
9
+
10
+ ```bash
11
+ uv sync
12
+ ```
13
+
14
+ Команда создаст `.venv/` и установит зависимости проекта плюс dev-группу
15
+ (mypy, pytest).
16
+
17
+ ## Установка git-хуков
18
+
19
+ Для автоматической проверки типов mypy перед каждым коммитом выполните:
20
+
21
+ ```bash
22
+ ./scripts/install-hooks.sh
23
+ ```
24
+
25
+ ## Стиль кода
26
+
27
+ - Все комментарии, docstring, сообщения логов - на русском языке.
28
+ - Не используйте m-тире (длинное тире). Используйте обычное тире или
29
+ переформулируйте.
30
+ - Не добавляйте строку `Co-Authored-By` в commit-сообщения.
31
+
32
+ ## Формат commit-сообщений
33
+
34
+ Каждый коммит начинается с одного или нескольких тегов в квадратных скобках
35
+ (на английском), затем краткое описание на русском языке.
36
+
37
+ ### Доступные теги
38
+
39
+ - `[{module}]` - название затронутого модуля: `[Config]`, `[Browser]`,
40
+ `[Elements]`, `[Services]`, `[Container]`, `[Reporting]`, `[CI]`
41
+ - `[Docs]` - изменения документации
42
+ - `[Fix]` - исправление бага без привязки к issue
43
+ - `[Fix #{issueId}]` - исправление бага по конкретному issue
44
+ - `[Style]` - только форматирование
45
+ - `[Feature]` - новая функциональность
46
+
47
+ ### Примеры
48
+
49
+ ```
50
+ [Browser] Поддержка запуска Firefox в headless-режиме
51
+ [Elements][Feature] Добавлен класс Select для выпадающих списков
52
+ [Services][Feature] CollectionFactory: поддержка XPath-полей
53
+ [Reporting][Feature] page_source прикрепляется к allure при падении теста
54
+ [Fix #7] Исправлен stale element в type_text
55
+ [CI] Добавлен job проверки pylint
56
+ ```
57
+
58
+ ## Проверка типов
59
+
60
+ ```bash
61
+ uv run mypy
62
+ ```
63
+
64
+ Ошибки типов блокируют merge в master.
65
+
66
+ ## Запуск тестов
67
+
68
+ ```bash
69
+ uv run pytest -v
70
+ ```
71
+
72
+ Тесты запускаются автоматически в CI на каждый MR.
73
+
74
+ ### Healthcheck браузеров на macOS-runner
75
+
76
+ Job `tests:macos-browsers-healthcheck` запускает smoke-тесты всех 5 браузеров
77
+ (`tests/test_browser_healthcheck.py`). Чтобы они проходили, на runner'е
78
+ нужна разовая настройка:
79
+
80
+ 1. Установить Google Chrome, Firefox, Microsoft Edge - стандартные dmg/pkg.
81
+ 2. Включить автоматизацию Safari (требует права администратора):
82
+ ```bash
83
+ sudo safaridriver --enable
84
+ ```
85
+ Дополнительно в самом Safari: **Settings → Developer → Allow Remote
86
+ Automation** (опция появляется после включения меню Develop в
87
+ **Settings → Advanced → Show Develop menu in menu bar**).
88
+
89
+ Без этих шагов `test_safari_smoke` падает с `SessionNotCreatedException`.
90
+
91
+ ## Обновление JSON-схемы
92
+
93
+ Схема `schema/config.schema.json` описывает все поля `SeleniumConfig`
94
+ (включая унаследованные от `BaseConfig`) и публикуется через jsDelivr:
95
+
96
+ ```
97
+ https://cdn.jsdelivr.net/gh/Tquality-ru/tquality-py-selenium@master/schema/config.schema.json
98
+ ```
99
+
100
+ Если вы изменили поля `SeleniumConfig`, обновите схему:
101
+
102
+ ```bash
103
+ uv run tquality-selenium-config schema
104
+ ```
105
+
106
+ Коммит без обновленной схемы провалит тест
107
+ `test_committed_schema_matches_selenium_config` в CI.
108
+
109
+ Для инициализации `config.json5` в чужом проекте со значениями по умолчанию:
110
+
111
+ ```bash
112
+ uv run tquality-selenium-config init
113
+ ```
114
+
115
+ ## Сборка пакета
116
+
117
+ ```bash
118
+ uv build
119
+ ```
120
+
121
+ ## Релиз
122
+
123
+ Версия пакета берется из последнего git-тега вида `vX.Y.Z` через
124
+ `hatch-vcs`. В `pyproject.toml` версия не указывается (поле `dynamic`),
125
+ поэтому рассинхронизация тега и пакета невозможна.
126
+
127
+ Ставьте тег **только на master** (после merge соответствующего MR).
128
+ `mirror-to-github` публикует на GitHub именно то, что на master, и
129
+ проверяет, что коммит тега достижим из master. Тег на feature-ветке
130
+ провалит зеркалирование.
131
+
132
+ ```bash
133
+ git checkout master
134
+ git pull
135
+ git tag -a v0.2.0 -m "v0.2.0"
136
+ git push origin v0.2.0
137
+ ```
138
+
139
+ Push тега `vX.Y.Z` триггерит три CI-джоба в stage `release`:
140
+
141
+ - **`publish-pypi`** - сборка (`uv build` получает версию из тега через
142
+ `hatch-vcs`) и публикация пакета в публичный
143
+ [PyPI](https://pypi.org/project/tquality-py-selenium/). Это основной канал
144
+ установки для всех потребителей.
145
+ - **`publish`** - дублирующая публикация в GitLab Package Registry
146
+ (`https://git.tquality.ru/frameworks/python/tquality-py-selenium/-/packages`)
147
+ как внутреннее зеркало.
148
+ - **`mirror-to-github`** - пушит `master` и сам тег в
149
+ https://github.com/Tquality-ru/tquality-py-selenium (feature-ветки и
150
+ служебные refs не зеркалируются).
151
+
152
+ ### Настройка публикации в PyPI (однократно)
153
+
154
+ 1. На https://pypi.org/manage/account/token/ создать API-токен со
155
+ scope, ограниченным проектом `tquality-py-selenium` (после первой
156
+ ручной публикации). Для самой первой публикации нужен токен с
157
+ глобальным scope.
158
+ 2. В GitLab: **Settings → CI/CD → Variables** добавить переменную:
159
+ - Key: `PYPI_TOKEN`
160
+ - Value: токен с PyPI (включая префикс `pypi-`)
161
+ - Protected: yes (только для protected refs, включая теги `v*`)
162
+ - Masked: yes
163
+
164
+ ### Установка пакета из GitLab Package Registry (внутренний канал)
165
+
166
+ ```bash
167
+ uv pip install tquality-py-selenium \
168
+ --index-url "https://gitlab-ci-token:${GITLAB_TOKEN}@git.tquality.ru/api/v4/projects/43/packages/pypi/simple"
169
+ ```
170
+
171
+ Либо добавьте в `pyproject.toml` консьюмера:
172
+
173
+ ```toml
174
+ [[tool.uv.index]]
175
+ name = "tquality"
176
+ url = "https://git.tquality.ru/api/v4/projects/43/packages/pypi/simple"
177
+ explicit = true
178
+
179
+ [tool.uv.sources]
180
+ tquality-py-selenium = { index = "tquality" }
181
+ ```
182
+
183
+ ### Настройка зеркалирования в GitHub (однократно)
184
+
185
+ 1. Создать GitHub Personal Access Token с правами `public_repo` (или `repo`
186
+ для приватных).
187
+ 2. В GitLab: **Settings → CI/CD → Variables** добавить переменную:
188
+ - Key: `GITHUB_MIRROR_TOKEN`
189
+ - Value: токен с GitHub
190
+ - Protected: yes (только для protected refs, включая теги `v*`)
191
+ - Masked: yes
192
+
193
+ Для публикации в Package Registry дополнительная настройка не нужна: джоб
194
+ использует встроенный `CI_JOB_TOKEN`.
195
+
196
+ ## Структура репозитория
197
+
198
+ ```
199
+ tquality-py-selenium/
200
+ ├── .gitlab-ci.yml # CI: mypy + pytest, на тег - publish-pypi/publish/mirror-to-github
201
+ ├── pyproject.toml # конфиг проекта, mypy, зависимости (core - с PyPI)
202
+ ├── schema/
203
+ │ └── config.schema.json # JSON-схема SeleniumConfig (публикуется через jsDelivr)
204
+ ├── scripts/
205
+ │ └── install-hooks.sh
206
+ ├── src/tquality_selenium/
207
+ │ ├── browser.py # BrowserService, is_browser_started
208
+ │ ├── cli.py # CLI: tquality-selenium-config init / schema
209
+ │ ├── config.py # SeleniumConfig, BrowserType
210
+ │ ├── container.py # SeleniumServices (composition root, setup())
211
+ │ ├── os_utils.py # OSUtils: карта поддержки браузеров ОС
212
+ │ ├── page_source_plugin.py # pytest-плагин: page_source -> allure при падении
213
+ │ ├── schema.py # генератор JSON-схемы для SeleniumConfig
214
+ │ ├── screencast_provider.py # webm-видеозапись шага (BiDi -> CDP -> screenshot)
215
+ │ ├── screenshot_provider.py # снимок экрана для CRITICAL-шагов
216
+ │ ├── elements/
217
+ │ │ ├── base_element.py # BaseElement (DI-резолверы, локатор как By)
218
+ │ │ ├── button.py
219
+ │ │ ├── by.py # By NamedTuple + ByKind str-Enum (own типы локаторов)
220
+ │ │ ├── checkbox.py
221
+ │ │ ├── input.py
222
+ │ │ └── label.py
223
+ │ ├── pages/ # BaseForm (с element_factory из контейнера)
224
+ │ └── services/
225
+ │ ├── collection_factory.py # фабрика коллекций Pydantic-моделей из DOM
226
+ │ ├── element_factory.py # фабрика типизированных элементов
227
+ │ ├── element_waiter.py # explicit waits по локатору
228
+ │ ├── js_actions.py # JsActions + ElementJsActions
229
+ │ └── waiter.py # обертка над WebDriverWait
230
+ ├── tests/
231
+ ├── README.md # английский (по умолчанию для PyPI)
232
+ ├── README.ru.md # русский
233
+ └── CHANGELOG.md
234
+ ```
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing the Work or
166
+ Derivative Works thereof, You may choose to offer, and charge a
167
+ fee for, acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 ООО «Точка качества»
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,6 @@
1
+ tquality-py-selenium
2
+ Copyright 2026 ООО «Точка качества»
3
+
4
+ This product includes software developed by
5
+ ООО «Точка качества» (https://tquality.ru).
6
+ ssh user@host -t 'tmux attach -t mysession'