utils-seleniumxp 1.0.0__tar.gz → 1.2.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.
- {utils_seleniumxp-1.0.0 → utils_seleniumxp-1.2.0}/PKG-INFO +14 -12
- {utils_seleniumxp-1.0.0 → utils_seleniumxp-1.2.0}/README.md +4 -4
- {utils_seleniumxp-1.0.0 → utils_seleniumxp-1.2.0}/pyproject.toml +58 -35
- {utils_seleniumxp-1.0.0 → utils_seleniumxp-1.2.0}/utils_seleniumxp/__init__.py +12 -22
- {utils_seleniumxp-1.0.0 → utils_seleniumxp-1.2.0}/utils_seleniumxp/eventfiring_addon.py +8 -8
- {utils_seleniumxp-1.0.0 → utils_seleniumxp-1.2.0}/utils_seleniumxp/eventlistener.py +2 -4
- {utils_seleniumxp-1.0.0 → utils_seleniumxp-1.2.0}/utils_seleniumxp/locatorutils.py +19 -13
- {utils_seleniumxp-1.0.0 → utils_seleniumxp-1.2.0}/utils_seleniumxp/sessionhandling.py +219 -120
- {utils_seleniumxp-1.0.0 → utils_seleniumxp-1.2.0}/utils_seleniumxp/version.py +16 -6
- {utils_seleniumxp-1.0.0 → utils_seleniumxp-1.2.0}/utils_seleniumxp/webdriver_addon.py +480 -177
- {utils_seleniumxp-1.0.0 → utils_seleniumxp-1.2.0}/utils_seleniumxp/webelement_addon.py +61 -7
- {utils_seleniumxp-1.0.0 → utils_seleniumxp-1.2.0}/.gitignore +0 -0
- {utils_seleniumxp-1.0.0 → utils_seleniumxp-1.2.0}/AUTHORS.md +0 -0
- {utils_seleniumxp-1.0.0 → utils_seleniumxp-1.2.0}/LICENSE.txt +0 -0
- {utils_seleniumxp-1.0.0 → utils_seleniumxp-1.2.0}/utils_seleniumxp/SeleniumPythonUtils.ini +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: utils-seleniumxp
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: Package with utilities and functional extensions for Selenium webdriver Python language bindings
|
|
5
5
|
Project-URL: Documentation, https://dornech.github.io/utils-seleniumxp
|
|
6
6
|
Project-URL: Source, https://github.com/dornech/utils-seleniumxp
|
|
@@ -10,23 +10,25 @@ Author-email: dornech <dornech@gmx.de>
|
|
|
10
10
|
License: GPL-3.0-only
|
|
11
11
|
License-File: AUTHORS.md
|
|
12
12
|
License-File: LICENSE.txt
|
|
13
|
-
Keywords: Chrome,FireFox,Selenium,close popup,event-firing webdriver,factory function,parsel,webdriver
|
|
13
|
+
Keywords: Chrome,FireFox,Selenium,close popup,event-firing webdriver,factory function,parsel,requests,stealth-selenium,waitless,webdriver
|
|
14
14
|
Classifier: Programming Language :: Python
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
17
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
17
|
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
19
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
21
|
-
Requires-Python: >=3.
|
|
20
|
+
Requires-Python: >=3.11
|
|
22
21
|
Requires-Dist: cssify
|
|
22
|
+
Requires-Dist: hatchling
|
|
23
23
|
Requires-Dist: parsel
|
|
24
24
|
Requires-Dist: psutil
|
|
25
25
|
Requires-Dist: requests
|
|
26
|
-
Requires-Dist: selenium
|
|
26
|
+
Requires-Dist: selenium-autowait
|
|
27
27
|
Requires-Dist: selenium-requests
|
|
28
|
-
Requires-Dist:
|
|
28
|
+
Requires-Dist: selenium>=4.33.0
|
|
29
|
+
Requires-Dist: stealthenium>=1.1.1
|
|
29
30
|
Requires-Dist: utils-mystuff
|
|
31
|
+
Requires-Dist: waitless
|
|
30
32
|
Description-Content-Type: text/markdown
|
|
31
33
|
|
|
32
34
|
# SeleniumXP utilities for Python
|
|
@@ -38,20 +40,20 @@ Package with utilities and functional extensions for Selenium webdriver Python l
|
|
|
38
40
|
The package consist of various helpers and extensions to the Selenium webdriver:
|
|
39
41
|
|
|
40
42
|
- module for session handling especially a custom factory function to initialize a webdriver object
|
|
41
|
-
- module with additional methods for the webdriver class
|
|
43
|
+
- module with additional methods for the webdriver class and a respective mixin class
|
|
42
44
|
- module with convenience functions for locators
|
|
43
45
|
- module with additional methods for the webelement class
|
|
44
46
|
- an extended event-firing webdriver and an extended listener abstract base class
|
|
45
47
|
- a sample event listener implementation based on the extended abstract base class
|
|
46
48
|
|
|
47
|
-
Different from other packages extending the Selenium webdriver class does not work with
|
|
49
|
+
Different from other packages extending the Selenium webdriver class this package does not work with
|
|
48
50
|
wrapping the original webdriver but providing a mixin class or alternatively directly setting
|
|
49
51
|
additional methods via 'setattr' in the original webdriver class. This is done and controlled
|
|
50
52
|
via a pretty versatile custom factory function initializing the webdriver.
|
|
51
53
|
|
|
52
|
-
The webelement
|
|
54
|
+
The webelement extensions are done via setattr only. Implementing a mixin class would require
|
|
53
55
|
to modify webdriver methods to return the new class with the mixin. So benefit of the
|
|
54
|
-
settattr approach is that extending the webelement class is
|
|
56
|
+
settattr approach is that extending the webelement class is independent from changes to the
|
|
55
57
|
webdriver class.
|
|
56
58
|
|
|
57
59
|
Note: as I am coming from camel case notation I was struggling a little bit with the Python naming conventions.
|
|
@@ -7,20 +7,20 @@ Package with utilities and functional extensions for Selenium webdriver Python l
|
|
|
7
7
|
The package consist of various helpers and extensions to the Selenium webdriver:
|
|
8
8
|
|
|
9
9
|
- module for session handling especially a custom factory function to initialize a webdriver object
|
|
10
|
-
- module with additional methods for the webdriver class
|
|
10
|
+
- module with additional methods for the webdriver class and a respective mixin class
|
|
11
11
|
- module with convenience functions for locators
|
|
12
12
|
- module with additional methods for the webelement class
|
|
13
13
|
- an extended event-firing webdriver and an extended listener abstract base class
|
|
14
14
|
- a sample event listener implementation based on the extended abstract base class
|
|
15
15
|
|
|
16
|
-
Different from other packages extending the Selenium webdriver class does not work with
|
|
16
|
+
Different from other packages extending the Selenium webdriver class this package does not work with
|
|
17
17
|
wrapping the original webdriver but providing a mixin class or alternatively directly setting
|
|
18
18
|
additional methods via 'setattr' in the original webdriver class. This is done and controlled
|
|
19
19
|
via a pretty versatile custom factory function initializing the webdriver.
|
|
20
20
|
|
|
21
|
-
The webelement
|
|
21
|
+
The webelement extensions are done via setattr only. Implementing a mixin class would require
|
|
22
22
|
to modify webdriver methods to return the new class with the mixin. So benefit of the
|
|
23
|
-
settattr approach is that extending the webelement class is
|
|
23
|
+
settattr approach is that extending the webelement class is independent from changes to the
|
|
24
24
|
webdriver class.
|
|
25
25
|
|
|
26
26
|
Note: as I am coming from camel case notation I was struggling a little bit with the Python naming conventions.
|
|
@@ -15,13 +15,14 @@ build-backend = "hatchling.build"
|
|
|
15
15
|
name = "utils-seleniumxp"
|
|
16
16
|
description = "Package with utilities and functional extensions for Selenium webdriver Python language bindings"
|
|
17
17
|
readme = "README.md"
|
|
18
|
-
requires-python = ">=3.
|
|
18
|
+
requires-python = ">=3.11"
|
|
19
19
|
# only license identifier from https://spdx.org/licenses/ are allowed
|
|
20
20
|
license = { text = "GPL-3.0-only" }
|
|
21
21
|
# keywords for easier look-up on PyPI
|
|
22
22
|
keywords = [
|
|
23
23
|
"Selenium", "webdriver", "Chrome", "FireFox",
|
|
24
|
-
"factory function", "event-firing webdriver", "
|
|
24
|
+
"factory function", "event-firing webdriver", "close popup",
|
|
25
|
+
"parsel", "requests", "stealth-selenium", "waitless"
|
|
25
26
|
]
|
|
26
27
|
authors = [
|
|
27
28
|
{ name = "dornech", email = "dornech@gmx.de" },
|
|
@@ -29,23 +30,25 @@ authors = [
|
|
|
29
30
|
# options under https://pypi.org/classifiers/
|
|
30
31
|
classifiers = [
|
|
31
32
|
"Programming Language :: Python",
|
|
32
|
-
"Programming Language :: Python :: 3.9",
|
|
33
|
-
"Programming Language :: Python :: 3.10",
|
|
34
33
|
"Programming Language :: Python :: 3.11",
|
|
35
34
|
"Programming Language :: Python :: 3.12",
|
|
36
35
|
"Programming Language :: Python :: 3.13",
|
|
36
|
+
"Programming Language :: Python :: 3.14",
|
|
37
37
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
38
38
|
]
|
|
39
39
|
# direct dependencies of this package, installed when users `pip install utils-seleniumxp` later.
|
|
40
40
|
dependencies = [
|
|
41
41
|
"cssify",
|
|
42
|
+
"hatchling",
|
|
42
43
|
"parsel",
|
|
43
44
|
"psutil",
|
|
44
45
|
"requests",
|
|
45
|
-
"selenium",
|
|
46
|
+
"selenium>=4.33.0",
|
|
47
|
+
"selenium-autowait",
|
|
46
48
|
"selenium-requests",
|
|
47
|
-
"stealthenium",
|
|
48
|
-
"
|
|
49
|
+
"stealthenium>=1.1.1",
|
|
50
|
+
"utils-mystuff",
|
|
51
|
+
"waitless",
|
|
49
52
|
]
|
|
50
53
|
dynamic = ["version"]
|
|
51
54
|
|
|
@@ -93,7 +96,7 @@ exclude = [
|
|
|
93
96
|
[tool.commitizen]
|
|
94
97
|
name = "cz_customize"
|
|
95
98
|
version_scheme = "pep440"
|
|
96
|
-
version = "1.
|
|
99
|
+
version = "1.2.0"
|
|
97
100
|
version_files = ["pyproject.toml:version"]
|
|
98
101
|
tag_format = "v$version"
|
|
99
102
|
# retry_after_failure = false
|
|
@@ -120,8 +123,8 @@ bump_map = {"feat" = "MINOR", "fix" = "PATCH", "BREAKING CHANGE" = "MAJOR"}
|
|
|
120
123
|
# with Initial Commit in changelog
|
|
121
124
|
commit_parser ="^(?P<change_type>[Ii]nitial [Cc]ommit|feat|fix|refactor|perf|docs|style|test|chore|build|ci|revert|BREAKING CHANGE)(\\((?P<scope>[^)]+)\\))?(:\\s(?P<message>.*))?"
|
|
122
125
|
changelog_pattern = "^([Ii]nitial [Cc]ommit|feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert|BREAKING CHANGE).*"
|
|
123
|
-
change_type_map = { feat = "Features", fix = "Bug fixes", refactor = "
|
|
124
|
-
change_type_order = ["BREAKING CHANGE", "
|
|
126
|
+
change_type_map = { feat = "Features", fix = "Bug fixes", refactor = "Code refactoring", perf = "Performance improvements", docs = "Documentation", style = "Code style", test = "Testing", chore = "Chores", build = "Build system", ci = "Continuous Integration" }
|
|
127
|
+
change_type_order = ["BREAKING CHANGE", "Features", "Bug fixes", "Code refactoring", "Performance improvements", "Documentation", "Code style", "Testing", "Chore", "Build System", "Continuous Integration", "Initial Commit"]
|
|
125
128
|
|
|
126
129
|
|
|
127
130
|
##################
|
|
@@ -140,7 +143,7 @@ ignore-args = false
|
|
|
140
143
|
ignore-kwargs = false
|
|
141
144
|
ignore-no-params = true
|
|
142
145
|
ignore_typechecker= false
|
|
143
|
-
|
|
146
|
+
disable = ["SIG305", "SIG306"]
|
|
144
147
|
# target = []
|
|
145
148
|
|
|
146
149
|
[tool.ruff]
|
|
@@ -151,8 +154,9 @@ include = [
|
|
|
151
154
|
"src/**/*.py",
|
|
152
155
|
"src/**/*.pyi",
|
|
153
156
|
"tests/**/*.py",
|
|
154
|
-
"tests/**/*.pyi"
|
|
157
|
+
"tests/**/*.pyi",
|
|
155
158
|
]
|
|
159
|
+
output-prefer-rule-codes = true
|
|
156
160
|
|
|
157
161
|
[tool.ruff.lint]
|
|
158
162
|
preview = true # preview features & checks, use with caution
|
|
@@ -247,6 +251,16 @@ warn_unused_ignores = true
|
|
|
247
251
|
warn_return_any = true
|
|
248
252
|
warn_unused_configs = true
|
|
249
253
|
|
|
254
|
+
[tool.deptry]
|
|
255
|
+
known_first_party = ["utils_seleniumxp"]
|
|
256
|
+
exclude = ["docs", "tests"]
|
|
257
|
+
ignore_notebooks = true
|
|
258
|
+
github_output = true
|
|
259
|
+
github_warning_errors = ["DEP003"]
|
|
260
|
+
|
|
261
|
+
[tool.deptry.package_module_name_map]
|
|
262
|
+
selenium-requests = "seleniumrequests"
|
|
263
|
+
|
|
250
264
|
[tool.cruft]
|
|
251
265
|
skip = ["README.md", "CHANGELOG.MD", "src/", "tests/", "docs/", "notebooks/"]
|
|
252
266
|
|
|
@@ -256,6 +270,10 @@ addopts = "-ra -q --doctest-glob='*.md'"
|
|
|
256
270
|
testpaths = [
|
|
257
271
|
"tests",
|
|
258
272
|
]
|
|
273
|
+
markers = [
|
|
274
|
+
"integration: integration test cases",
|
|
275
|
+
"local: test cases not suitable for CI",
|
|
276
|
+
]
|
|
259
277
|
|
|
260
278
|
[tool.coverage.run]
|
|
261
279
|
branch = true
|
|
@@ -294,28 +312,29 @@ exclude_lines = [
|
|
|
294
312
|
|
|
295
313
|
# Hatch default environment
|
|
296
314
|
[tool.hatch.envs.default]
|
|
297
|
-
# python = "3.9"
|
|
298
315
|
post-install-commands = ["pre-commit install", "pre-commit install --hook-type commit-msg"]
|
|
299
316
|
dependencies = [
|
|
300
317
|
"pre-commit",
|
|
318
|
+
"pre_commit",
|
|
301
319
|
"commitizen",
|
|
302
320
|
]
|
|
303
321
|
# installer = "pip"
|
|
304
322
|
|
|
305
|
-
# Hatch default test environment for "hatch test" (also used in
|
|
323
|
+
# Hatch default test environment for "hatch test" (also used in GitHub Action)
|
|
324
|
+
# do not define scripts [tool.hatch.envs.hatch-test.scripts] without taking over hatch standard scripts!!!
|
|
306
325
|
[tool.hatch.envs.hatch-test]
|
|
307
326
|
dependencies = [
|
|
308
327
|
"pip",
|
|
309
328
|
"coverage-enable-subprocess==1.0",
|
|
310
|
-
"coverage[toml]
|
|
311
|
-
"pytest
|
|
312
|
-
"pytest-mock
|
|
313
|
-
"pytest-randomly
|
|
314
|
-
"pytest-rerunfailures
|
|
315
|
-
"pytest-xdist[psutil]
|
|
329
|
+
"coverage[toml]>=7.4",
|
|
330
|
+
"pytest>=8.1",
|
|
331
|
+
"pytest-mock>=3.12",
|
|
332
|
+
"pytest-randomly>=3.15",
|
|
333
|
+
"pytest-rerunfailures>=14.0",
|
|
334
|
+
"pytest-xdist[psutil]>=3.5",
|
|
316
335
|
]
|
|
317
336
|
|
|
318
|
-
#
|
|
337
|
+
# Hatch local testing environment with test-only dependencies (do not mix up with default hatch-test environment "hatch-test" !)
|
|
319
338
|
[tool.hatch.envs.test]
|
|
320
339
|
dependencies = [
|
|
321
340
|
# required test dependencies
|
|
@@ -331,29 +350,31 @@ dependencies = [
|
|
|
331
350
|
[tool.hatch.envs.test.scripts]
|
|
332
351
|
cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=src/utils_seleniumxp --cov=tests {args}"
|
|
333
352
|
no-cov = "cov --no-cov {args}"
|
|
334
|
-
debug =
|
|
353
|
+
debug = "cov --no-cov -s --pdb --pdbcls=IPython.core.debugger:Pdb {args}"
|
|
354
|
+
test_not_local_only = "run pytest -m 'not local'"
|
|
355
|
+
test_local_only = "run pytest -m 'local'"
|
|
335
356
|
|
|
336
|
-
# Hatch testing environment matrix for various Python versions replacing the functionality of tox
|
|
357
|
+
# Hatch local testing environment matrix for various Python versions replacing the functionality of tox
|
|
337
358
|
[[tool.hatch.envs.test.matrix]]
|
|
338
359
|
template = ["test"]
|
|
339
|
-
python = ["3.
|
|
360
|
+
python = ["3.11", "3.12", "3.13", "3.14"]
|
|
340
361
|
|
|
341
362
|
# Hatch default linting environment for "hatch fmt"
|
|
342
363
|
[tool.hatch.envs.hatch-static-analysis]
|
|
343
364
|
dependencies = [
|
|
344
365
|
"pip",
|
|
345
|
-
"mypy==
|
|
346
|
-
"ruff==0.
|
|
366
|
+
"mypy==2.3.0",
|
|
367
|
+
"ruff==0.16.2",
|
|
347
368
|
]
|
|
348
369
|
|
|
349
|
-
# Hatch Linting environment for
|
|
370
|
+
# Hatch Linting environment for GitHub Action
|
|
350
371
|
[tool.hatch.envs.lint]
|
|
351
372
|
template = "lint" # don't inherit from default!
|
|
352
373
|
dependencies = [
|
|
353
374
|
"pip",
|
|
354
|
-
"mypy==
|
|
355
|
-
"ruff==0.
|
|
356
|
-
"docsig==0.
|
|
375
|
+
"mypy==2.3.0",
|
|
376
|
+
"ruff==0.16.2",
|
|
377
|
+
"docsig==0.94.0",
|
|
357
378
|
]
|
|
358
379
|
[tool.hatch.envs.lint.scripts]
|
|
359
380
|
typing = [
|
|
@@ -379,8 +400,10 @@ all = [
|
|
|
379
400
|
# Hatch environment for building documentation
|
|
380
401
|
[tool.hatch.envs.docs]
|
|
381
402
|
dependencies = [
|
|
382
|
-
"
|
|
383
|
-
"
|
|
403
|
+
"pre-commit", # needed otherwise error
|
|
404
|
+
"pre_commit", # needed otherwise error
|
|
405
|
+
"properdocs",
|
|
406
|
+
"mkdocs-materialx[imaging]",
|
|
384
407
|
# Plugins
|
|
385
408
|
"mkdocs-include-markdown-plugin",
|
|
386
409
|
"mkdocs-gen-files",
|
|
@@ -402,10 +425,10 @@ dependencies = [
|
|
|
402
425
|
[tool.hatch.envs.docs.env-vars]
|
|
403
426
|
SOURCE_DATE_EPOCH = "1580601600"
|
|
404
427
|
PYTHONUNBUFFERED = "1"
|
|
405
|
-
MKDOCS_CONFIG = "
|
|
428
|
+
MKDOCS_CONFIG = "properdocs.yml"
|
|
406
429
|
[tool.hatch.envs.docs.scripts]
|
|
407
|
-
build = "
|
|
408
|
-
serve = "
|
|
430
|
+
build = "properdocs build --config-file {env:MKDOCS_CONFIG} --clean --strict {args}"
|
|
431
|
+
serve = "properdocs serve --config-file {env:MKDOCS_CONFIG} --dev-addr localhost:8000 {args}"
|
|
409
432
|
ci-build = "mike deploy --config-file {env:MKDOCS_CONFIG} --update-aliases {args}"
|
|
410
433
|
# --ignore-url=None since the SUMMARY.md file leaves a <toc>None</toc> in sitemap.xml
|
|
411
434
|
validate = "linkchecker --config .linkcheckerrc --ignore-url=/reference --ignore-url=None site"
|
|
@@ -34,7 +34,7 @@ provided for enabling a direct download, disabling browser notifications or opti
|
|
|
34
34
|
|
|
35
35
|
The webelement extension are done via setattr only. Implementing a mixin class would require
|
|
36
36
|
to modify webdriver methods to return the new class with the mixin. So benefit of the
|
|
37
|
-
settattr approach is that extending the webelement class is
|
|
37
|
+
settattr approach is that extending the webelement class is independent from changes to the
|
|
38
38
|
webdriver class.
|
|
39
39
|
|
|
40
40
|
The package also provides an extended event-firing webdriver class.
|
|
@@ -58,18 +58,7 @@ Beside the factory function to create the webdriver there is no change in the AP
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
# version determination
|
|
62
|
-
|
|
63
|
-
# original Hatchlor version
|
|
64
|
-
# from importlib.metadata import PackageNotFoundError, version
|
|
65
|
-
# try:
|
|
66
|
-
# __version__ = version('{{ cookiecutter.project_slug }}')
|
|
67
|
-
# except PackageNotFoundError: # pragma: no cover
|
|
68
|
-
# __version__ = 'unknown'
|
|
69
|
-
# finally:
|
|
70
|
-
# del version, PackageNotFoundError
|
|
71
|
-
|
|
72
|
-
# latest import requirement for hatch-vcs-footgun-example
|
|
61
|
+
# version determination - latest import requirement for hatch-vcs-footgun-example
|
|
73
62
|
from utils_seleniumxp.version import __version__
|
|
74
63
|
|
|
75
64
|
|
|
@@ -81,13 +70,20 @@ from utils_seleniumxp.version import __version__
|
|
|
81
70
|
# package: import <selenium.xxx> as <SeleniumBinding short name>
|
|
82
71
|
# use: from UtilsSeleniumXP import <SeleniumBinding short name>
|
|
83
72
|
|
|
84
|
-
from selenium import webdriver as WebDriver
|
|
73
|
+
# from selenium import webdriver as WebDriver
|
|
74
|
+
from selenium.webdriver.chrome.webdriver import WebDriver as Chrome
|
|
75
|
+
from selenium.webdriver.chrome.options import Options as ChromeOptions
|
|
76
|
+
from selenium.webdriver.firefox.webdriver import WebDriver as Firefox
|
|
77
|
+
from selenium.webdriver.firefox.options import Options as FirefoxOptions
|
|
78
|
+
# from selenium.webdriver.common.webdriver import LocalWebDriver as _LocalWebDriver
|
|
79
|
+
from selenium.webdriver.remote.webdriver import WebDriver as WebDriver
|
|
85
80
|
from selenium.webdriver.remote.webdriver import WebDriver as _RemoteWebDriver
|
|
86
81
|
from selenium.webdriver.remote.webelement import WebElement as _WebElement
|
|
87
82
|
from selenium.webdriver.remote.shadowroot import ShadowRoot as _ShadowRoot
|
|
88
83
|
from selenium.webdriver.remote.switch_to import SwitchTo as _SwitchTo
|
|
89
84
|
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
|
90
85
|
from selenium.webdriver.common.alert import Alert
|
|
86
|
+
from selenium.webdriver.common.action_chains import ActionChains
|
|
91
87
|
from selenium.webdriver.common.by import By
|
|
92
88
|
from selenium.webdriver.common.keys import Keys
|
|
93
89
|
from selenium.webdriver.support.select import Select
|
|
@@ -102,7 +98,7 @@ import selenium.webdriver.support.expected_conditions as ExpectedConditions
|
|
|
102
98
|
|
|
103
99
|
|
|
104
100
|
|
|
105
|
-
# exception class
|
|
101
|
+
# exception class - must be defined here to avoid errors
|
|
106
102
|
class ErrorUtilsSelenium(BaseException):
|
|
107
103
|
pass
|
|
108
104
|
|
|
@@ -112,12 +108,6 @@ class ErrorUtilsSelenium(BaseException):
|
|
|
112
108
|
# switch mixin method of additional functionality - MixIn class vs. direct setattr or callables
|
|
113
109
|
mixinactive = False
|
|
114
110
|
|
|
115
|
-
import sys
|
|
116
|
-
import os.path
|
|
117
|
-
|
|
118
|
-
# switch os.path -> pathlib
|
|
119
|
-
sys.path.insert(1, os.path.dirname(os.path.realpath(__file__)))
|
|
120
|
-
# sys.path.insert(1, str(pathlib.Path(__file__).resolve().parent))
|
|
121
111
|
|
|
122
112
|
# import utils_seleniumxp.sessionhandling
|
|
123
113
|
from utils_seleniumxp.sessionhandling import initWebDriver, init_webdriver
|
|
@@ -128,7 +118,7 @@ from utils_seleniumxp.locatorutils import SeleniumLocator as SeleniumLocator
|
|
|
128
118
|
from utils_seleniumxp.locatorutils import SeleniumLocatorXPATH as SeleniumLocatorXPATH
|
|
129
119
|
from utils_seleniumxp.locatorutils import SeleniumLocatorCSS as SeleniumLocatorCSS
|
|
130
120
|
from utils_seleniumxp.locatorutils import parameterizedSeleniumLocator as parameterizedSeleniumLocator
|
|
131
|
-
from utils_seleniumxp.locatorutils import parselSelectorExtension as
|
|
121
|
+
from utils_seleniumxp.locatorutils import parselSelectorExtension as parselSelectorExtension
|
|
132
122
|
import utils_seleniumxp.webdriver_addon as WebdriverAddOn
|
|
133
123
|
import utils_seleniumxp.webelement_addon as WebelementAddOn
|
|
134
124
|
import utils_seleniumxp.eventfiring_addon as EventFiringAddon
|
|
@@ -15,7 +15,7 @@ module providing event firing and listening - additional functionalities compare
|
|
|
15
15
|
# boolean-type arguments
|
|
16
16
|
# ruff: noqa: FBT001, FBT002
|
|
17
17
|
# others
|
|
18
|
-
# ruff: noqa: B006, E301, PLR0904, PLR0917, SIM102
|
|
18
|
+
# ruff: noqa: B006, E301, PLR0904, PLR0917, RUF105, SIM102
|
|
19
19
|
#
|
|
20
20
|
# disable mypy errors
|
|
21
21
|
# - mypy error "Returning Any from function ..."
|
|
@@ -35,7 +35,7 @@ module providing event firing and listening - additional functionalities compare
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
from typing import Any
|
|
38
|
+
from typing import Any
|
|
39
39
|
|
|
40
40
|
import sys
|
|
41
41
|
|
|
@@ -74,7 +74,7 @@ def _wrap_elements(result: Any, ef_driver: "EventFiringWebDriverExtended") -> An
|
|
|
74
74
|
# for non-elementary webdriver methods (like closepopup) special treatment is implemented
|
|
75
75
|
def _dispatch(
|
|
76
76
|
dispatcher: Any,
|
|
77
|
-
l_call:
|
|
77
|
+
l_call: str | None,
|
|
78
78
|
l_args: tuple[Any, ...],
|
|
79
79
|
d_call: str,
|
|
80
80
|
d_args: tuple[Any, ...],
|
|
@@ -120,7 +120,7 @@ def _getattr(dispatcher, name: str) -> Any:
|
|
|
120
120
|
# note that log entry generation for after_event must be included in returned wrapper to keep
|
|
121
121
|
# execution order; however log entry generation for before_event is included as well as for non-method events
|
|
122
122
|
# the log entries do not make too much sense anyway
|
|
123
|
-
def _getattr_dispatch_generic(dispatcher: Any, l_call:
|
|
123
|
+
def _getattr_dispatch_generic(dispatcher: Any, l_call: str | None, l_args: tuple, d_call: str):
|
|
124
124
|
|
|
125
125
|
def _wrap(*args, **kwargs):
|
|
126
126
|
|
|
@@ -184,7 +184,7 @@ class EventFiringWebDriverExtended(EventFiringWebDriver):
|
|
|
184
184
|
|
|
185
185
|
def _dispatch(
|
|
186
186
|
self,
|
|
187
|
-
l_call:
|
|
187
|
+
l_call: str | None,
|
|
188
188
|
l_args: tuple[Any, ...],
|
|
189
189
|
d_call: str,
|
|
190
190
|
d_args: tuple[Any, ...],
|
|
@@ -245,7 +245,7 @@ class EventFiringSwitchTo:
|
|
|
245
245
|
|
|
246
246
|
def _dispatch(
|
|
247
247
|
self,
|
|
248
|
-
l_call:
|
|
248
|
+
l_call: str | None,
|
|
249
249
|
l_args: tuple[Any, ...],
|
|
250
250
|
d_call: str,
|
|
251
251
|
d_args: tuple[Any, ...]
|
|
@@ -287,7 +287,7 @@ class EventFiringAlert:
|
|
|
287
287
|
|
|
288
288
|
def _dispatch(
|
|
289
289
|
self,
|
|
290
|
-
l_call:
|
|
290
|
+
l_call: str | None,
|
|
291
291
|
l_args: tuple[Any, ...],
|
|
292
292
|
d_call: str,
|
|
293
293
|
d_args: tuple[Any, ...]
|
|
@@ -316,7 +316,7 @@ class EventFiringWebElementExtended(EventFiringWebElement):
|
|
|
316
316
|
|
|
317
317
|
def _dispatch(
|
|
318
318
|
self,
|
|
319
|
-
l_call:
|
|
319
|
+
l_call: str | None,
|
|
320
320
|
l_args: tuple,
|
|
321
321
|
d_call: str,
|
|
322
322
|
d_args: tuple
|
|
@@ -17,7 +17,7 @@ the Selenium project including not covered standard functions
|
|
|
17
17
|
# boolean-type arguments
|
|
18
18
|
# ruff: noqa: FBT001, FBT002
|
|
19
19
|
# others
|
|
20
|
-
# ruff: noqa: B006, PLR0904, PLR5501, PLR6301
|
|
20
|
+
# ruff: noqa: B006, PLR0904, PLR5501, PLR6301, RUF105
|
|
21
21
|
|
|
22
22
|
# fmt: off
|
|
23
23
|
|
|
@@ -34,8 +34,6 @@ the Selenium project including not covered standard functions
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
from typing import Optional
|
|
38
|
-
|
|
39
37
|
import sys
|
|
40
38
|
import logging
|
|
41
39
|
|
|
@@ -53,7 +51,7 @@ class SimpleEventListener(AbstractEventListenerExtended):
|
|
|
53
51
|
|
|
54
52
|
def __init__(
|
|
55
53
|
self,
|
|
56
|
-
loggername:
|
|
54
|
+
loggername: str | None = None,
|
|
57
55
|
events_include_list: list[str] = [],
|
|
58
56
|
events_exclude_list: list[str] = [],
|
|
59
57
|
events_generic_list: list[str] = []
|
|
@@ -15,7 +15,7 @@ module providing Selenium locator tools
|
|
|
15
15
|
# boolean-type arguments
|
|
16
16
|
# ruff: noqa: FBT001, FBT002
|
|
17
17
|
# others
|
|
18
|
-
# ruff: noqa: B006, TID252
|
|
18
|
+
# ruff: noqa: B006, RUF105, TID252
|
|
19
19
|
#
|
|
20
20
|
# disable mypy errors
|
|
21
21
|
# mypy: disable-error-code = "attr-defined, no-any-return"
|
|
@@ -24,7 +24,7 @@ module providing Selenium locator tools
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
from typing import NamedTuple
|
|
27
|
+
from typing import NamedTuple
|
|
28
28
|
|
|
29
29
|
import parsel
|
|
30
30
|
import re
|
|
@@ -40,7 +40,7 @@ class SeleniumLocator(NamedTuple):
|
|
|
40
40
|
"""
|
|
41
41
|
SeleniumLocator - locator as namedtuple (dataclass leads to error as unpack operator will not work)
|
|
42
42
|
"""
|
|
43
|
-
by:
|
|
43
|
+
by: By | str
|
|
44
44
|
value: str
|
|
45
45
|
|
|
46
46
|
|
|
@@ -109,14 +109,14 @@ class parameterizedSeleniumLocator: # docsig: disable
|
|
|
109
109
|
|
|
110
110
|
# check locator list if all of specified type (default By.XPATH or By.CSS_SELECTOR)
|
|
111
111
|
def check_locatorlist(
|
|
112
|
-
loclist: list[SeleniumLocator],
|
|
113
|
-
loctypes:
|
|
112
|
+
loclist: SeleniumLocator | list[SeleniumLocator] | None,
|
|
113
|
+
loctypes: list[str] | set[str] = {By.XPATH, By.CSS_SELECTOR}
|
|
114
114
|
) -> bool:
|
|
115
115
|
"""
|
|
116
116
|
check_locatorlist - check locator list if of type in typelist
|
|
117
117
|
|
|
118
118
|
Args:
|
|
119
|
-
loclist(list[SeleniumLocator]): list of SeleniumLocator objects
|
|
119
|
+
loclist (Union[SeleniumLocator, list[SeleniumLocator], optional): list of SeleniumLocator objects
|
|
120
120
|
loctypes (Union[list[str], set[str], optional): list of locator types. Defaults to [By.XPATH, By.CSS_SELECTOR].
|
|
121
121
|
|
|
122
122
|
Returns:
|
|
@@ -124,27 +124,33 @@ def check_locatorlist(
|
|
|
124
124
|
"""
|
|
125
125
|
|
|
126
126
|
check = True
|
|
127
|
-
|
|
128
|
-
if
|
|
129
|
-
|
|
127
|
+
if loclist is not None:
|
|
128
|
+
if not isinstance(loclist, list):
|
|
129
|
+
loclist = [loclist]
|
|
130
|
+
for locator in loclist:
|
|
131
|
+
if locator is not None:
|
|
132
|
+
check = check and (locator.by in loctypes)
|
|
130
133
|
return check
|
|
131
134
|
|
|
132
135
|
# check single locator if of specified type (default By.XPATH or By.CSS_SELECTOR)
|
|
133
136
|
def check_locator(
|
|
134
|
-
locator: SeleniumLocator,
|
|
135
|
-
loctypes:
|
|
137
|
+
locator: SeleniumLocator | None,
|
|
138
|
+
loctypes: list[str] | set[str] = {By.XPATH, By.CSS_SELECTOR}
|
|
136
139
|
) -> bool:
|
|
137
140
|
"""
|
|
138
141
|
check_locator - check locator if of type in typelist
|
|
139
142
|
|
|
140
143
|
Args:
|
|
141
|
-
locator (SeleniumLocator): SeleniumLocator object
|
|
144
|
+
locator (SeleniumLocator, optional): SeleniumLocator object
|
|
142
145
|
loctypes (Union[list[str], set[str], optional): list of locator types. Defaults to [By.XPATH, By.CSS_SELECTOR].
|
|
143
146
|
|
|
144
147
|
Returns:
|
|
145
148
|
bool: check result
|
|
146
149
|
"""
|
|
147
|
-
|
|
150
|
+
if locator is not None:
|
|
151
|
+
return check_locatorlist([locator], loctypes)
|
|
152
|
+
else:
|
|
153
|
+
return True
|
|
148
154
|
|
|
149
155
|
|
|
150
156
|
# parsel selector wrapping extension to unify calling for the selector types CSS and XPATH
|