setup-selenium-testing 0.1.4__tar.gz → 0.1.7__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: setup-selenium-testing
3
- Version: 0.1.4
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.2.0) ; extra == "dev"
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"
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "setup-selenium-testing"
3
- version = "0.1.4"
3
+ version = "0.1.7"
4
4
  description = "Setup Selenium for automation testing"
5
5
  authors = ["Marcel Wilson <trenchrats@gmail.com>"]
6
6
  license = "MIT"
@@ -31,7 +31,7 @@ typing-extensions = "*"
31
31
  pytest = {version="*", optional = true}
32
32
  black = {version="*", optional = true}
33
33
  mypy = {version="*", optional = true}
34
- ruff = {version = ">=0.2.0", optional = true}
34
+ ruff = {version = ">=0.8.0", optional = true}
35
35
  tox = {version="*", optional = true}
36
36
 
37
37
  [tool.poetry.extras]
@@ -94,6 +94,7 @@ extend-exclude = [
94
94
  "README.md",
95
95
  ".idea",
96
96
  ]
97
+ output-format = "concise"
97
98
 
98
99
  [tool.ruff.lint]
99
100
  select = [
@@ -136,8 +137,6 @@ select = [
136
137
  # "FURB", # refurb # needs --preview flag to run
137
138
  ]
138
139
  ignore = [
139
- "ANN101", # missing-type-self
140
- "ANN102", # cls
141
140
  "E501", # line too long -- black will take care of this for us
142
141
  "SIM115", # use context handler for open -- situationally useful
143
142
  # "SIM300", # yoda conditions -- meh
@@ -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
- args = [f"{sm.get_binary()}", "--browser", browser]
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
- output = sm.run(args)
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
- maintains the initial window handle as an attribute
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: TRY302
609
+ except WebDriverException: # noqa: TRY203
589
610
  # Have we closed all the windows?
590
611
  raise
591
612
  if window: