seleniumbase 4.15.14__py3-none-any.whl → 4.16.0__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.
Files changed (56) hide show
  1. sbase/__init__.py +1 -0
  2. seleniumbase/__init__.py +1 -0
  3. seleniumbase/__version__.py +1 -1
  4. seleniumbase/behave/behave_sb.py +12 -19
  5. seleniumbase/common/exceptions.py +5 -0
  6. seleniumbase/config/settings.py +7 -0
  7. seleniumbase/console_scripts/ReadMe.md +2 -2
  8. seleniumbase/console_scripts/run.py +5 -4
  9. seleniumbase/console_scripts/sb_behave_gui.py +6 -9
  10. seleniumbase/console_scripts/sb_caseplans.py +2 -5
  11. seleniumbase/console_scripts/sb_commander.py +5 -8
  12. seleniumbase/console_scripts/sb_install.py +43 -54
  13. seleniumbase/console_scripts/sb_mkchart.py +12 -7
  14. seleniumbase/console_scripts/sb_mkfile.py +1 -2
  15. seleniumbase/console_scripts/sb_mkpres.py +6 -1
  16. seleniumbase/console_scripts/sb_print.py +2 -0
  17. seleniumbase/console_scripts/sb_recorder.py +3 -2
  18. seleniumbase/core/browser_launcher.py +13 -27
  19. seleniumbase/core/capabilities_parser.py +2 -3
  20. seleniumbase/core/detect_b_ver.py +3 -4
  21. seleniumbase/core/jqc_helper.py +2 -4
  22. seleniumbase/core/mysql.py +1 -1
  23. seleniumbase/core/proxy_helper.py +65 -0
  24. seleniumbase/core/recorder_helper.py +1 -1
  25. seleniumbase/core/s3_manager.py +29 -23
  26. seleniumbase/core/session_helper.py +2 -6
  27. seleniumbase/core/settings_parser.py +2 -0
  28. seleniumbase/fixtures/base_case.py +31 -13
  29. seleniumbase/fixtures/constants.py +1 -1
  30. seleniumbase/fixtures/css_to_xpath.py +1 -2
  31. seleniumbase/fixtures/errors.py +2 -7
  32. seleniumbase/fixtures/js_utils.py +8 -16
  33. seleniumbase/fixtures/page_actions.py +3 -6
  34. seleniumbase/fixtures/page_utils.py +1 -1
  35. seleniumbase/fixtures/shared_utils.py +26 -79
  36. seleniumbase/fixtures/xpath_to_css.py +1 -3
  37. seleniumbase/plugins/base_plugin.py +1 -1
  38. seleniumbase/plugins/basic_test_info.py +1 -1
  39. seleniumbase/plugins/db_reporting_plugin.py +2 -2
  40. seleniumbase/plugins/driver_manager.py +2 -1
  41. seleniumbase/plugins/page_source.py +2 -4
  42. seleniumbase/plugins/pytest_plugin.py +9 -8
  43. seleniumbase/plugins/s3_logging_plugin.py +20 -9
  44. seleniumbase/plugins/sb_manager.py +2 -2
  45. seleniumbase/plugins/screen_shots.py +2 -2
  46. seleniumbase/plugins/selenium_plugin.py +5 -8
  47. seleniumbase/translate/translator.py +397 -396
  48. seleniumbase/undetected/__init__.py +17 -37
  49. seleniumbase/utilities/selenium_grid/grid_hub.py +2 -1
  50. seleniumbase/utilities/selenium_grid/grid_node.py +2 -1
  51. {seleniumbase-4.15.14.dist-info → seleniumbase-4.16.0.dist-info}/METADATA +8 -8
  52. {seleniumbase-4.15.14.dist-info → seleniumbase-4.16.0.dist-info}/RECORD +56 -56
  53. {seleniumbase-4.15.14.dist-info → seleniumbase-4.16.0.dist-info}/LICENSE +0 -0
  54. {seleniumbase-4.15.14.dist-info → seleniumbase-4.16.0.dist-info}/WHEEL +0 -0
  55. {seleniumbase-4.15.14.dist-info → seleniumbase-4.16.0.dist-info}/entry_points.txt +0 -0
  56. {seleniumbase-4.15.14.dist-info → seleniumbase-4.16.0.dist-info}/top_level.txt +0 -0
sbase/__init__.py CHANGED
@@ -6,6 +6,7 @@ from seleniumbase import DriverContext # noqa
6
6
  from seleniumbase import encryption # noqa
7
7
  from seleniumbase import get_driver # noqa
8
8
  from seleniumbase import js_utils # noqa
9
+ from seleniumbase import shared_utils # noqa
9
10
  from seleniumbase import MasterQA # noqa
