setup-selenium-testing 0.1.4__py3-none-any.whl → 0.1.7__py3-none-any.whl
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.
- setup_selenium/setup_selenium.py +26 -5
- {setup_selenium_testing-0.1.4.dist-info → setup_selenium_testing-0.1.7.dist-info}/METADATA +4 -3
- setup_selenium_testing-0.1.7.dist-info/RECORD +7 -0
- {setup_selenium_testing-0.1.4.dist-info → setup_selenium_testing-0.1.7.dist-info}/WHEEL +1 -1
- setup_selenium_testing-0.1.4.dist-info/RECORD +0 -7
- {setup_selenium_testing-0.1.4.dist-info → setup_selenium_testing-0.1.7.dist-info}/LICENSE +0 -0
setup_selenium/setup_selenium.py
CHANGED
@@ -8,7 +8,7 @@ import os as os
|
|
8
8
|
from enum import Enum
|
9
9
|
from typing import TYPE_CHECKING, Optional, Union
|
10
10
|
|
11
|
-
from selenium import webdriver
|
11
|
+
from selenium import __version__, webdriver
|
12
12
|
from selenium.common.exceptions import NoSuchWindowException, WebDriverException
|
13
13
|
from selenium.webdriver.chrome.service import Service as ChromeService
|
14
14
|
from selenium.webdriver.common.selenium_manager import SeleniumManager
|
@@ -28,6 +28,11 @@ if TYPE_CHECKING:
|
|
28
28
|
webdriver.FirefoxOptions, webdriver.ChromeOptions, webdriver.EdgeOptions
|
29
29
|
]
|
30
30
|
|
31
|
+
NEW_SELENIUM = False
|
32
|
+
if Version(__version__) >= Version("4.20.0"):
|
33
|
+
NEW_SELENIUM = True
|
34
|
+
|
35
|
+
|
31
36
|
__all__ = ["SetupSelenium"]
|
32
37
|
|
33
38
|
|
@@ -171,7 +176,11 @@ class SetupSelenium:
|
|
171
176
|
driver_version = driver_version or None
|
172
177
|
|
173
178
|
sm = SeleniumManager()
|
174
|
-
|
179
|
+
|
180
|
+
if NEW_SELENIUM:
|
181
|
+
args = [f"{sm._get_binary()}", "--browser", browser]
|
182
|
+
else:
|
183
|
+
args = [f"{sm.get_binary()}", "--browser", browser] # type: ignore[attr-defined]
|
175
184
|
|
176
185
|
if browser_version:
|
177
186
|
args.append("--browser-version")
|
@@ -187,7 +196,12 @@ class SetupSelenium:
|
|
187
196
|
args.append("--browser-path")
|
188
197
|
args.append(browser_path)
|
189
198
|
|
190
|
-
|
199
|
+
if NEW_SELENIUM:
|
200
|
+
args.append("--output")
|
201
|
+
args.append("json")
|
202
|
+
output = sm._run(args)
|
203
|
+
else:
|
204
|
+
output = sm.run(args) # type: ignore[attr-defined]
|
191
205
|
driver_path = output["driver_path"]
|
192
206
|
browser_path = output["browser_path"]
|
193
207
|
|
@@ -265,6 +279,9 @@ class SetupSelenium:
|
|
265
279
|
options.set_preference("app.update.enabled", False)
|
266
280
|
options.set_preference("network.prefetch-next", False)
|
267
281
|
options.set_preference("network.dns.disablePrefetch", True)
|
282
|
+
options.set_preference(
|
283
|
+
"extensions.formautofill.addresses.capture.enabled", False
|
284
|
+
)
|
268
285
|
return options
|
269
286
|
|
270
287
|
@staticmethod
|
@@ -337,9 +354,11 @@ class SetupSelenium:
|
|
337
354
|
# it's possible we no longer need to do these
|
338
355
|
"--disable-gpu", # https://stackoverflow.com/q/51959986/2532408
|
339
356
|
)
|
357
|
+
exp_prefs = {"autofill.profile_enabled": False}
|
340
358
|
options = webdriver.ChromeOptions()
|
341
359
|
for opt in opts:
|
342
360
|
options.add_argument(opt)
|
361
|
+
options.add_experimental_option("prefs", exp_prefs)
|
343
362
|
return options
|
344
363
|
|
345
364
|
@staticmethod
|
@@ -470,9 +489,11 @@ class SetupSelenium:
|
|
470
489
|
"--no-sandbox",
|
471
490
|
"--disable-dev-shm-usage",
|
472
491
|
)
|
492
|
+
exp_prefs = {"autofill.profile_enabled": False}
|
473
493
|
options = webdriver.EdgeOptions()
|
474
494
|
for opt in opts:
|
475
495
|
options.add_argument(opt)
|
496
|
+
options.add_experimental_option("prefs", exp_prefs)
|
476
497
|
return options
|
477
498
|
|
478
499
|
@staticmethod
|
@@ -573,7 +594,7 @@ class SetupSelenium:
|
|
573
594
|
|
574
595
|
def set_main_window_handle(self, window: str | None = None) -> str:
|
575
596
|
"""
|
576
|
-
|
597
|
+
Maintains the initial window handle as an attribute
|
577
598
|
|
578
599
|
Most users will never utilize this. It's part of a legacy requirement for
|
579
600
|
an old test suite
|
@@ -585,7 +606,7 @@ class SetupSelenium:
|
|
585
606
|
except NoSuchWindowException:
|
586
607
|
try:
|
587
608
|
window = self.driver.window_handles[0]
|
588
|
-
except WebDriverException: # noqa:
|
609
|
+
except WebDriverException: # noqa: TRY203
|
589
610
|
# Have we closed all the windows?
|
590
611
|
raise
|
591
612
|
if window:
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.3
|
2
2
|
Name: setup-selenium-testing
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.7
|
4
4
|
Summary: Setup Selenium for automation testing
|
5
5
|
Home-page: https://github.com/bandophahita/setup_selenium
|
6
6
|
License: MIT
|
@@ -17,13 +17,14 @@ Classifier: Programming Language :: Python :: 3.9
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.10
|
18
18
|
Classifier: Programming Language :: Python :: 3.11
|
19
19
|
Classifier: Programming Language :: Python :: 3.12
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
20
21
|
Classifier: Programming Language :: Python :: 3 :: Only
|
21
22
|
Provides-Extra: dev
|
22
23
|
Provides-Extra: test
|
23
24
|
Requires-Dist: black ; extra == "dev"
|
24
25
|
Requires-Dist: mypy ; extra == "dev"
|
25
26
|
Requires-Dist: pytest ; extra == "dev" or extra == "test"
|
26
|
-
Requires-Dist: ruff (>=0.
|
27
|
+
Requires-Dist: ruff (>=0.8.0) ; extra == "dev"
|
27
28
|
Requires-Dist: selenium (>=4.7.0)
|
28
29
|
Requires-Dist: semantic-version
|
29
30
|
Requires-Dist: tox ; extra == "dev" or extra == "test"
|
@@ -0,0 +1,7 @@
|
|
1
|
+
setup_selenium/__init__.py,sha256=-w9Vvo72ZLaEyIEfc_Nh0bDDJz9W0pOy4rkRXurIJHI,63
|
2
|
+
setup_selenium/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
setup_selenium/setup_selenium.py,sha256=asqQhE6fXcivb2MK3PL90TcQcCBVr_2Mgx-_CULxfUk,21921
|
4
|
+
setup_selenium_testing-0.1.7.dist-info/LICENSE,sha256=KGdE-1D1chm3UNFtfE8x-EpVxhmv2zFx8oltbO8M1qE,1070
|
5
|
+
setup_selenium_testing-0.1.7.dist-info/METADATA,sha256=nKPKfJ3LRA3t7XBoipB0wnjlA7DEhfpzDewY88g9dy4,5408
|
6
|
+
setup_selenium_testing-0.1.7.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
|
7
|
+
setup_selenium_testing-0.1.7.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
setup_selenium/__init__.py,sha256=-w9Vvo72ZLaEyIEfc_Nh0bDDJz9W0pOy4rkRXurIJHI,63
|
2
|
-
setup_selenium/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
-
setup_selenium/setup_selenium.py,sha256=CNliMHOwXIu3eo6eSR-5wcyS6VQvgXcbcUV-_guk6sw,21155
|
4
|
-
setup_selenium_testing-0.1.4.dist-info/LICENSE,sha256=KGdE-1D1chm3UNFtfE8x-EpVxhmv2zFx8oltbO8M1qE,1070
|
5
|
-
setup_selenium_testing-0.1.4.dist-info/METADATA,sha256=zxPcbJtROmmTdJzEjES21Wqjqs-8GoKBTFDUoYsqfv0,5357
|
6
|
-
setup_selenium_testing-0.1.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
7
|
-
setup_selenium_testing-0.1.4.dist-info/RECORD,,
|
File without changes
|