setup-selenium-testing 1.0.1__tar.gz → 1.0.4__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.3
2
2
  Name: setup-selenium-testing
3
- Version: 1.0.1
3
+ Version: 1.0.4
4
4
  Summary: Setup Selenium for automation testing
5
5
  License: MIT
6
6
  Author: Marcel Wilson
@@ -145,6 +145,10 @@ Passing a valid `driver_path` will not trigger any download of the webdriver.
145
145
 
146
146
  CHANGELOG
147
147
  ---------
148
+ ### version 1.0.2
149
+
150
+ - removed python 3.8 support
151
+
148
152
  ### version 1.0.1
149
153
 
150
154
  - removed `--remote-debugging-pipe` from default chrome options (causes older chrome to crash)
@@ -113,6 +113,10 @@ Passing a valid `driver_path` will not trigger any download of the webdriver.
113
113
 
114
114
  CHANGELOG
115
115
  ---------
116
+ ### version 1.0.2
117
+
118
+ - removed python 3.8 support
119
+
116
120
  ### version 1.0.1
117
121
 
118
122
  - removed `--remote-debugging-pipe` from default chrome options (causes older chrome to crash)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "setup-selenium-testing"
3
- version = "1.0.1"
3
+ version = "1.0.4"
4
4
  description = "Setup Selenium for automation testing"
5
5
  authors = ["Marcel Wilson <trenchrats+pypi@gmail.com>"]
6
6
  license = "MIT"
@@ -98,54 +98,21 @@ output-format = "concise"
98
98
 
99
99
  [tool.ruff.lint]
100
100
  select = [
101
- "A", # flake8-builtins
102
- "ANN", # flake8-annotations # coming back to this one later to compare against mypy
103
- "ARG", # flake8-unused-arguments
104
- "B", # flake8-bugbear
105
- "BLE", # flake8-blind-except
106
- "C4", # flake8-comprehensions
107
- "D", # pydocstyle
108
- "E", # pycodestyle error
109
- "EM", # flake8-errmsg
110
- "ERA", # eradicate
111
- "F", # Pyflakes
112
- "FA", # flake8-future-annotations
113
- # "FBT", # flake8-boolean-trap
114
- "FIX", # flake8-fixme
115
- "FLY", # flynt
116
- "I", # isort
117
- "ICN", # flake8-import-conventions
118
- "ISC", # flake8-implicit-str-concat
119
- "PGH", # pygrep-hooks
120
- "PIE", # flake8-pie
121
- "PL", # pylint
122
- "PT", # flake8-pytest-style
123
- "Q", # flake8-quotes
124
- "RET", # flake8-return
125
- "RSE", # flake8-raise
126
- "RUF", # ruff specific
127
- "SIM", # flake8-simplify
128
- "T10", # flake8-debugger
129
- "TCH", # flake8-type-checking
130
- "TD", #TODOs
131
- "TRY", # tryceratops
132
- "UP", # python upgrade
133
- "W", # pycodestyle warning
134
- "YTT", # flake8-2020
135
-
136
- # may eventually use but for now these are not helpful
137
- # "FURB", # refurb # needs --preview flag to run
101
+ "ALL",
138
102
  ]
139
103
  ignore = [
140
- "E501", # line too long -- black will take care of this for us
141
- "SIM115", # use context handler for open -- situationally useful
142
- # "SIM300", # yoda conditions -- meh
143
-
144
- "PERF203", # `try`-`except` within a loop incurs performance overhead
145
- "PERF401", # use list comp
146
-
104
+ "C90", # mccabe
105
+ "FBT", # flake8-boolean-trap
106
+ "G", # flake8-logging-format
107
+ "N", # pep8 naming -- dear lord, leave this off
108
+ "PTH", # flake8-use-pathlib (unclear if we NEED to do this)
109
+ "SLF", # flake8-self (accessing private members)
110
+
147
111
  # NOT OPTIONAL. MUST REMAIN AS SET
148
112
  # these are all completely unnecessary
113
+ "B028", # No explicit `stacklevel` keyword argument found in logging
114
+ "COM812", # missing trailing comma
115
+ "D100", # Missing docstring in public module
149
116
  "D101", # Missing docstring in public class
150
117
  "D104", # Missing docstring in public package
151
118
  "D105", # Missing docstring in magic method
@@ -163,29 +130,40 @@ ignore = [
163
130
  "D406", # Section name should end with a newline
164
131
  "D407", # Missing dashed underline after section
165
132
  "D411", # Missing blank line before section
166
- "D412", # No blank lines allowed between a section header and its content
133
+ "D412", # No blank lines allowed between a section header and its content
167
134
  "D415", # First line should end with punctuation
168
-
135
+ "E501", # line too long -- black will take care of this for us
136
+ "PERF203", # `try`-`except` within a loop incurs performance overhead
169
137
  "PLC0414", # useless-import-alias
170
138
  "PLR0911", # too-many-return-statements
171
139
  "PLR0912", # too-many-branches
172
140
  "PLR0913", # too-many-arguments
173
141
  "PLR0915", # too-many-statements
142
+ "S101", # use of assert
143
+ "TC006", # cast wants str for types (blech!)
174
144
 
175
- # 3.8 & 3.9 compatibility
176
- "UP007", # Use `X | Y` for type annotations
177
- "UP035", # Import from `typing` instead: `TypeAlias`
145
+ # 3.9 compatibility
178
146
  "UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)`
179
147
  ]
180
148
 
181
149
  extend-safe-fixes = [
182
- "EM101", "EM102",
183
- "TCH001", "TCH002", "TCH003", "TCH004",
150
+ "ANN201", "ANN202", "ANN204",
151
+ "B011",
184
152
  "C419",
185
- "D200", "D205",
153
+ "E711", # Comparison to `None` should be `cond is None`
154
+ "EM101", "EM102",
155
+ "PLR1714",
186
156
  "PT003", "PT006", "PT018",
187
157
  "RET504",
158
+ "RSE102",
159
+ "SIM102", "SIM103", "SIM105", "SIM108", "SIM110",
160
+ "TCH001", "TCH002", "TCH003", "TCH004",
161
+ "TID252", #absolute import over relative
162
+ "TRY400",
188
163
  "UP007",
164
+ "UP040",
165
+ "W291",
166
+
189
167
  ]
190
168
 
191
169
  [tool.ruff.lint.flake8-pytest-style]
@@ -204,6 +182,7 @@ split-on-trailing-comma = false
204
182
  "D", # we don't need public-API-polished docstrings in tests.
205
183
  "FBT", # using a boolean as a test object is useful!
206
184
  "PLR", # likewise using specific numbers and strings in tests.
185
+ "INP001", # implicit namespace package
207
186
  ]