10
11
  from seleniumbase import page_actions # noqa
11
12
  from seleniumbase import page_utils # noqa
seleniumbase/__init__.py CHANGED
@@ -14,6 +14,7 @@ from seleniumbase.core.browser_launcher import get_driver # noqa
14
14
  from seleniumbase.fixtures import js_utils # noqa
15
15
  from seleniumbase.fixtures import page_actions # noqa
16
16
  from seleniumbase.fixtures import page_utils # noqa
17
+ from seleniumbase.fixtures import shared_utils # noqa
17
18
  from seleniumbase.fixtures.base_case import BaseCase # noqa
18
19
  from seleniumbase.masterqa.master_qa import MasterQA # noqa
19
20
  from seleniumbase.plugins.sb_manager import SB # noqa
@@ -1,2 +1,2 @@
1
1
  # seleniumbase package
2
- __version__ = "4.15.14"
2
+ __version__ = "4.16.0"
@@ -82,8 +82,8 @@ behave -D agent="User Agent String" -D demo
82
82
  -D incognito (Enable Chrome's Incognito mode.)
83
83
  -D guest (Enable Chrome's Guest mode.)
84
84
  -D devtools (Open Chrome's DevTools when the browser opens.)
85
- -D reuse-session | -D rs (Reuse browser session for all tests.)
86
- -D reuse-class-session | -D rcs (Reuse session for tests in class/feature)
85
+ -D rs | -D reuse-session (Reuse browser session for all tests.)
86
+ -D rcs | -D reuse-class-session (Reuse session for tests in class/feature)
87
87
  -D crumbs (Delete all cookies between tests reusing a session.)
88
88
  -D disable-beforeunload (Disable the "beforeunload" event on Chrome.)
89
89
  -D window-size=WIDTH,HEIGHT (Set the browser's starting window size.)
@@ -95,24 +95,21 @@ behave -D agent="User Agent String" -D demo
95
95
  -D external-pdf (Set Chromium "plugins.always_open_pdf_externally":True.)
96
96
  -D timeout-multiplier=MULTIPLIER (Multiplies the default timeout values.)
97
97
  """
98
-
99
98
  import ast
100
99
  import colorama
101
100
  import os
102
101
  import re
103
102
  import sys
103
+ from seleniumbase import config as sb_config
104
104
  from seleniumbase.config import settings
105
- from seleniumbase.core import log_helper
106
105
  from seleniumbase.core import download_helper
106
+ from seleniumbase.core import log_helper
107
107
  from seleniumbase.core import proxy_helper
108
108
  from seleniumbase.core import session_helper
109
109
  from seleniumbase.fixtures import constants
110
- from seleniumbase import config as sb_config
110
+ from seleniumbase.fixtures import shared_utils
111
111
 
112
112
  sb_config.__base_class = None
113
- is_windows = False
114
- if sys.platform in ["win32", "win64", "x64"]:
115
- is_windows = True
116
113
 
117
114
 
118
115
  def set_base_class(base_class):
@@ -817,10 +814,10 @@ def get_configured_sb(context):
817
814
  '\n (Your browser choice was: "%s")\n' % sb.browser
818
815
  )
819
816
  # The Xvfb virtual display server is for Linux OS Only.
820
- if sb.xvfb and "linux" not in sys.platform:
817
+ if sb.xvfb and not shared_utils.is_linux():
821
818
  sb.xvfb = False
822
819
  if (
823
- "linux" in sys.platform
820
+ shared_utils.is_linux()
824
821
  and not sb.headed
825
822
  and not sb.headless
826
823
  and not sb.headless2
@@ -931,7 +928,6 @@ def get_configured_sb(context):
931
928
  log_helper.log_folder_setup(sb.log_path, sb.archive_logs)
932
929
  download_helper.reset_downloads_folder()
933
930
  proxy_helper.remove_proxy_zip_if_present()
934
-
935
931
  return sb
936
932
 
937
933
 
@@ -1007,7 +1003,7 @@ def dashboard_pre_processing():
1007
1003
  filename = None
1008
1004
  feature_name = None
1009
1005
  scenario_name = None
1010
- if is_windows:
1006
+ if shared_utils.is_windows():
1011
1007
  output = output.decode("latin1")
1012
1008
  else:
1013
1009
  output = output.decode("utf-8")
@@ -1116,7 +1112,7 @@ def behave_dashboard_prepare():
1116
1112
  stars = "*" * star_len
1117
1113
  c1 = ""
1118
1114
  cr = ""
1119
- if "linux" not in sys.platform:
1115
+ if not shared_utils.is_linux():
1120
1116
  colorama.init(autoreset=True)
1121
1117
  c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
1122
1118
  cr = colorama.Style.RESET_ALL
@@ -1124,9 +1120,6 @@ def behave_dashboard_prepare():
1124
1120
 
1125
1121
 
1126
1122
  def _perform_behave_unconfigure_():
1127
- from seleniumbase.core import log_helper
1128
- from seleniumbase.core import proxy_helper
1129
-
1130
1123
  if hasattr(sb_config, "multi_proxy") and not sb_config.multi_proxy:
1131
1124
  proxy_helper.remove_proxy_zip_if_present()
1132
1125
  if hasattr(sb_config, "reuse_session") and sb_config.reuse_session:
@@ -1134,7 +1127,7 @@ def _perform_behave_unconfigure_():
1134
1127
  if sb_config.shared_driver:
1135
1128
  try:
1136
1129
  if (
1137
- not is_windows
1130
+ not shared_utils.is_windows()
1138
1131
  or sb_config.browser == "ie"
1139
1132
  or sb_config.shared_driver.service.process
1140
1133
  ):
@@ -1210,7 +1203,7 @@ def do_final_driver_cleanup_as_needed():
1210
1203
  try:
1211
1204
  if hasattr(sb_config, "last_driver") and sb_config.last_driver:
1212
1205
  if (
1213
- not is_windows
1206
+ not shared_utils.is_windows()
1214
1207
  or sb_config.browser == "ie"
1215
1208
  or sb_config.last_driver.service.process
1216
1209
  ):
@@ -1232,7 +1225,7 @@ def _perform_behave_terminal_summary_():
1232
1225
  equals = "=" * (equals_len + 2)
1233
1226
  c2 = ""
1234
1227
  cr = ""
1235
- if "linux" not in sys.platform:
1228
+ if not shared_utils.is_linux():
1236
1229
  colorama.init(autoreset=True)
1237
1230
  c2 = colorama.Fore.MAGENTA + colorama.Back.LIGHTYELLOW_EX
1238
1231
  cr = colorama.Style.RESET_ALL
@@ -5,6 +5,7 @@
5
5
  NotUsingChromeException => Used by Chrome-only methods if not using Chrome.
6
6
  NotUsingChromiumException => Used by Chromium-only methods if not Chromium.
7
7
  OutOfScopeException => Used by BaseCase methods when setUp() is skipped.
8
+ ProxyConnectionException => Called when the proxy connection failed.
8
9
  TextNotVisibleException => Called when expected text fails to appear.
9
10
  TimeLimitExceededException => Called when exceeding "--time-limit=SECONDS".
10
11
  TimeoutException => Called when some timeout limit has been exceeded.
@@ -36,6 +37,10 @@ class OutOfScopeException(Exception):
36
37
  pass
37
38
 
38
39
 
40
+ class ProxyConnectionException(Exception):
41
+ pass
42
+
43
+
39
44
  class TextNotVisibleException(Exception):
40
45
  pass
41
46
 
@@ -37,6 +37,13 @@ ARCHIVE_EXISTING_LOGS = False
37
37
  # If False, only the downloads from the most recent run will be saved locally.
38
38
  ARCHIVE_EXISTING_DOWNLOADS = False
39
39
 
40
+ # If True, the last page screenshot will include the <body> and background.
41
+ # If False, the last page screenshot will only include the <body> section.
42
+ # Depending on the screen size, including a background could make the <body>
43
+ # appear very small in the screenshot, which may require manually zooming in
44
+ # on the <body> to see page details if you decide to include the background.
45
+ SCREENSHOT_WITH_BACKGROUND = False
46
+
40
47
  # Default names for files saved during test failures.
41
48
  # (These files will get saved to the "latest_logs/" folder.)
42
49
  SCREENSHOT_NAME = "screenshot.png"
@@ -62,8 +62,8 @@ sbase install [DRIVER] [OPTIONS]
62
62
  sbase get chromedriver
63
63
  sbase get geckodriver
64
64
  sbase get edgedriver
65
- sbase get chromedriver 112
66
- sbase get chromedriver 112.0.5615.49
65
+ sbase get chromedriver 114
66
+ sbase get chromedriver 114.0.5735.90
67
67
  sbase get chromedriver latest
68
68
  sbase get chromedriver latest-1 # (Latest minus one)
69
69
  sbase get chromedriver -p
@@ -40,7 +40,6 @@ import colorama
40
40
  import sys
41
41
  import time
42
42
  from seleniumbase.fixtures import constants
43
- from seleniumbase.fixtures import shared_utils
44
43
 
45
44
  colorama.init(autoreset=True)
46
45
 
@@ -144,8 +143,8 @@ def show_install_usage():
144
143
  print(" sbase get chromedriver")
145
144
  print(" sbase get geckodriver")
146
145
  print(" sbase get edgedriver")
147
- print(" sbase get chromedriver 112")
148
- print(" sbase get chromedriver 112.0.5615.49")
146
+ print(" sbase get chromedriver 114")
147
+ print(" sbase get chromedriver 114.0.5735.90")
149
148
  print(" sbase get chromedriver latest")
150
149
  print(" sbase get chromedriver latest-1")
151
150
  print(" sbase get chromedriver -p")
@@ -976,12 +975,14 @@ def main():
976
975
  retry_msg_1 = "* Unable to download driver! Retrying in 3s..."
977
976
  retry_msg_2 = "** Unable to download driver! Retrying in 5s..."
978
977
  if " --proxy=" in " ".join(sys.argv):
978
+ from seleniumbase.core import proxy_helper
979
+
979
980
  for arg in sys.argv:
980
981
  if arg.startswith("--proxy="):
981
982
  proxy_string = arg.split("--proxy=")[1]
982
983
  if "@" in proxy_string:
983
984
  proxy_string = proxy_string.split("@")[1]
984
- shared_utils.validate_proxy_string(proxy_string)
985
+ proxy_helper.validate_proxy_string(proxy_string)
985
986
  break
986
987
  try:
987
988
  sb_install.main()
@@ -23,13 +23,10 @@ if sys.version_info <= (3, 7):
23
23
  "\n* SBase Commander requires Python 3.7 or newer!"
24
24
  "\n** You are currently using Python %s" % current_version
25
25
  )
26
+ from seleniumbase.fixtures import shared_utils
26
27
  import tkinter as tk # noqa: E402
27
28
  from tkinter.scrolledtext import ScrolledText # noqa: E402
28
29
 
29
- is_windows = False
30
- if sys.platform in ["win32", "win64", "x64"]:
31
- is_windows = True
32
-
33
30
 
34
31
  def set_colors(use_colors):
35
32
  c0 = ""
@@ -127,7 +124,7 @@ def do_behave_run(
127
124
 
128
125
  if headless:
129
126
  full_run_command += " -D headless"
130
- elif "linux" in sys.platform:
127
+ elif shared_utils.is_linux():
131
128
  full_run_command += " -D gui"
132
129
 
133
130
  if save_screenshots:
@@ -188,7 +185,7 @@ def create_tkinter_gui(tests, command_string, t_count, f_count, s_tests):
188
185
  "Use Edge Browser (-D edge)",
189
186
  "Use Firefox Browser (-D firefox)",
190
187
  ]
191
- if "darwin" in sys.platform:
188
+ if shared_utils.is_mac():
192
189
  options_list.append("Use Safari Browser (-D safari)")
193
190
  brx = tk.StringVar(root)
194
191
  brx.set(options_list[0])
@@ -267,7 +264,7 @@ def create_tkinter_gui(tests, command_string, t_count, f_count, s_tests):
267
264
  row += " " * 200
268
265
  ara[count] = tk.IntVar()
269
266
  cb = None
270
- if not is_windows:
267
+ if not shared_utils.is_windows():
271
268
  cb = tk.Checkbutton(
272
269
  text_area,
273
270
  text=(row),
@@ -362,7 +359,7 @@ def create_tkinter_gui(tests, command_string, t_count, f_count, s_tests):
362
359
 
363
360
  def main():
364
361
  use_colors = True
365
- if "linux" in sys.platform:
362
+ if shared_utils.is_linux():
366
363
  use_colors = False
367
364
  c0, c1, c2, c3, c4, c5, c6, cr = set_colors(use_colors)
368
365
  command_args = sys.argv[2:]
@@ -414,7 +411,7 @@ def main():
414
411
  f_count = 0
415
412
  s_count = 0
416
413
  t_count = 0
417
- if is_windows:
414
+ if shared_utils.is_windows():
418
415
  output = output.decode("latin1")
419
416
  else:
420
417
  output = output.decode("utf-8")
@@ -27,14 +27,11 @@ if sys.version_info <= (3, 7):
27
27
  "\n* SBase Case Plans Generator requires Python 3.7 or newer!"
28
28
  "\n** You are currently using Python %s" % current_version
29
29
  )
30
+ from seleniumbase.fixtures import shared_utils
30
31
  import tkinter as tk # noqa: E402
31
32
  from tkinter import messagebox # noqa: E402
32
33
  from tkinter.scrolledtext import ScrolledText # noqa: E402
33
34
 
34
- is_windows = False
35
- if sys.platform in ["win32", "win64", "x64"]:
36
- is_windows = True
37
-
38
35
 
39
36
  def set_colors(use_colors):
40
37
  c0 = ""
@@ -404,7 +401,7 @@ def create_tkinter_gui(tests, command_string):
404
401
  row += " " * 200
405
402
  ara[count] = tk.IntVar()
406
403
  cb = None
407
- if not is_windows:
404
+ if not shared_utils.is_windows():
408
405
  cb = tk.Checkbutton(
409
406
  text_area,
410
407
  text=(row),
@@ -28,13 +28,10 @@ if sys.version_info <= (3, 7):
28
28
  "\n* SBase Commander requires Python 3.7 or newer!"
29
29
  "\n** You are currently using Python %s" % current_version
30
30
  )
31
+ from seleniumbase.fixtures import shared_utils
31
32
  import tkinter as tk # noqa: E402
32
33
  from tkinter.scrolledtext import ScrolledText # noqa: E402
33
34
 
34
- is_windows = False
35
- if sys.platform in ["win32", "win64", "x64"]:
36
- is_windows = True
37
-
38
35
 
39
36
  def set_colors(use_colors):
40
37
  c0 = ""
@@ -154,7 +151,7 @@ def do_pytest_run(
154
151
 
155
152
  if headless:
156
153
  full_run_command += " --headless"
157
- elif "linux" in sys.platform:
154
+ elif shared_utils.is_linux():
158
155
  full_run_command += " --gui"
159
156
 
160
157
  if save_screenshots:
@@ -191,7 +188,7 @@ def create_tkinter_gui(tests, command_string, files, solo_tests):
191
188
  "Use Edge Browser (--edge)",
192
189
  "Use Firefox Browser (--firefox)",
193
190
  ]
194
- if "darwin" in sys.platform:
191
+ if shared_utils.is_mac():
195
192
  options_list.append("Use Safari Browser (--safari)")
196
193
  brx = tk.StringVar(root)
197
194
  brx.set(options_list[0])
@@ -302,7 +299,7 @@ def create_tkinter_gui(tests, command_string, files, solo_tests):
302
299
  row += " " * 200
303
300
  ara[count] = tk.IntVar()
304
301
  cb = None
305
- if not is_windows:
302
+ if not shared_utils.is_windows():
306
303
  cb = tk.Checkbutton(
307
304
  text_area,
308
305
  text=(row),
@@ -401,7 +398,7 @@ def create_tkinter_gui(tests, command_string, files, solo_tests):
401
398
 
402
399
  def main():
403
400
  use_colors = True
404
- if "linux" in sys.platform:
401
+ if shared_utils.is_linux():
405
402
  use_colors = False
406
403
  c0, c1, c2, c3, c4, c5, cr = set_colors(use_colors)
407
404
  command_args = sys.argv[2:]
@@ -14,8 +14,8 @@ Examples:
14
14
  sbase get chromedriver
15
15
  sbase get geckodriver
16
16
  sbase get edgedriver
17
- sbase get chromedriver 112
18
- sbase get chromedriver 112.0.5615.49
17
+ sbase get chromedriver 114
18
+ sbase get chromedriver 114.0.5735.90
19
19
  sbase get chromedriver latest
20
20
  sbase get chromedriver latest-1 # (Latest minus one)
21
21
  sbase get chromedriver -p
@@ -32,6 +32,7 @@ import platform
32
32
  import requests
33
33
  import shutil
34
34
  import sys
35
+ import time
35
36
  import tarfile
36
37
  import urllib3
37
38
  import zipfile
@@ -42,26 +43,18 @@ from seleniumbase import drivers # webdriver storage folder for SeleniumBase
42
43
 
43
44
  urllib3.disable_warnings()
44
45
  selenium4_or_newer = False
45
- if sys.version_info[0] == 3 and sys.version_info[1] >= 7:
46
+ if sys.version_info >= (3, 7):
46
47
  selenium4_or_newer = True
47
- IS_ARM_MAC = False
48
- if (
49
- sys.platform.endswith("darwin")
50
- and (
51
- "arm" in platform.processor().lower()
52
- or "arm64" in platform.version().lower()
53
- )
54
- ):
55
- IS_ARM_MAC = True
56
- PLAT = sys.platform
57
- IS_WINDOWS = False
58
- if "win32" in PLAT or "win64" in PLAT or "x64" in PLAT or "x86" in PLAT:
59
- IS_WINDOWS = True
48
+ ARCH = platform.architecture()[0]
49
+ IS_ARM_MAC = shared_utils.is_arm_mac()
50
+ IS_MAC = shared_utils.is_mac()
51
+ IS_LINUX = shared_utils.is_linux()
52
+ IS_WINDOWS = shared_utils.is_windows()
60
53
  DRIVER_DIR = os.path.dirname(os.path.realpath(drivers.__file__))
61
54
  LOCAL_PATH = "/usr/local/bin/" # On Mac and Linux systems
62
55
  DEFAULT_CHROMEDRIVER_VERSION = "72.0.3626.69" # (If can't find LATEST_STABLE)
63
56
  DEFAULT_GECKODRIVER_VERSION = "v0.33.0"
64
- DEFAULT_EDGEDRIVER_VERSION = "112.0.1722.58" # (If can't find LATEST_STABLE)
57
+ DEFAULT_EDGEDRIVER_VERSION = "114.0.1823.82" # (If can't find LATEST_STABLE)
65
58
  DEFAULT_OPERADRIVER_VERSION = "v.96.0.4664.45"
66
59
 
67
60
 
@@ -86,8 +79,8 @@ def invalid_run_command():
86
79
  exp += " sbase get chromedriver\n"
87
80
  exp += " sbase get geckodriver\n"
88
81
  exp += " sbase get edgedriver\n"
89
- exp += " sbase get chromedriver 112\n"
90
- exp += " sbase get chromedriver 112.0.5615.49\n"
82
+ exp += " sbase get chromedriver 114\n"
83
+ exp += " sbase get chromedriver 114.0.5735.90\n"
91
84
  exp += " sbase get chromedriver latest\n"
92
85
  exp += " sbase get chromedriver latest-1\n"
93
86
  exp += " sbase get chromedriver -p\n"
@@ -124,6 +117,8 @@ def requests_get_with_retry(url):
124
117
  protocol = "http"
125
118
  user_and_pass = None
126
119
  if " --proxy=" in " ".join(sys.argv):
120
+ from seleniumbase.core import proxy_helper
121
+
127
122
  for arg in sys.argv:
128
123
  if arg.startswith("--proxy="):
129
124
  proxy_string = arg.split("--proxy=")[1]
@@ -144,7 +139,7 @@ def requests_get_with_retry(url):
144
139
  protocol = "socks4"
145
140
  elif "socks5" in proxy_string:
146
141
  protocol = "socks5"
147
- proxy_string = shared_utils.validate_proxy_string(proxy_string)
142
+ proxy_string = proxy_helper.validate_proxy_string(proxy_string)
148
143
  if user_and_pass:
149
144
  proxy_string = "%s@%s" % (user_and_pass, proxy_string)
150
145
  use_proxy = True
@@ -155,8 +150,6 @@ def requests_get_with_retry(url):
155
150
  try:
156
151
  response = requests.get(url, proxies=proxies)
157
152
  except Exception:
158
- import time
159
-
160
153
  time.sleep(0.75)
161
154
  response = requests.get(url, proxies=proxies)
162
155
  return response
@@ -164,8 +157,6 @@ def requests_get_with_retry(url):
164
157
  try:
165
158
  response = requests.get(url)
166
159
  except Exception:
167
- import time
168
-
169
160
  time.sleep(0.75)
170
161
  response = requests.get(url)
171
162
  return response
@@ -220,7 +211,6 @@ def main(override=None, intel_for_uc=None):
220
211
  headless_ie_exists = False
221
212
  headless_ie_file_name = None
222
213
  downloads_folder = DRIVER_DIR
223
- sys_plat = sys.platform
224
214
  expected_contents = None
225
215
  platform_code = None
226
216
  inner_folder = None
@@ -236,7 +226,7 @@ def main(override=None, intel_for_uc=None):
236
226
  c4 = colorama.Fore.LIGHTRED_EX + colorama.Back.LIGHTWHITE_EX
237
227
  c5 = colorama.Fore.RED + colorama.Back.LIGHTWHITE_EX
238
228
  cr = colorama.Style.RESET_ALL
239
- if "linux" in sys_plat:
229
+ if IS_LINUX:
240
230
  c1 = ""
241
231
  c2 = ""
242
232
  c3 = ""
@@ -292,7 +282,7 @@ def main(override=None, intel_for_uc=None):
292
282
  copy_to_path = True
293
283
  else:
294
284
  invalid_run_command()
295
- if "darwin" in sys_plat:
285
+ if IS_MAC:
296
286
  if IS_ARM_MAC and not intel_for_uc:
297
287
  if use_version == "latest" or use_version == "latest-1":
298
288
  use_version = requests_get(last).text
@@ -306,7 +296,7 @@ def main(override=None, intel_for_uc=None):
306
296
  file_name = "chromedriver_mac_arm64.zip"
307
297
  else:
308
298
  file_name = "chromedriver_mac64.zip"
309
- elif "linux" in sys_plat:
299
+ elif IS_LINUX:
310
300
  file_name = "chromedriver_linux64.zip"
311
301
  elif IS_WINDOWS:
312
302
  file_name = "chromedriver_win32.zip" # Works for win32 / win_x64
@@ -394,11 +384,10 @@ def main(override=None, intel_for_uc=None):
394
384
  copy_to_path = True
395
385
  else:
396
386
  invalid_run_command()
397
- if "darwin" in sys_plat:
387
+ if IS_MAC:
398
388
  file_name = "geckodriver-%s-macos.tar.gz" % use_version
399
- elif "linux" in sys_plat:
400
- arch = platform.architecture()[0]
401
- if "64" in arch:
389
+ elif IS_LINUX:
390
+ if "64" in ARCH:
402
391
  file_name = "geckodriver-%s-linux64.tar.gz" % use_version
403
392
  else:
404
393
  file_name = "geckodriver-%s-linux32.tar.gz" % use_version
@@ -484,19 +473,19 @@ def main(override=None, intel_for_uc=None):
484
473
  else:
485
474
  use_version = DEFAULT_EDGEDRIVER_VERSION
486
475
  suffix = None
487
- if "win64" in sys_plat or "x64" in sys_plat:
476
+ if IS_WINDOWS and "64" in ARCH:
488
477
  file_name = "edgedriver_win64.zip"
489
478
  suffix = "WINDOWS"
490
- elif "win32" in sys_plat or "x86" in sys_plat:
479
+ elif IS_WINDOWS:
491
480
  file_name = "edgedriver_win32.zip"
492
481
  suffix = "WINDOWS"
493
- elif "darwin" in sys_plat:
482
+ elif IS_MAC:
494
483
  if IS_ARM_MAC and int(use_version.split(".")[0]) > 104:
495
484
  file_name = "edgedriver_mac64_m1.zip"
496
485
  else:
497
486
  file_name = "edgedriver_mac64.zip"
498
487
  suffix = "MACOS"
499
- elif "linux" in sys_plat:
488
+ elif IS_LINUX:
500
489
  file_name = "edgedriver_linux64.zip"
501
490
  suffix = "LINUX"
502
491
  else:
@@ -526,10 +515,10 @@ def main(override=None, intel_for_uc=None):
526
515
  major_version = "3.14"
527
516
  full_version = "3.14.0"
528
517
  use_version = full_version
529
- if "win32" in sys_plat:
530
- file_name = "IEDriverServer_Win32_%s.zip" % full_version
531
- elif "win64" in sys_plat or "x64" in sys_plat:
518
+ if IS_WINDOWS and "64" in ARCH:
532
519
  file_name = "IEDriverServer_x64_%s.zip" % full_version
520
+ elif IS_WINDOWS:
521
+ file_name = "IEDriverServer_Win32_%s.zip" % full_version
533
522
  else:
534
523
  raise Exception(
535
524
  "Sorry! IEDriver is only for "
@@ -568,7 +557,7 @@ def main(override=None, intel_for_uc=None):
568
557
  copy_to_path = True
569
558
  else:
570
559
  invalid_run_command()
571
- if "darwin" in sys_plat:
560
+ if IS_MAC:
572
561
  file_name = "operadriver_mac64.zip"
573
562
  platform_code = "mac64"
574
563
  inner_folder = "operadriver_%s/" % platform_code
@@ -577,7 +566,7 @@ def main(override=None, intel_for_uc=None):
577
566
  "operadriver_mac64/operadriver",
578
567
  "operadriver_mac64/sha512_sum",
579
568
  ]
580
- elif "linux" in sys_plat:
569
+ elif IS_LINUX:
581
570
  file_name = "operadriver_linux64.zip"
582
571
  platform_code = "linux64"
583
572
  inner_folder = "operadriver_%s/" % platform_code
@@ -586,16 +575,7 @@ def main(override=None, intel_for_uc=None):
586
575
  "operadriver_linux64/operadriver",
587
576
  "operadriver_linux64/sha512_sum",
588
577
  ]
589
- elif "win32" in sys_plat:
590
- file_name = "operadriver_win32.zip"
591
- platform_code = "win32"
592
- inner_folder = "operadriver_%s/" % platform_code
593
- expected_contents = [
594
- "operadriver_win32/",
595
- "operadriver_win32/operadriver.exe",
596
- "operadriver_win32/sha512_sum",
597
- ]
598
- elif "win64" in sys_plat or "x64" in sys_plat:
578
+ elif IS_WINDOWS and "64" in ARCH:
599
579
  file_name = "operadriver_win64.zip"
600
580
  platform_code = "win64"
601
581
  inner_folder = "operadriver_%s/" % platform_code
@@ -604,6 +584,15 @@ def main(override=None, intel_for_uc=None):
604
584
  "operadriver_win64/operadriver.exe",
605
585
  "operadriver_win64/sha512_sum",
606
586
  ]
587
+ elif IS_WINDOWS:
588
+ file_name = "operadriver_win32.zip"
589
+ platform_code = "win32"
590
+ inner_folder = "operadriver_%s/" % platform_code
591
+ expected_contents = [
592
+ "operadriver_win32/",
593
+ "operadriver_win32/operadriver.exe",
594
+ "operadriver_win32/sha512_sum",
595
+ ]
607
596
  else:
608
597
  raise Exception(
609
598
  "Cannot determine which version of Operadriver to download!"
@@ -743,7 +732,7 @@ def main(override=None, intel_for_uc=None):
743
732
  new_file = os.path.join(downloads_folder, str(f_name))
744
733
  if (
745
734
  intel_for_uc
746
- and "darwin" in sys_plat
735
+ and IS_MAC
747
736
  and new_file.endswith("drivers/chromedriver")
748
737
  ):
749
738
  new_file = new_file.replace(
@@ -806,7 +795,7 @@ def main(override=None, intel_for_uc=None):
806
795
  print("Also copied to: %s%s%s" % (c3, path_file, cr))
807
796
  print("")
808
797
  elif name == "edgedriver" or name == "msedgedriver":
809
- if "darwin" in sys_plat or "linux" in sys_plat:
798
+ if IS_MAC or IS_LINUX:
810
799
  # Mac / Linux
811
800
  expected_contents = [
812
801
  "Driver_Notes/",
@@ -840,7 +829,7 @@ def main(override=None, intel_for_uc=None):
840
829
  # Remove existing version if exists
841
830
  str_name = str(f_name)
842
831
  new_file = os.path.join(downloads_folder, str_name)
843
- if "darwin" in sys_plat or "linux" in sys_plat:
832
+ if IS_MAC or IS_LINUX:
844
833
  # Mac / Linux
845
834
  if str_name == "msedgedriver":
846
835
  driver_file = str_name
@@ -183,8 +183,8 @@ def main():
183
183
  chart_options = '"circular", "barras", "columnas", "líneas", "área"'
184
184
 
185
185
  import_line = "from seleniumbase import BaseCase"
186
+ main_line = "BaseCase.main(__name__, __file__)"
186
187
  parent_class = "BaseCase"
187
- class_line = "class MyTestClass(BaseCase):"
188
188
  if language != "English":
189
189
  from seleniumbase.translate.master_dict import MD_F
190
190
 
@@ -196,6 +196,7 @@ def main():
196
196
  add_slide = '"<p>Chart Demo</p>" + self.extract_chart()'
197
197
  data = []
198
198
  data.append("%s" % import_line)
199
+ data.append("%s" % main_line)
199
200
  data.append("")
200
201
  data.append("")
201
202
  data.append("%s" % class_line)
@@ -204,12 +205,12 @@ def main():
204
205
  data.append("")
205
206
  data.append(" # %s => %s" % (select_option, chart_options))
206
207
  data.append(" self.create_pie_chart(%s)" % chart_settings)
207
- data.append(' self.add_data_point("%s A", 50)' % item)
208
- data.append(' self.add_data_point("%s B", 40)' % item)
209
- data.append(' self.add_data_point("%s C", 35)' % item)
210
- data.append(' self.add_data_point("%s D", 30)' % item)
211
- data.append(' self.add_data_point("%s E", 25)' % item)
212
- data.append(' self.add_data_point("%s F", 20)' % item)
208
+ data.append(' self.add_data_point("%s A", 36)' % item)
209
+ data.append(' self.add_data_point("%s B", 33)' % item)
210
+ data.append(' self.add_data_point("%s C", 27)' % item)
211
+ data.append(' self.add_data_point("%s D", 21)' % item)
212
+ data.append(' self.add_data_point("%s E", 18)' % item)
213
+ data.append(' self.add_data_point("%s F", 15)' % item)
213
214
  data.append(" self.add_slide(%s)" % add_slide)
214
215
  data.append("")
215
216
  data.append(' self.begin_presentation(filename="%s")' % html_name)
@@ -243,6 +244,10 @@ def main():
243
244
  # Example: self.assert_true("Name" in self.get_title())
244
245
  line = new_line
245
246
  continue
247
+ if main_line in line:
248
+ new_main = "%s.main(__name__, __file__)" % parent_class
249
+ new_line = line.replace(main_line, new_main)
250
+ found_swap = True
246
251
  if found_swap:
247
252
  if new_line.endswith(" # noqa"): # Remove flake8 skip
248
253
  new_line = new_line[0 : -len(" # noqa")]