utils-seleniumxp 1.0.0__tar.gz → 1.1.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: utils-seleniumxp
3
- Version: 1.0.0
3
+ Version: 1.1.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
@@ -12,20 +12,20 @@ License-File: AUTHORS.md
12
12
  License-File: LICENSE.txt
13
13
  Keywords: Chrome,FireFox,Selenium,close popup,event-firing webdriver,factory function,parsel,webdriver
14
14
  Classifier: Programming Language :: Python
15
- Classifier: Programming Language :: Python :: 3.9
16
15
  Classifier: Programming Language :: Python :: 3.10
17
16
  Classifier: Programming Language :: Python :: 3.11
18
17
  Classifier: Programming Language :: Python :: 3.12
19
18
  Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
20
  Classifier: Programming Language :: Python :: Implementation :: CPython
21
- Requires-Python: >=3.9
21
+ Requires-Python: >=3.10
22
22
  Requires-Dist: cssify
23
23
  Requires-Dist: parsel
24
24
  Requires-Dist: psutil
25
25
  Requires-Dist: requests
26
- Requires-Dist: selenium
27
26
  Requires-Dist: selenium-requests
28
- Requires-Dist: stealthenium
27
+ Requires-Dist: selenium~=4.33.0
28
+ Requires-Dist: stealthenium>=1.1.1
29
29
  Requires-Dist: utils-mystuff
30
30
  Description-Content-Type: text/markdown
31
31
 
@@ -38,20 +38,20 @@ Package with utilities and functional extensions for Selenium webdriver Python l
38
38
  The package consist of various helpers and extensions to the Selenium webdriver:
39
39
 
40
40
  - module for session handling especially a custom factory function to initialize a webdriver object
41
- - module with additional methods for the webdriver class
41
+ - module with additional methods for the webdriver class and a respective mixin class
42
42
  - module with convenience functions for locators
43
43
  - module with additional methods for the webelement class
44
44
  - an extended event-firing webdriver and an extended listener abstract base class
45
45
  - a sample event listener implementation based on the extended abstract base class
46
46
 
47
- Different from other packages extending the Selenium webdriver class does not work with
47
+ Different from other packages extending the Selenium webdriver class this package does not work with
48
48
  wrapping the original webdriver but providing a mixin class or alternatively directly setting
49
49
  additional methods via 'setattr' in the original webdriver class. This is done and controlled
50
50
  via a pretty versatile custom factory function initializing the webdriver.
51
51
 
52
- The webelement extension are done via setattr only. Implementing a mixin class would require
52
+ The webelement extensions are done via setattr only. Implementing a mixin class would require
53
53
  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 independend from changes to the
54
+ settattr approach is that extending the webelement class is independent from changes to the
55
55
  webdriver class.
56
56
 
57
57
  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 extension are done via setattr only. Implementing a mixin class would require
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 independend from changes to the
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,7 +15,7 @@ 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.9"
18
+ requires-python = ">=3.10"
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
@@ -29,11 +29,11 @@ authors = [
29
29
  # options under https://pypi.org/classifiers/
30
30
  classifiers = [
31
31
  "Programming Language :: Python",
32
- "Programming Language :: Python :: 3.9",
33
32
  "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.
@@ -42,9 +42,9 @@ dependencies = [
42
42
  "parsel",
43
43
  "psutil",
44
44
  "requests",
45
- "selenium",
45
+ "selenium~=4.33.0",
46
46
  "selenium-requests",
47
- "stealthenium",
47
+ "stealthenium>=1.1.1",
48
48
  "utils_mystuff"
49
49
  ]
50
50
  dynamic = ["version"]
@@ -93,7 +93,7 @@ exclude = [
93
93
  [tool.commitizen]
94
94
  name = "cz_customize"
95
95
  version_scheme = "pep440"
96
- version = "1.0.0"
96
+ version = "1.1.0"
97
97
  version_files = ["pyproject.toml:version"]
98
98
  tag_format = "v$version"
99
99
  # retry_after_failure = false
@@ -294,10 +294,10 @@ exclude_lines = [
294
294
 
295
295
  # Hatch default environment
296
296
  [tool.hatch.envs.default]
297
- # python = "3.9"
298
297
  post-install-commands = ["pre-commit install", "pre-commit install --hook-type commit-msg"]
299
298
  dependencies = [
300
299
  "pre-commit",
300
+ "pre_commit",
301
301
  "commitizen",
302
302
  ]
303
303
  # installer = "pip"
@@ -331,12 +331,12 @@ dependencies = [
331
331
  [tool.hatch.envs.test.scripts]
332
332
  cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=src/utils_seleniumxp --cov=tests {args}"
333
333
  no-cov = "cov --no-cov {args}"
334
- debug = "cov --no-cov -s --pdb --pdbcls=IPython.core.debugger:Pdb {args}"
334
+ debug = "cov --no-cov -s --pdb --pdbcls=IPython.core.debugger:Pdb {args}"
335
335
 
336
336
  # Hatch testing environment matrix for various Python versions replacing the functionality of tox
337
337
  [[tool.hatch.envs.test.matrix]]
338
338
  template = ["test"]
339
- python = ["3.9", "3.10", "3.11", "3.12", "3.13"]
339
+ python = ["3.10", "3.11", "3.12", "3.13", "3.14"]
340
340
 
341
341
  # Hatch default linting environment for "hatch fmt"
342
342
  [tool.hatch.envs.hatch-static-analysis]
@@ -379,8 +379,10 @@ all = [
379
379
  # Hatch environment for building documentation
380
380
  [tool.hatch.envs.docs]
381
381
  dependencies = [
382
- "mkdocs~=1.6",
383
- "mkdocs-material[imaging]~=9.4",
382
+ "pre-commit", # needed otherwise error
383
+ "pre_commit", # needed otherwise error
384
+ "properdocs",
385
+ "mkdocs-materialx[imaging]",
384
386
  # Plugins
385
387
  "mkdocs-include-markdown-plugin",
386
388
  "mkdocs-gen-files",
@@ -402,10 +404,10 @@ dependencies = [
402
404
  [tool.hatch.envs.docs.env-vars]
403
405
  SOURCE_DATE_EPOCH = "1580601600"
404
406
  PYTHONUNBUFFERED = "1"
405
- MKDOCS_CONFIG = "mkdocs.yml"
407
+ MKDOCS_CONFIG = "properdocs.yml"
406
408
  [tool.hatch.envs.docs.scripts]
407
- build = "mkdocs build --config-file {env:MKDOCS_CONFIG} --clean --strict {args}"
408
- serve = "mkdocs serve --config-file {env:MKDOCS_CONFIG} --dev-addr localhost:8000 {args}"
409
+ build = "properdocs build --config-file {env:MKDOCS_CONFIG} --clean --strict {args}"
410
+ serve = "properdocs serve --config-file {env:MKDOCS_CONFIG} --dev-addr localhost:8000 {args}"
409
411
  ci-build = "mike deploy --config-file {env:MKDOCS_CONFIG} --update-aliases {args}"
410
412
  # --ignore-url=None since the SUMMARY.md file leaves a <toc>None</toc> in sitemap.xml
411
413
  validate = "linkchecker --config .linkcheckerrc --ignore-url=/reference --ignore-url=None site"
@@ -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
 
@@ -102,7 +91,7 @@ import selenium.webdriver.support.expected_conditions as ExpectedConditions
102
91
 
103
92
 
104
93
 
105
- # exception class
94
+ # exception class - must be defined here to avoid errors
106
95
  class ErrorUtilsSelenium(BaseException):
107
96
  pass
108
97
 
@@ -112,12 +101,6 @@ class ErrorUtilsSelenium(BaseException):
112
101
  # switch mixin method of additional functionality - MixIn class vs. direct setattr or callables
113
102
  mixinactive = False
114
103
 
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
104
 
122
105
  # import utils_seleniumxp.sessionhandling
123
106
  from utils_seleniumxp.sessionhandling import initWebDriver, init_webdriver
@@ -128,7 +111,7 @@ from utils_seleniumxp.locatorutils import SeleniumLocator as SeleniumLocator
128
111
  from utils_seleniumxp.locatorutils import SeleniumLocatorXPATH as SeleniumLocatorXPATH
129
112
  from utils_seleniumxp.locatorutils import SeleniumLocatorCSS as SeleniumLocatorCSS
130
113
  from utils_seleniumxp.locatorutils import parameterizedSeleniumLocator as parameterizedSeleniumLocator
131
- from utils_seleniumxp.locatorutils import parselSelectorExtension as parselSelectorExtension
114
+ from utils_seleniumxp.locatorutils import parselSelectorExtension as parselSelectorExtension
132
115
  import utils_seleniumxp.webdriver_addon as WebdriverAddOn
133
116
  import utils_seleniumxp.webelement_addon as WebelementAddOn
134
117
  import utils_seleniumxp.eventfiring_addon as EventFiringAddon
@@ -35,7 +35,7 @@ module providing event firing and listening - additional functionalities compare
35
35
 
36
36
 
37
37
 
38
- from typing import Any, Optional
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: Optional[str],
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: Optional[str], l_args: tuple, d_call: str):
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: Optional[str],
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: Optional[str],
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: Optional[str],
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: Optional[str],
319
+ l_call: str | None,
320
320
  l_args: tuple,
321
321
  d_call: str,
322
322
  d_args: tuple
@@ -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: Optional[str] = None,
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] = []
@@ -24,7 +24,7 @@ module providing Selenium locator tools
24
24
 
25
25
 
26
26
 
27
- from typing import NamedTuple, Union
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: Union[By, str]
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: Union[list[str], set[str]] = {By.XPATH, By.CSS_SELECTOR}
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
- for locator in loclist:
128
- if locator is not None:
129
- check = check and (locator.by in loctypes)
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: Union[list[str], set[str]] = {By.XPATH, By.CSS_SELECTOR}
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
- return check_locatorlist([locator], loctypes)
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