logikal-browser 1.0.0__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.
- logikal_browser-1.0.0/.copier-answers.yml +23 -0
- logikal_browser-1.0.0/LICENSE.txt +16 -0
- logikal_browser-1.0.0/MANIFEST.in +4 -0
- logikal_browser-1.0.0/PKG-INFO +54 -0
- logikal_browser-1.0.0/README.md +2 -0
- logikal_browser-1.0.0/README.rst +8 -0
- logikal_browser-1.0.0/browser.py +7 -0
- logikal_browser-1.0.0/compose.yml +6 -0
- logikal_browser-1.0.0/logikal_browser/__init__.py +4 -0
- logikal_browser-1.0.0/logikal_browser/browser.py +267 -0
- logikal_browser-1.0.0/logikal_browser/chrome.py +39 -0
- logikal_browser-1.0.0/logikal_browser/chromium.py +75 -0
- logikal_browser-1.0.0/logikal_browser/config.py +11 -0
- logikal_browser-1.0.0/logikal_browser/edge.py +46 -0
- logikal_browser-1.0.0/logikal_browser/install.py +62 -0
- logikal_browser-1.0.0/logikal_browser/py.typed +0 -0
- logikal_browser-1.0.0/logikal_browser/scenarios.py +58 -0
- logikal_browser-1.0.0/logikal_browser/utils.py +91 -0
- logikal_browser-1.0.0/logikal_browser.egg-info/PKG-INFO +54 -0
- logikal_browser-1.0.0/logikal_browser.egg-info/SOURCES.txt +31 -0
- logikal_browser-1.0.0/logikal_browser.egg-info/dependency_links.txt +1 -0
- logikal_browser-1.0.0/logikal_browser.egg-info/requires.txt +8 -0
- logikal_browser-1.0.0/logikal_browser.egg-info/top_level.txt +1 -0
- logikal_browser-1.0.0/pyproject.toml +58 -0
- logikal_browser-1.0.0/requirements/build.txt +2 -0
- logikal_browser-1.0.0/requirements/build.txt.lock +40 -0
- logikal_browser-1.0.0/requirements/core.txt +5 -0
- logikal_browser-1.0.0/requirements/dev.txt +6 -0
- logikal_browser-1.0.0/requirements/dev.txt.lock +136 -0
- logikal_browser-1.0.0/requirements/docs.txt +5 -0
- logikal_browser-1.0.0/requirements/docs.txt.lock +56 -0
- logikal_browser-1.0.0/requirements/extras/django.txt +1 -0
- logikal_browser-1.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
###################################################################################################
|
|
2
|
+
##
|
|
3
|
+
## DO NOT EDIT THIS FILE.
|
|
4
|
+
## This is an answers file generated by Copier.
|
|
5
|
+
##
|
|
6
|
+
###################################################################################################
|
|
7
|
+
_commit: v1.0.7
|
|
8
|
+
_src_path: git@github.com:logikal-io/python-package-template.git
|
|
9
|
+
audience: Developers
|
|
10
|
+
classifiers:
|
|
11
|
+
- 'Topic :: Software Development :: Libraries :: Python Modules'
|
|
12
|
+
cloud: false
|
|
13
|
+
description: Common browser automation utilities
|
|
14
|
+
extras:
|
|
15
|
+
- django
|
|
16
|
+
jupyter: false
|
|
17
|
+
keywords:
|
|
18
|
+
- selenium
|
|
19
|
+
license: mit
|
|
20
|
+
name: logikal-browser
|
|
21
|
+
scripts: []
|
|
22
|
+
title: logikal-browser
|
|
23
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Copyright 2025 Logikal GmbH
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
4
|
+
associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
5
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
6
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
7
|
+
furnished to do so, subject to the following conditions:
|
|
8
|
+
|
|
9
|
+
The above copyright notice and this permission notice shall be included in all copies or
|
|
10
|
+
substantial portions of the Software.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
13
|
+
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
14
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
15
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
|
16
|
+
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: logikal-browser
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Common browser automation utilities
|
|
5
|
+
Author-email: Logikal GmbH <contact@logikal.io>
|
|
6
|
+
License: Copyright 2025 Logikal GmbH
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
9
|
+
associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
10
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
11
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all copies or
|
|
15
|
+
substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
18
|
+
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
20
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
|
21
|
+
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
|
|
23
|
+
Project-URL: Documentation, https://docs.logikal.io/logikal-browser/
|
|
24
|
+
Project-URL: Release notes, https://github.com/logikal-io/logikal-browser/releases
|
|
25
|
+
Project-URL: Issue tracker, https://github.com/logikal-io/logikal-browser/issues
|
|
26
|
+
Project-URL: Source code, https://github.com/logikal-io/logikal-browser
|
|
27
|
+
Keywords: selenium
|
|
28
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
29
|
+
Classifier: Intended Audience :: Developers
|
|
30
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
31
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
32
|
+
Classifier: Programming Language :: Python :: 3
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
34
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
35
|
+
Classifier: Typing :: Typed
|
|
36
|
+
Requires-Python: ~=3.12
|
|
37
|
+
Description-Content-Type: text/x-rst
|
|
38
|
+
License-File: LICENSE.txt
|
|
39
|
+
Requires-Dist: logikal-utils[download]~=1.4
|
|
40
|
+
Requires-Dist: pillow~=11.0
|
|
41
|
+
Requires-Dist: selenium==4.28.0
|
|
42
|
+
Requires-Dist: termcolor~=2.5
|
|
43
|
+
Requires-Dist: xdg-base-dirs~=6.0
|
|
44
|
+
Provides-Extra: django
|
|
45
|
+
Requires-Dist: Django~=5.1; extra == "django"
|
|
46
|
+
|
|
47
|
+
logikal-browser
|
|
48
|
+
===============
|
|
49
|
+
Common browser automation utilities.
|
|
50
|
+
|
|
51
|
+
Getting Started
|
|
52
|
+
---------------
|
|
53
|
+
You can find the project documentation under `docs.logikal.io/logikal-browser/
|
|
54
|
+
<https://docs.logikal.io/logikal-browser/>`_.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
from logikal_browser.chrome import ChromeBrowser
|
|
3
|
+
from logikal_browser.scenarios import desktop
|
|
4
|
+
|
|
5
|
+
browser = ChromeBrowser(settings=desktop.settings, headless=False)
|
|
6
|
+
browser.get('https://logikal.io')
|
|
7
|
+
input('Press <ENTER> to stop the program... ')
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# pylint: disable=import-outside-toplevel
|
|
2
|
+
import logging
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
from collections.abc import Iterator
|
|
5
|
+
from contextlib import contextmanager
|
|
6
|
+
from importlib import import_module
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from sys import stderr
|
|
9
|
+
from time import sleep
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from logikal_utils.path import tmp_path
|
|
13
|
+
from logikal_utils.testing import hide_traceback
|
|
14
|
+
from selenium.webdriver.remote.webdriver import WebDriver
|
|
15
|
+
from selenium.webdriver.support import expected_conditions
|
|
16
|
+
from selenium.webdriver.support.wait import WebDriverWait
|
|
17
|
+
from termcolor import colored
|
|
18
|
+
from xdg_base_dirs import xdg_cache_home
|
|
19
|
+
|
|
20
|
+
from logikal_browser.config import BROWSER_VERSIONS
|
|
21
|
+
from logikal_browser.scenarios import Settings
|
|
22
|
+
from logikal_browser.utils import assert_image_equal
|
|
23
|
+
|
|
24
|
+
logger = logging.getLogger(__name__)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class BrowserVersion(ABC):
|
|
28
|
+
"""
|
|
29
|
+
Base class for browser versions.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
version: The browser version to use. Defaults to the appropriate version specified in
|
|
33
|
+
:data:`~logikal_browser.config.BROWSER_VERSIONS`.
|
|
34
|
+
install: Whether to install the web browser and the web driver.
|
|
35
|
+
install_path: The path to use for the installation.
|
|
36
|
+
Defaults to ``$XDG_CACHE_HOME/logikal_browser``.
|
|
37
|
+
|
|
38
|
+
"""
|
|
39
|
+
def __init__(
|
|
40
|
+
self,
|
|
41
|
+
version: str | None = None,
|
|
42
|
+
install: bool = True,
|
|
43
|
+
install_path: Path | None = None,
|
|
44
|
+
):
|
|
45
|
+
install_path = install_path or (xdg_cache_home() / 'logikal_browser')
|
|
46
|
+
|
|
47
|
+
self.version = version or BROWSER_VERSIONS.get(self.name)
|
|
48
|
+
if not self.version:
|
|
49
|
+
raise ValueError(f'The browser version must be specified for "{self.name}"')
|
|
50
|
+
self.path = install_path / self.name / self.version / self.binary_name
|
|
51
|
+
self.driver_path = install_path / self.driver_name / self.version / self.driver_binary_name
|
|
52
|
+
if install:
|
|
53
|
+
self.install()
|
|
54
|
+
|
|
55
|
+
def __str__(self) -> str:
|
|
56
|
+
return f'{self.name} ({self.version})'
|
|
57
|
+
|
|
58
|
+
def __repr__(self) -> str:
|
|
59
|
+
return (
|
|
60
|
+
f'<{str(self.__class__.__name__)} ({self.version}) at "{self.path}" '
|
|
61
|
+
f'with {self.driver_name} ({self.driver_version}) at "{self.driver_path}">'
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
@property
|
|
65
|
+
@abstractmethod
|
|
66
|
+
def name(self) -> str:
|
|
67
|
+
...
|
|
68
|
+
|
|
69
|
+
@abstractmethod
|
|
70
|
+
def install(self) -> None:
|
|
71
|
+
...
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def binary_name(self) -> str:
|
|
75
|
+
return self.name
|
|
76
|
+
|
|
77
|
+
@property
|
|
78
|
+
def driver_name(self) -> str:
|
|
79
|
+
return f'{self.name}driver'
|
|
80
|
+
|
|
81
|
+
@property
|
|
82
|
+
def driver_binary_name(self) -> str:
|
|
83
|
+
return self.driver_name
|
|
84
|
+
|
|
85
|
+
@property
|
|
86
|
+
def driver_version(self) -> str:
|
|
87
|
+
return self.version
|
|
88
|
+
|
|
89
|
+
@staticmethod
|
|
90
|
+
def print(message: str) -> None:
|
|
91
|
+
print(f'\n{colored(message, attrs=['bold'])}', file=stderr)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class Browser(ABC, WebDriver):
|
|
95
|
+
"""
|
|
96
|
+
Base class for browser-specific web drivers.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
settings: The browser settings to use.
|
|
100
|
+
version: The browser version to use.
|
|
101
|
+
headless: Whether to run in headless mode.
|
|
102
|
+
screenshot_path: The path where screenshots are stored.
|
|
103
|
+
screenshot_tmp_path: The temporary path to use for screenshots.
|
|
104
|
+
|
|
105
|
+
"""
|
|
106
|
+
height_offset = 0 # correction for https://github.com/SeleniumHQ/selenium/issues/14660
|
|
107
|
+
width_offset = 0 # correction for https://github.com/SeleniumHQ/selenium/issues/14660
|
|
108
|
+
|
|
109
|
+
def __init__( # pylint: disable=too-many-arguments
|
|
110
|
+
self,
|
|
111
|
+
*,
|
|
112
|
+
settings: Settings,
|
|
113
|
+
version: BrowserVersion | None = None,
|
|
114
|
+
headless: bool = True,
|
|
115
|
+
screenshot_path: Path = Path('screenshot'),
|
|
116
|
+
screenshot_tmp_path: Path | None = None,
|
|
117
|
+
**kwargs: Any,
|
|
118
|
+
):
|
|
119
|
+
self.version = version or self.version_class()
|
|
120
|
+
logger.debug(f'Browser version: {repr(self.version)}')
|
|
121
|
+
self.settings = settings
|
|
122
|
+
logger.debug(f'Browser settings: {self.settings}')
|
|
123
|
+
self.headless = headless
|
|
124
|
+
if self.headless:
|
|
125
|
+
logger.debug('Running in headless mode')
|
|
126
|
+
self.screenshot_path = screenshot_path
|
|
127
|
+
logger.debug(f'Using screenshot path "{self.screenshot_path}/"')
|
|
128
|
+
self.screenshot_tmp_path = (
|
|
129
|
+
screenshot_tmp_path or tmp_path('logikal_browser', suffix='image')
|
|
130
|
+
)
|
|
131
|
+
logger.debug(f'Using screenshot temporary path "{self.screenshot_tmp_path}/"')
|
|
132
|
+
|
|
133
|
+
super().__init__(**{**kwargs, **self.init_args()})
|
|
134
|
+
|
|
135
|
+
@abstractmethod
|
|
136
|
+
def init_args(self) -> dict[str, Any]:
|
|
137
|
+
...
|
|
138
|
+
|
|
139
|
+
@property
|
|
140
|
+
@abstractmethod
|
|
141
|
+
def version_class(self) -> type[BrowserVersion]:
|
|
142
|
+
...
|
|
143
|
+
|
|
144
|
+
def _set_settings_window_size(self, height: int | None = None) -> None:
|
|
145
|
+
width = self.settings.width + self.width_offset
|
|
146
|
+
height = (self.settings.height if height is None else height) + self.height_offset
|
|
147
|
+
logger.debug(f'Setting window size to width "{width}" height "{height}"')
|
|
148
|
+
self.set_window_size(width, height)
|
|
149
|
+
|
|
150
|
+
@contextmanager
|
|
151
|
+
def auto_height(self, wait_milliseconds: int | None) -> Iterator[None]:
|
|
152
|
+
if not self.settings.full_page_height:
|
|
153
|
+
yield
|
|
154
|
+
return
|
|
155
|
+
logger.debug('Using full page height')
|
|
156
|
+
self._set_settings_window_size()
|
|
157
|
+
if wait_milliseconds: # we use a small delay to mitigate height flakiness
|
|
158
|
+
logger.debug(f'Waiting {wait_milliseconds} ms')
|
|
159
|
+
sleep(wait_milliseconds / 1000)
|
|
160
|
+
elements = [
|
|
161
|
+
'document.body.clientHeight',
|
|
162
|
+
'document.body.scrollHeight',
|
|
163
|
+
'document.body.offsetHeight',
|
|
164
|
+
'document.documentElement.clientHeight',
|
|
165
|
+
'document.documentElement.scrollHeight',
|
|
166
|
+
'document.documentElement.offsetHeight',
|
|
167
|
+
]
|
|
168
|
+
script = f'return Math.max({','.join(elements)});'
|
|
169
|
+
height = self.execute_script(script) # type: ignore[no-untyped-call]
|
|
170
|
+
logger.debug(f'Calculated page height: {height}')
|
|
171
|
+
self._set_settings_window_size(height=height)
|
|
172
|
+
try:
|
|
173
|
+
yield
|
|
174
|
+
finally:
|
|
175
|
+
self._set_settings_window_size()
|
|
176
|
+
|
|
177
|
+
@hide_traceback
|
|
178
|
+
def check(self, name: str | None = None, wait_milliseconds: int | None = 100) -> None:
|
|
179
|
+
"""
|
|
180
|
+
Create a screenshot and check it against an expected version.
|
|
181
|
+
|
|
182
|
+
Args:
|
|
183
|
+
name: The name of the check.
|
|
184
|
+
wait_milliseconds: The milliseconds to wait before calculating the screenshot height
|
|
185
|
+
for unlimited height checks.
|
|
186
|
+
|
|
187
|
+
"""
|
|
188
|
+
name_parts = [self.screenshot_path.name, self.version.name, self.settings.name, name]
|
|
189
|
+
full_name = '_'.join(part for part in name_parts if part is not None)
|
|
190
|
+
expected = self.screenshot_path.with_name(full_name).with_suffix('.png')
|
|
191
|
+
|
|
192
|
+
script = 'document.body.style.caretColor = "transparent";' # hide the blinking caret
|
|
193
|
+
self.execute_script(script) # type: ignore[no-untyped-call]
|
|
194
|
+
|
|
195
|
+
with self.auto_height(wait_milliseconds=wait_milliseconds):
|
|
196
|
+
logger.debug('Taking screenshot')
|
|
197
|
+
# Note: we are disabling debug remote logs because they contain the verbose image data
|
|
198
|
+
logging.getLogger('selenium.webdriver.remote').setLevel(logging.INFO)
|
|
199
|
+
actual = self.get_screenshot_as_png()
|
|
200
|
+
logging.getLogger('selenium.webdriver.remote').setLevel(logging.DEBUG)
|
|
201
|
+
|
|
202
|
+
assert_image_equal(
|
|
203
|
+
actual=actual,
|
|
204
|
+
expected=expected,
|
|
205
|
+
image_tmp_path=self.screenshot_tmp_path,
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
def replace_text(self, element: Any, text: str) -> None:
|
|
209
|
+
"""
|
|
210
|
+
Replace the text of an element.
|
|
211
|
+
|
|
212
|
+
Args:
|
|
213
|
+
element: The element to use.
|
|
214
|
+
text: The new text value.
|
|
215
|
+
|
|
216
|
+
"""
|
|
217
|
+
script = f'arguments[0].innerHTML = "{text}";'
|
|
218
|
+
self.execute_script(script, element) # type: ignore[no-untyped-call]
|
|
219
|
+
|
|
220
|
+
def wait_for_element(
|
|
221
|
+
self,
|
|
222
|
+
by: str,
|
|
223
|
+
value: str,
|
|
224
|
+
timeout_seconds: int = 10,
|
|
225
|
+
poll_frequency: float = 0.5,
|
|
226
|
+
) -> None:
|
|
227
|
+
"""
|
|
228
|
+
Wait until a given element is present.
|
|
229
|
+
|
|
230
|
+
Args:
|
|
231
|
+
by: The selector type to use for locating the element.
|
|
232
|
+
value: The selector value to use for locating the element.
|
|
233
|
+
timeout_seconds: The maximal time to wait.
|
|
234
|
+
poll_frequency: Sleep interval between checks.
|
|
235
|
+
|
|
236
|
+
"""
|
|
237
|
+
wait = WebDriverWait(driver=self, timeout=timeout_seconds, poll_frequency=poll_frequency)
|
|
238
|
+
wait.until(expected_conditions.presence_of_element_located((by, value)))
|
|
239
|
+
|
|
240
|
+
def login(self, user: Any, force: bool = True) -> None:
|
|
241
|
+
"""
|
|
242
|
+
.. note:: The ``django`` extra must be installed for this method to work.
|
|
243
|
+
|
|
244
|
+
Log in a given user.
|
|
245
|
+
|
|
246
|
+
Args:
|
|
247
|
+
user: The user to log in.
|
|
248
|
+
force: Whether to log the user in without going through the authentication steps.
|
|
249
|
+
|
|
250
|
+
"""
|
|
251
|
+
try:
|
|
252
|
+
from django.conf import settings
|
|
253
|
+
from django.contrib.auth import login as django_auth_login
|
|
254
|
+
from django.http import HttpRequest
|
|
255
|
+
except ImportError as error: # pragma: no cover
|
|
256
|
+
raise RuntimeError('The `django` extra must be installed for login to work') from error
|
|
257
|
+
if not force:
|
|
258
|
+
raise NotImplementedError('Only the forced login is implemented currently')
|
|
259
|
+
|
|
260
|
+
request = HttpRequest()
|
|
261
|
+
request.session = import_module(settings.SESSION_ENGINE).SessionStore()
|
|
262
|
+
django_auth_login(request, user)
|
|
263
|
+
request.session.save()
|
|
264
|
+
self.add_cookie({
|
|
265
|
+
'name': settings.SESSION_COOKIE_NAME,
|
|
266
|
+
'value': request.session.session_key,
|
|
267
|
+
})
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from logikal_utils.download import download
|
|
2
|
+
from logikal_utils.path import move, tmp_path, unzip
|
|
3
|
+
from selenium.webdriver.chrome.options import Options
|
|
4
|
+
from selenium.webdriver.chrome.service import Service
|
|
5
|
+
from selenium.webdriver.chrome.webdriver import WebDriver
|
|
6
|
+
|
|
7
|
+
from logikal_browser import BrowserVersion
|
|
8
|
+
from logikal_browser.chromium import ChromiumBrowser
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ChromeVersion(BrowserVersion):
|
|
12
|
+
name = 'chrome'
|
|
13
|
+
|
|
14
|
+
def install(self) -> None:
|
|
15
|
+
root = f'https://storage.googleapis.com/chrome-for-testing-public/{self.version}/linux64'
|
|
16
|
+
|
|
17
|
+
if not self.path.exists():
|
|
18
|
+
self.print(f'Installing Google Chrome {self.version}')
|
|
19
|
+
tmp = tmp_path('logikal_browser', suffix=self.name)
|
|
20
|
+
unzip(download(f'{root}/chrome-linux64.zip', tmp / 'chrome.zip'))
|
|
21
|
+
move(tmp / 'chrome/chrome-linux64', self.path.parent)
|
|
22
|
+
|
|
23
|
+
if not self.driver_path.exists():
|
|
24
|
+
self.print(f'Installing Google Chrome WebDriver {self.driver_version}')
|
|
25
|
+
tmp = tmp_path('logikal_browser', suffix=self.driver_name)
|
|
26
|
+
unzip(download(f'{root}/chromedriver-linux64.zip', tmp / 'chromedriver.zip'))
|
|
27
|
+
move(tmp / 'chromedriver/chromedriver-linux64', self.driver_path.parent)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ChromeBrowser(ChromiumBrowser, WebDriver):
|
|
31
|
+
"""
|
|
32
|
+
Google Chrome WebDriver.
|
|
33
|
+
"""
|
|
34
|
+
version_class = ChromeVersion
|
|
35
|
+
options_class = Options
|
|
36
|
+
service_class = Service
|
|
37
|
+
|
|
38
|
+
# See https://github.com/SeleniumHQ/selenium/issues/14660
|
|
39
|
+
height_offset = 87
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from abc import abstractmethod
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from logikal_utils.random import DEFAULT_RANDOM_SEED
|
|
6
|
+
from selenium.webdriver.chromium.options import ChromiumOptions
|
|
7
|
+
from selenium.webdriver.chromium.service import ChromiumService
|
|
8
|
+
|
|
9
|
+
from logikal_browser import Browser
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ChromiumBrowser(Browser):
|
|
13
|
+
"""
|
|
14
|
+
Abstract base class for Chromium-based WebDriver classes.
|
|
15
|
+
"""
|
|
16
|
+
@property
|
|
17
|
+
@abstractmethod
|
|
18
|
+
def options_class(self) -> type[ChromiumOptions]:
|
|
19
|
+
...
|
|
20
|
+
|
|
21
|
+
@property
|
|
22
|
+
@abstractmethod
|
|
23
|
+
def service_class(self) -> type[ChromiumService]:
|
|
24
|
+
...
|
|
25
|
+
|
|
26
|
+
# See https://www.selenium.dev/documentation/webdriver/browsers/chrome/#options
|
|
27
|
+
# See https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md
|
|
28
|
+
def init_args(self) -> dict[str, Any]:
|
|
29
|
+
window_width = self.settings.width + self.width_offset
|
|
30
|
+
window_height = self.settings.height + self.height_offset
|
|
31
|
+
args = [
|
|
32
|
+
'--new-window',
|
|
33
|
+
'--window-position=0,0',
|
|
34
|
+
f'--window-size={window_width},{window_height}',
|
|
35
|
+
# Unwanted features
|
|
36
|
+
'--enable-automation',
|
|
37
|
+
'--no-experiments',
|
|
38
|
+
'--disable-infobars',
|
|
39
|
+
'--disable-breakpad',
|
|
40
|
+
'--disable-default-apps',
|
|
41
|
+
'--disable-extensions',
|
|
42
|
+
'--disable-component-extensions-with-background-pages',
|
|
43
|
+
'--disable-features=InterestFeedContentSuggestions,Translate',
|
|
44
|
+
'--no-default-browser-check',
|
|
45
|
+
'--no-first-run',
|
|
46
|
+
'--ash-no-nudges',
|
|
47
|
+
'--disable-search-engine-choice-screen',
|
|
48
|
+
'--propagate-iph-for-testing',
|
|
49
|
+
# Deterministic rendering (see https://issues.chromium.org/issues/40039960#comment29)
|
|
50
|
+
'--disable-partial-raster',
|
|
51
|
+
'--disable-skia-runtime-opts',
|
|
52
|
+
'--force-color-profile=srgb',
|
|
53
|
+
f'--js-flags=--random-seed={DEFAULT_RANDOM_SEED}',
|
|
54
|
+
]
|
|
55
|
+
if os.getenv('DOCKER_RUN') == '1': # pragma: no cover
|
|
56
|
+
args += ['--no-sandbox']
|
|
57
|
+
if self.headless:
|
|
58
|
+
args += [
|
|
59
|
+
'--headless=new',
|
|
60
|
+
'--in-process-gpu', # memory saving
|
|
61
|
+
'--mute-audio',
|
|
62
|
+
'--allow-pre-commit-input', # see https://issuetracker.google.com/issues/172339334
|
|
63
|
+
'--deterministic-mode',
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
options = self.options_class()
|
|
67
|
+
options.binary_location = str(self.version.path)
|
|
68
|
+
if self.settings.mobile:
|
|
69
|
+
args.append('--hide-scrollbars')
|
|
70
|
+
for arg in args:
|
|
71
|
+
options.add_argument(arg)
|
|
72
|
+
|
|
73
|
+
service = self.service_class(executable_path=str(self.version.driver_path))
|
|
74
|
+
|
|
75
|
+
return {'options': options, 'service': service}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from logikal_utils.project import PYPROJECT
|
|
2
|
+
|
|
3
|
+
#: The available browser versions as specified in the ``tool.browser.versions`` section in
|
|
4
|
+
#: ``pyproject.toml``.
|
|
5
|
+
#:
|
|
6
|
+
#: .. tip:: The currently available versions can be found on the following URLs:
|
|
7
|
+
#:
|
|
8
|
+
#: * `Chrome <https://googlechromelabs.github.io/chrome-for-testing/#stable>`_
|
|
9
|
+
#: * `Edge <https://learn.microsoft.com/en-us/deployedge/microsoft-edge-relnote-stable-channel>`_
|
|
10
|
+
#: * `Edge WebDriver <https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver>`_
|
|
11
|
+
BROWSER_VERSIONS = PYPROJECT.get('tool', {}).get('browser', {}).get('versions', {})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from subprocess import run
|
|
2
|
+
|
|
3
|
+
from logikal_utils.download import download
|
|
4
|
+
from logikal_utils.path import move, tmp_path, unzip
|
|
5
|
+
from selenium.webdriver.edge.options import Options
|
|
6
|
+
from selenium.webdriver.edge.service import Service
|
|
7
|
+
from selenium.webdriver.edge.webdriver import WebDriver
|
|
8
|
+
|
|
9
|
+
from logikal_browser import BrowserVersion
|
|
10
|
+
from logikal_browser.chromium import ChromiumBrowser
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class EdgeVersion(BrowserVersion):
|
|
14
|
+
name = 'edge'
|
|
15
|
+
binary_name = 'microsoft-edge'
|
|
16
|
+
driver_binary_name = 'msedgedriver'
|
|
17
|
+
|
|
18
|
+
def install(self) -> None:
|
|
19
|
+
if not self.path.exists():
|
|
20
|
+
self.print(f'Installing Microsoft Edge {self.version}')
|
|
21
|
+
root = 'https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable'
|
|
22
|
+
url = f'{root}/microsoft-edge-stable_{self.version}-1_amd64.deb'
|
|
23
|
+
tmp = tmp_path('logikal_browser', suffix=self.name)
|
|
24
|
+
package = download(url, tmp / 'edge.deb')
|
|
25
|
+
run(['dpkg', '-x', str(package), str(tmp / 'edge')], check=True) # nosec
|
|
26
|
+
move(tmp / 'edge/opt/microsoft/msedge', self.path.parent)
|
|
27
|
+
|
|
28
|
+
if not self.driver_path.exists():
|
|
29
|
+
self.print(f'Installing Microsoft Edge WebDriver {self.driver_version}')
|
|
30
|
+
url = f'https://msedgedriver.azureedge.net/{self.version}/edgedriver_linux64.zip'
|
|
31
|
+
tmp = tmp_path('logikal_browser', suffix=self.driver_name)
|
|
32
|
+
unzip(download(url, tmp / 'edgedriver.zip'))
|
|
33
|
+
move(tmp / 'edgedriver', self.driver_path.parent)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class EdgeBrowser(ChromiumBrowser, WebDriver):
|
|
37
|
+
"""
|
|
38
|
+
Microsoft Edge WebDriver.
|
|
39
|
+
"""
|
|
40
|
+
version_class = EdgeVersion
|
|
41
|
+
options_class = Options
|
|
42
|
+
service_class = Service
|
|
43
|
+
|
|
44
|
+
# See https://github.com/SeleniumHQ/selenium/issues/14660
|
|
45
|
+
height_offset = 78
|
|
46
|
+
width_offset = 8
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from sys import stderr
|
|
2
|
+
|
|
3
|
+
from termcolor import colored
|
|
4
|
+
|
|
5
|
+
from logikal_browser import Browser, BrowserVersion
|
|
6
|
+
from logikal_browser.chrome import ChromeBrowser
|
|
7
|
+
from logikal_browser.config import BROWSER_VERSIONS
|
|
8
|
+
from logikal_browser.edge import EdgeBrowser
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class InstalledBrowser: # pylint: disable=too-few-public-methods
|
|
12
|
+
"""
|
|
13
|
+
Information related to an installed browser.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
browser_name: The name of the browser to install.
|
|
17
|
+
version: The browser version to install.
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
BROWSERS: dict[str, type[Browser]] = {
|
|
21
|
+
'chrome': ChromeBrowser,
|
|
22
|
+
'edge': EdgeBrowser,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
def __init__(self, browser_name: str, version: str):
|
|
26
|
+
try:
|
|
27
|
+
#: The appropriate browser-specific :class:`~logikal_browser.Browser` sub-class.
|
|
28
|
+
self.browser_class: type[Browser] = InstalledBrowser.BROWSERS[browser_name]
|
|
29
|
+
except KeyError as error:
|
|
30
|
+
raise RuntimeError(f'Browser "{browser_name}" is currently not supported') from error
|
|
31
|
+
|
|
32
|
+
browser_version_class: type[BrowserVersion] = (
|
|
33
|
+
self.browser_class.version_class # type: ignore[assignment]
|
|
34
|
+
)
|
|
35
|
+
#: The installed browser-specific :class:`~logikal_browser.BrowserVersion` sub-class
|
|
36
|
+
#: instance.
|
|
37
|
+
self.browser_version: BrowserVersion = browser_version_class(version=version, install=True)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def install_all(versions: dict[str, str] | None = None) -> dict[str, InstalledBrowser]:
|
|
41
|
+
"""
|
|
42
|
+
Install all specified browser versions.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
versions: A mapping of browser names to versions to install.
|
|
46
|
+
Defaults to :data:`~logikal_browser.config.BROWSER_VERSIONS`.
|
|
47
|
+
|
|
48
|
+
"""
|
|
49
|
+
installed_browsers: dict[str, InstalledBrowser] = {}
|
|
50
|
+
|
|
51
|
+
if not (versions := BROWSER_VERSIONS if versions is None else versions):
|
|
52
|
+
raise RuntimeError('You must specify at least one browser version')
|
|
53
|
+
|
|
54
|
+
print(colored('Installing browsers', 'yellow', attrs=['bold']), file=stderr)
|
|
55
|
+
for browser_name, version in sorted(versions.items()):
|
|
56
|
+
installed_browsers[browser_name] = InstalledBrowser(
|
|
57
|
+
browser_name=browser_name,
|
|
58
|
+
version=version,
|
|
59
|
+
)
|
|
60
|
+
print(file=stderr) # trailing newline
|
|
61
|
+
|
|
62
|
+
return installed_browsers
|
|
File without changes
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from collections.abc import Iterable
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class Settings:
|
|
7
|
+
"""
|
|
8
|
+
Browser settings specification.
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
name: Name of the settings.
|
|
12
|
+
width: Browser window width.
|
|
13
|
+
height: Browser window height.
|
|
14
|
+
full_page_height: Whether to use the full page height for screenshots.
|
|
15
|
+
mobile: Whether it is a mobile browser.
|
|
16
|
+
|
|
17
|
+
"""
|
|
18
|
+
name: str
|
|
19
|
+
width: int
|
|
20
|
+
height: int
|
|
21
|
+
full_page_height: bool = True
|
|
22
|
+
mobile: bool = False
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass
|
|
26
|
+
class Scenario:
|
|
27
|
+
"""
|
|
28
|
+
Browser scenario specification.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
settings: Settings to use.
|
|
32
|
+
browsers: Browsers to use. Defaults to using all configured browser versions.
|
|
33
|
+
|
|
34
|
+
"""
|
|
35
|
+
settings: Settings | Iterable[Settings]
|
|
36
|
+
browsers: Iterable[str] | None = None
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@dataclass
|
|
40
|
+
class StandardScenario(Scenario):
|
|
41
|
+
"""
|
|
42
|
+
Standard browser scenario specification.
|
|
43
|
+
"""
|
|
44
|
+
settings: Settings
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
desktop_4k = StandardScenario(Settings('desktop_4k', width=2560, height=1440)) #:
|
|
48
|
+
desktop = StandardScenario(Settings(
|
|
49
|
+
'desktop',
|
|
50
|
+
width=1920 - 120, # offset for e.g. top bar, bottom bar, dash bar, task bar
|
|
51
|
+
height=1080 - 180, # offset for e.g. dash bar
|
|
52
|
+
)) #:
|
|
53
|
+
laptop_l = StandardScenario(Settings('laptop_l', width=1440, height=900)) #:
|
|
54
|
+
laptop = StandardScenario(Settings('laptop', width=1024, height=768)) #:
|
|
55
|
+
tablet = StandardScenario(Settings('tablet', width=768, height=1024, mobile=True)) #:
|
|
56
|
+
mobile_l = StandardScenario(Settings('mobile_l', width=425, height=680, mobile=True)) #:
|
|
57
|
+
mobile_m = StandardScenario(Settings('mobile_m', width=375, height=600, mobile=True)) #:
|
|
58
|
+
mobile_s = StandardScenario(Settings('mobile_s', width=320, height=512, mobile=True)) #:
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
from io import BytesIO
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from shutil import copy
|
|
7
|
+
from subprocess import run
|
|
8
|
+
|
|
9
|
+
from logikal_utils.testing import hide_traceback
|
|
10
|
+
from PIL import Image, ImageChops
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@hide_traceback
|
|
16
|
+
def assert_image_equal(actual: bytes, expected: Path, image_tmp_path: Path) -> None:
|
|
17
|
+
tmp_actual_path = image_tmp_path / 'actual.png'
|
|
18
|
+
tmp_expected_path = image_tmp_path / 'expected.png'
|
|
19
|
+
tmp_diff_path = image_tmp_path / 'diff.png'
|
|
20
|
+
|
|
21
|
+
logger.info(f'Checking expected image in "{expected}"')
|
|
22
|
+
if expected.is_file():
|
|
23
|
+
with Image.open(BytesIO(actual)) as actual_image, Image.open(expected) as expected_image:
|
|
24
|
+
if actual_image == expected_image:
|
|
25
|
+
logger.info('The actual image matches the expected image')
|
|
26
|
+
return
|
|
27
|
+
|
|
28
|
+
tmp_actual_path.write_bytes(actual) # saving the temporary actual image
|
|
29
|
+
copy(expected, tmp_expected_path) # saving the temporary expected image
|
|
30
|
+
diff_image = ImageChops.invert(ImageChops.difference(
|
|
31
|
+
expected_image.convert('RGB'),
|
|
32
|
+
actual_image.convert('RGB'),
|
|
33
|
+
))
|
|
34
|
+
diff_image.save(str(tmp_diff_path)) # saving the temporary diff image
|
|
35
|
+
save_image_prompt(
|
|
36
|
+
message='Actual image differs from the expected image',
|
|
37
|
+
source=tmp_actual_path, destination=expected, difference=tmp_diff_path,
|
|
38
|
+
)
|
|
39
|
+
else:
|
|
40
|
+
logger.info('Expected image not found')
|
|
41
|
+
tmp_actual_path.write_bytes(actual) # saving the temporary actual image
|
|
42
|
+
save_image_prompt(
|
|
43
|
+
message='Expected image file does not exist',
|
|
44
|
+
source=tmp_actual_path, destination=expected,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def save_image_prompt(
|
|
49
|
+
message: str,
|
|
50
|
+
source: Path,
|
|
51
|
+
destination: Path,
|
|
52
|
+
difference: Path | None = None,
|
|
53
|
+
) -> None:
|
|
54
|
+
if not sys.stdin.isatty():
|
|
55
|
+
error_lines = [
|
|
56
|
+
f'{message} and this is not an interactive session (consider using --live)',
|
|
57
|
+
f' Actual: file://{source}',
|
|
58
|
+
f' Expected: file://{destination}',
|
|
59
|
+
]
|
|
60
|
+
if difference:
|
|
61
|
+
error_lines.append(f' Difference: file://{difference}')
|
|
62
|
+
raise AssertionError('\n'.join(error_lines))
|
|
63
|
+
try:
|
|
64
|
+
short_destination = destination.relative_to(os.getcwd())
|
|
65
|
+
except ValueError:
|
|
66
|
+
short_destination = destination
|
|
67
|
+
|
|
68
|
+
colors = {'red': '\033[31m\033[1m', 'reset': '\033[0m'}
|
|
69
|
+
print(f'\n{colors['red']}{message}!{colors['reset']}')
|
|
70
|
+
print(short_destination)
|
|
71
|
+
|
|
72
|
+
prompt = f'{colors['red']}>{colors['reset']} '
|
|
73
|
+
if (opener := Path('/usr/bin/xdg-open')).exists():
|
|
74
|
+
response = input(f'{prompt}Press "enter" to open or type "s" to skip or "c" to cancel: ')
|
|
75
|
+
if response == 's':
|
|
76
|
+
logger.info('Image opening skipped')
|
|
77
|
+
elif not response:
|
|
78
|
+
# This subprocess call is secure as it is not using untrusted input
|
|
79
|
+
run([str(opener), str(source)], check=False) # nosec
|
|
80
|
+
else:
|
|
81
|
+
raise AssertionError('Image opening canceled')
|
|
82
|
+
else:
|
|
83
|
+
print(f'{prompt}See file://{source}')
|
|
84
|
+
|
|
85
|
+
response = input(f'{prompt}Type "accept" to accept this version or press "enter" to reject: ')
|
|
86
|
+
if response == 'accept':
|
|
87
|
+
destination.parent.mkdir(parents=True, exist_ok=True)
|
|
88
|
+
copy(source, destination)
|
|
89
|
+
logger.info(f'Image saved at "{short_destination}"')
|
|
90
|
+
else:
|
|
91
|
+
raise AssertionError(f'Image rejected (file://{source})')
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: logikal-browser
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Common browser automation utilities
|
|
5
|
+
Author-email: Logikal GmbH <contact@logikal.io>
|
|
6
|
+
License: Copyright 2025 Logikal GmbH
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
9
|
+
associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
10
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
11
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all copies or
|
|
15
|
+
substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
18
|
+
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
20
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
|
21
|
+
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
|
|
23
|
+
Project-URL: Documentation, https://docs.logikal.io/logikal-browser/
|
|
24
|
+
Project-URL: Release notes, https://github.com/logikal-io/logikal-browser/releases
|
|
25
|
+
Project-URL: Issue tracker, https://github.com/logikal-io/logikal-browser/issues
|
|
26
|
+
Project-URL: Source code, https://github.com/logikal-io/logikal-browser
|
|
27
|
+
Keywords: selenium
|
|
28
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
29
|
+
Classifier: Intended Audience :: Developers
|
|
30
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
31
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
32
|
+
Classifier: Programming Language :: Python :: 3
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
34
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
35
|
+
Classifier: Typing :: Typed
|
|
36
|
+
Requires-Python: ~=3.12
|
|
37
|
+
Description-Content-Type: text/x-rst
|
|
38
|
+
License-File: LICENSE.txt
|
|
39
|
+
Requires-Dist: logikal-utils[download]~=1.4
|
|
40
|
+
Requires-Dist: pillow~=11.0
|
|
41
|
+
Requires-Dist: selenium==4.28.0
|
|
42
|
+
Requires-Dist: termcolor~=2.5
|
|
43
|
+
Requires-Dist: xdg-base-dirs~=6.0
|
|
44
|
+
Provides-Extra: django
|
|
45
|
+
Requires-Dist: Django~=5.1; extra == "django"
|
|
46
|
+
|
|
47
|
+
logikal-browser
|
|
48
|
+
===============
|
|
49
|
+
Common browser automation utilities.
|
|
50
|
+
|
|
51
|
+
Getting Started
|
|
52
|
+
---------------
|
|
53
|
+
You can find the project documentation under `docs.logikal.io/logikal-browser/
|
|
54
|
+
<https://docs.logikal.io/logikal-browser/>`_.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.copier-answers.yml
|
|
2
|
+
LICENSE.txt
|
|
3
|
+
MANIFEST.in
|
|
4
|
+
README.md
|
|
5
|
+
README.rst
|
|
6
|
+
browser.py
|
|
7
|
+
compose.yml
|
|
8
|
+
pyproject.toml
|
|
9
|
+
logikal_browser/__init__.py
|
|
10
|
+
logikal_browser/browser.py
|
|
11
|
+
logikal_browser/chrome.py
|
|
12
|
+
logikal_browser/chromium.py
|
|
13
|
+
logikal_browser/config.py
|
|
14
|
+
logikal_browser/edge.py
|
|
15
|
+
logikal_browser/install.py
|
|
16
|
+
logikal_browser/py.typed
|
|
17
|
+
logikal_browser/scenarios.py
|
|
18
|
+
logikal_browser/utils.py
|
|
19
|
+
logikal_browser.egg-info/PKG-INFO
|
|
20
|
+
logikal_browser.egg-info/SOURCES.txt
|
|
21
|
+
logikal_browser.egg-info/dependency_links.txt
|
|
22
|
+
logikal_browser.egg-info/requires.txt
|
|
23
|
+
logikal_browser.egg-info/top_level.txt
|
|
24
|
+
requirements/build.txt
|
|
25
|
+
requirements/build.txt.lock
|
|
26
|
+
requirements/core.txt
|
|
27
|
+
requirements/dev.txt
|
|
28
|
+
requirements/dev.txt.lock
|
|
29
|
+
requirements/docs.txt
|
|
30
|
+
requirements/docs.txt.lock
|
|
31
|
+
requirements/extras/django.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
logikal_browser
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ['setuptools>=64', 'setuptools-scm>=8']
|
|
3
|
+
build-backend = 'setuptools.build_meta'
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = 'logikal-browser'
|
|
7
|
+
description = 'Common browser automation utilities'
|
|
8
|
+
readme = 'README.rst'
|
|
9
|
+
requires-python = '~= 3.12'
|
|
10
|
+
license = {file = 'LICENSE.txt'}
|
|
11
|
+
authors = [{name = 'Logikal GmbH', email = 'contact@logikal.io'}]
|
|
12
|
+
keywords = ['selenium']
|
|
13
|
+
classifiers = [
|
|
14
|
+
'Development Status :: 5 - Production/Stable',
|
|
15
|
+
'Intended Audience :: Developers',
|
|
16
|
+
'License :: OSI Approved :: MIT License',
|
|
17
|
+
'Operating System :: POSIX :: Linux',
|
|
18
|
+
'Programming Language :: Python :: 3',
|
|
19
|
+
'Programming Language :: Python :: 3.12',
|
|
20
|
+
'Topic :: Software Development :: Libraries :: Python Modules',
|
|
21
|
+
'Typing :: Typed',
|
|
22
|
+
]
|
|
23
|
+
dynamic = ['version', 'dependencies', 'optional-dependencies']
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
'Documentation' = 'https://docs.logikal.io/logikal-browser/'
|
|
27
|
+
'Release notes' = 'https://github.com/logikal-io/logikal-browser/releases'
|
|
28
|
+
'Issue tracker' = 'https://github.com/logikal-io/logikal-browser/issues'
|
|
29
|
+
'Source code' = 'https://github.com/logikal-io/logikal-browser'
|
|
30
|
+
|
|
31
|
+
[tool.setuptools.dynamic]
|
|
32
|
+
dependencies = {file = 'requirements/core.txt'}
|
|
33
|
+
|
|
34
|
+
[tool.setuptools.dynamic.optional-dependencies]
|
|
35
|
+
django = {file = 'requirements/extras/django.txt'}
|
|
36
|
+
|
|
37
|
+
[tool.setuptools]
|
|
38
|
+
packages = ['logikal_browser']
|
|
39
|
+
|
|
40
|
+
[tool.setuptools_scm]
|
|
41
|
+
|
|
42
|
+
[tool.pytest.ini_options]
|
|
43
|
+
DJANGO_SETTINGS_MODULE = 'tests.website.settings'
|
|
44
|
+
|
|
45
|
+
[tool.browser.versions]
|
|
46
|
+
chrome = '132.0.6834.83'
|
|
47
|
+
edge = '132.0.2957.115'
|
|
48
|
+
|
|
49
|
+
[[tool.mypy.overrides]]
|
|
50
|
+
ignore_missing_imports = true
|
|
51
|
+
module = ['factory.*']
|
|
52
|
+
|
|
53
|
+
[tool.coverage.report]
|
|
54
|
+
omit = ['browser.py']
|
|
55
|
+
exclude_lines = [
|
|
56
|
+
'pragma: no cover',
|
|
57
|
+
'\.\.\.', # exclude abstract methods
|
|
58
|
+
]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
###################################################################################################
|
|
2
|
+
##
|
|
3
|
+
## DO NOT EDIT THIS FILE.
|
|
4
|
+
## This is a locked requirements file generated by pyorbs.
|
|
5
|
+
##
|
|
6
|
+
## Requirements hash: 4b966e84286870990e5b2f35c748d3d289cc313f0d0828bc7e796ab915d7f817
|
|
7
|
+
##
|
|
8
|
+
###################################################################################################
|
|
9
|
+
build==1.2.2
|
|
10
|
+
certifi==2024.12.14
|
|
11
|
+
cffi==1.17.1
|
|
12
|
+
charset-normalizer==3.4.1
|
|
13
|
+
cryptography==44.0.0
|
|
14
|
+
docutils==0.21.2
|
|
15
|
+
id==1.5.0
|
|
16
|
+
idna==3.10
|
|
17
|
+
jaraco.classes==3.4.0
|
|
18
|
+
jaraco.context==6.0.1
|
|
19
|
+
jaraco.functools==4.1.0
|
|
20
|
+
jeepney==0.8.0
|
|
21
|
+
keyring==25.6.0
|
|
22
|
+
markdown-it-py==3.0.0
|
|
23
|
+
mdurl==0.1.2
|
|
24
|
+
more-itertools==10.6.0
|
|
25
|
+
nh3==0.2.20
|
|
26
|
+
packaging==24.2
|
|
27
|
+
pip==24.3.1
|
|
28
|
+
pycparser==2.22
|
|
29
|
+
Pygments==2.19.1
|
|
30
|
+
pyproject_hooks==1.2.0
|
|
31
|
+
readme_renderer==44.0
|
|
32
|
+
requests==2.32.3
|
|
33
|
+
requests-toolbelt==1.0.0
|
|
34
|
+
rfc3986==2.0.0
|
|
35
|
+
rich==13.9.4
|
|
36
|
+
SecretStorage==3.3.3
|
|
37
|
+
setuptools==75.8.0
|
|
38
|
+
twine==6.1.0
|
|
39
|
+
urllib3==2.3.0
|
|
40
|
+
wheel==0.45.1
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
###################################################################################################
|
|
2
|
+
##
|
|
3
|
+
## DO NOT EDIT THIS FILE.
|
|
4
|
+
## This is a locked requirements file generated by pyorbs.
|
|
5
|
+
##
|
|
6
|
+
## Requirements hash: 4aae21fec85be7f9a23befaf214f59f075ec5f0bfbe4afe7334b5387dbc81815
|
|
7
|
+
##
|
|
8
|
+
###################################################################################################
|
|
9
|
+
-e .
|
|
10
|
+
alabaster==1.0.0
|
|
11
|
+
appdirs==1.4.4
|
|
12
|
+
asgiref==3.8.1
|
|
13
|
+
astroid==3.3.8
|
|
14
|
+
attrs==24.3.0
|
|
15
|
+
babel==2.16.0
|
|
16
|
+
bandit==1.8.2
|
|
17
|
+
build==1.2.2
|
|
18
|
+
certifi==2024.12.14
|
|
19
|
+
cffi==1.17.1
|
|
20
|
+
charset-normalizer==3.4.1
|
|
21
|
+
click==8.1.8
|
|
22
|
+
codespell==2.3.0
|
|
23
|
+
colorama==0.4.6
|
|
24
|
+
coverage==7.6.10
|
|
25
|
+
cryptography==44.0.0
|
|
26
|
+
cssbeautifier==1.15.1
|
|
27
|
+
dill==0.3.9
|
|
28
|
+
Django==5.1.5
|
|
29
|
+
django-migration-linter==5.1.0
|
|
30
|
+
django-stubs==5.1.2
|
|
31
|
+
django-stubs-ext==5.1.2
|
|
32
|
+
djlint==1.36.4
|
|
33
|
+
docker==7.1.0
|
|
34
|
+
docutils==0.21.2
|
|
35
|
+
EditorConfig==0.17.0
|
|
36
|
+
execnet==2.1.1
|
|
37
|
+
factory_boy==3.3.1
|
|
38
|
+
Faker==33.3.1
|
|
39
|
+
filelock==3.17.0
|
|
40
|
+
h11==0.14.0
|
|
41
|
+
id==1.5.0
|
|
42
|
+
idna==3.10
|
|
43
|
+
imagesize==1.4.1
|
|
44
|
+
inflection==0.5.1
|
|
45
|
+
iniconfig==2.0.0
|
|
46
|
+
isort==5.13.2
|
|
47
|
+
jaraco.classes==3.4.0
|
|
48
|
+
jaraco.context==6.0.1
|
|
49
|
+
jaraco.functools==4.1.0
|
|
50
|
+
jeepney==0.8.0
|
|
51
|
+
Jinja2==3.1.5
|
|
52
|
+
jsbeautifier==1.15.1
|
|
53
|
+
json5==0.10.0
|
|
54
|
+
keyring==25.6.0
|
|
55
|
+
logikal-docs==1.2.1
|
|
56
|
+
logikal-utils==1.4.0
|
|
57
|
+
markdown-it-py==3.0.0
|
|
58
|
+
MarkupSafe==3.0.2
|
|
59
|
+
mccabe==0.7.0
|
|
60
|
+
mdurl==0.1.2
|
|
61
|
+
more-itertools==10.6.0
|
|
62
|
+
mypy==1.14.1
|
|
63
|
+
mypy-extensions==1.0.0
|
|
64
|
+
nh3==0.2.20
|
|
65
|
+
orjson==3.10.15
|
|
66
|
+
outcome==1.3.0.post0
|
|
67
|
+
packaging==24.2
|
|
68
|
+
pathspec==0.12.1
|
|
69
|
+
pbr==6.1.0
|
|
70
|
+
pillow==11.1.0
|
|
71
|
+
pip==24.3.1
|
|
72
|
+
pip-licenses==5.0.0
|
|
73
|
+
platformdirs==4.3.6
|
|
74
|
+
pluggy==1.5.0
|
|
75
|
+
prettytable==3.12.0
|
|
76
|
+
psutil==6.1.1
|
|
77
|
+
pycodestyle==2.12.1
|
|
78
|
+
pycparser==2.22
|
|
79
|
+
pydocstyle==6.3.0
|
|
80
|
+
Pygments==2.19.1
|
|
81
|
+
pylint==3.3.3
|
|
82
|
+
pylint-django==2.6.1
|
|
83
|
+
pylint-plugin-utils==0.8.2
|
|
84
|
+
pyorbs==2.1.0
|
|
85
|
+
pyproject_hooks==1.2.0
|
|
86
|
+
PySocks==1.7.1
|
|
87
|
+
pytest==8.3.4
|
|
88
|
+
pytest-cov==6.0.0
|
|
89
|
+
pytest-django==4.9.0
|
|
90
|
+
pytest-factoryboy==2.7.0
|
|
91
|
+
pytest-logikal==3.7.1
|
|
92
|
+
pytest-mock==3.14.0
|
|
93
|
+
pytest-mypy==0.10.3
|
|
94
|
+
pytest-xdist==3.6.1
|
|
95
|
+
python-dateutil==2.9.0.post0
|
|
96
|
+
PyYAML==6.0.2
|
|
97
|
+
readme_renderer==44.0
|
|
98
|
+
regex==2024.11.6
|
|
99
|
+
requests==2.32.3
|
|
100
|
+
requests-toolbelt==1.0.0
|
|
101
|
+
rfc3986==2.0.0
|
|
102
|
+
rich==13.9.4
|
|
103
|
+
SecretStorage==3.3.3
|
|
104
|
+
selenium==4.28.0
|
|
105
|
+
setuptools==75.8.0
|
|
106
|
+
six==1.17.0
|
|
107
|
+
sniffio==1.3.1
|
|
108
|
+
snowballstemmer==2.2.0
|
|
109
|
+
sortedcontainers==2.4.0
|
|
110
|
+
Sphinx==8.1.3
|
|
111
|
+
sphinx-rtd-theme==3.0.1
|
|
112
|
+
sphinxcontrib-applehelp==2.0.0
|
|
113
|
+
sphinxcontrib-devhelp==2.0.0
|
|
114
|
+
sphinxcontrib-htmlhelp==2.1.0
|
|
115
|
+
sphinxcontrib-jquery==4.1
|
|
116
|
+
sphinxcontrib-jsmath==1.0.1
|
|
117
|
+
sphinxcontrib-qthelp==2.0.0
|
|
118
|
+
sphinxcontrib-serializinghtml==2.0.0
|
|
119
|
+
sqlparse==0.5.3
|
|
120
|
+
stevedore==5.4.0
|
|
121
|
+
termcolor==2.5.0
|
|
122
|
+
toml==0.10.2
|
|
123
|
+
tomli==2.2.1
|
|
124
|
+
tomlkit==0.13.2
|
|
125
|
+
tqdm==4.67.1
|
|
126
|
+
trio==0.28.0
|
|
127
|
+
trio-websocket==0.11.1
|
|
128
|
+
twine==6.1.0
|
|
129
|
+
types-PyYAML==6.0.12.20241230
|
|
130
|
+
typing_extensions==4.12.2
|
|
131
|
+
urllib3==2.3.0
|
|
132
|
+
wcwidth==0.2.13
|
|
133
|
+
websocket-client==1.8.0
|
|
134
|
+
wheel==0.45.1
|
|
135
|
+
wsproto==1.2.0
|
|
136
|
+
xdg-base-dirs==6.0.2
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
###################################################################################################
|
|
2
|
+
##
|
|
3
|
+
## DO NOT EDIT THIS FILE.
|
|
4
|
+
## This is a locked requirements file generated by pyorbs.
|
|
5
|
+
##
|
|
6
|
+
## Requirements hash: ee66828f1895e654694f15e47bb56b6e13ef6a493d4bad03d88d98bc195b2d35
|
|
7
|
+
##
|
|
8
|
+
###################################################################################################
|
|
9
|
+
-e .
|
|
10
|
+
alabaster==1.0.0
|
|
11
|
+
asgiref==3.8.1
|
|
12
|
+
attrs==24.3.0
|
|
13
|
+
babel==2.16.0
|
|
14
|
+
certifi==2024.12.14
|
|
15
|
+
charset-normalizer==3.4.1
|
|
16
|
+
Django==5.1.5
|
|
17
|
+
docutils==0.21.2
|
|
18
|
+
h11==0.14.0
|
|
19
|
+
idna==3.10
|
|
20
|
+
imagesize==1.4.1
|
|
21
|
+
Jinja2==3.1.5
|
|
22
|
+
logikal-docs==1.2.1
|
|
23
|
+
logikal-utils==1.4.0
|
|
24
|
+
MarkupSafe==3.0.2
|
|
25
|
+
outcome==1.3.0.post0
|
|
26
|
+
packaging==24.2
|
|
27
|
+
pillow==11.1.0
|
|
28
|
+
pip==24.3.1
|
|
29
|
+
Pygments==2.19.1
|
|
30
|
+
PySocks==1.7.1
|
|
31
|
+
requests==2.32.3
|
|
32
|
+
selenium==4.28.0
|
|
33
|
+
setuptools==75.8.0
|
|
34
|
+
sniffio==1.3.1
|
|
35
|
+
snowballstemmer==2.2.0
|
|
36
|
+
sortedcontainers==2.4.0
|
|
37
|
+
Sphinx==8.1.3
|
|
38
|
+
sphinx-rtd-theme==3.0.1
|
|
39
|
+
sphinxcontrib-applehelp==2.0.0
|
|
40
|
+
sphinxcontrib-devhelp==2.0.0
|
|
41
|
+
sphinxcontrib-htmlhelp==2.1.0
|
|
42
|
+
sphinxcontrib-jquery==4.1
|
|
43
|
+
sphinxcontrib-jsmath==1.0.1
|
|
44
|
+
sphinxcontrib-qthelp==2.0.0
|
|
45
|
+
sphinxcontrib-serializinghtml==2.0.0
|
|
46
|
+
sqlparse==0.5.3
|
|
47
|
+
termcolor==2.5.0
|
|
48
|
+
tqdm==4.67.1
|
|
49
|
+
trio==0.28.0
|
|
50
|
+
trio-websocket==0.11.1
|
|
51
|
+
typing_extensions==4.12.2
|
|
52
|
+
urllib3==2.3.0
|
|
53
|
+
websocket-client==1.8.0
|
|
54
|
+
wheel==0.45.1
|
|
55
|
+
wsproto==1.2.0
|
|
56
|
+
xdg-base-dirs==6.0.2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Django~=5.1
|