208
187
  [tool.ruff.lint.flake8-annotations]
209
188
  # ignore returns types for functions that implicity or explicitly only return None
@@ -5,7 +5,7 @@ from __future__ import annotations
5
5
  import logging
6
6
  import os as os
7
7
  from enum import Enum
8
- from typing import TYPE_CHECKING, Optional, Union
8
+ from typing import TYPE_CHECKING, Union
9
9
 
10
10
  from selenium import __version__, webdriver
11
11
  from selenium.webdriver.chrome.service import Service as ChromeService
@@ -128,6 +128,9 @@ class SetupSelenium:
128
128
 
129
129
  sm = SeleniumManager()
130
130
 
131
+ if browser == Browser.EDGE:
132
+ os.environ["SE_DRIVER_MIRROR_URL"] = "https://msedgedriver.microsoft.com"
133
+
131
134
  if NEW_SELENIUM:
132
135
  args = [f"{sm._get_binary()}", "--browser", browser]
133
136
  else:
@@ -171,7 +174,7 @@ class SetupSelenium:
171
174
  log_dir: str = "./logs",
172
175
  binary: str | None = None,
173
176
  driver_path: str | None = None,
174
- options: Optional[T_DrvOpts] = None,
177
+ options: T_DrvOpts | None = None,
175
178
  ) -> T_WebDriver:
176
179
  """Instantiates the browser driver"""
177
180
  browser = browser.lower()
@@ -325,7 +328,7 @@ class SetupSelenium:
325
328
  "--force-color-profile=srgb",
326
329
  "--metrics-recording-only",
327
330
  "--mute-audio",
328
- # "--remote-debugging-pipe",
331
+ # "--remote-debugging-pipe", # noqa: ERA001
329
332
  # fixes MUI fade issue
330
333
  "--disable-renderer-backgrounding",
331
334
  # fixes actionchains in headless
@@ -432,7 +435,7 @@ class SetupSelenium:
432
435
  return driver
433
436
 
434
437
  @staticmethod
435
- def set_throttle(driver: webdriver.Chrome):
438
+ def set_network_throttle(driver: webdriver.Chrome, network_type: str = "SLOW3G"):
436
439
  """Experimental settings to slow down browser"""
437
440
  # experimental settings to slow down browser
438
441
  # @formatter:off
@@ -448,8 +451,7 @@ class SetupSelenium:
448
451
  }
449
452
  # fmt: on
450
453
  # @formatter:on
451
- net_type = "SLOW3G"
452
- net_lat, net_down, net_up = network_conditions[net_type]
454
+ net_lat, net_down, net_up = network_conditions[network_type]
453
455
  net_down = net_down / 8 * 1024
454
456
  net_up = net_up / 8 * 1024
455
457
  driver.set_network_conditions(
@@ -458,7 +460,11 @@ class SetupSelenium:
458
460
  download_throughput=net_down,
459
461
  upload_throughput=net_up,
460
462
  )
461
- driver.execute_cdp_cmd("Emulation.setCPUThrottlingRate", {"rate": 100})
463
+
464
+ @staticmethod
465
+ def set_cpu_throttle(driver: webdriver.Chrome, rate: int = 10):
466
+ """Experimental settings to slow down browser"""
467
+ driver.execute_cdp_cmd("Emulation.setCPUThrottlingRate", {"rate": rate})
462
468
 
463
469
  @staticmethod
464
470
  def edge_options() -> webdriver.EdgeOptions:
@@ -482,7 +488,7 @@ class SetupSelenium:
482
488
  "--force-color-profile=srgb",
483
489
  "--metrics-recording-only",
484
490
  "--mute-audio",
485
- # "--remote-debugging-pipe",
491
+ # "--remote-debugging-pipe", # noqa: ERA001
486
492
  # fixes MUI fade issue
487
493
  "--disable-renderer-backgrounding",
488
494
  # fixes actionchains in headless