seleniumbase 4.24.10__py3-none-any.whl → 4.33.15__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 (79) hide show
  1. sbase/__init__.py +1 -0
  2. sbase/steps.py +7 -0
  3. seleniumbase/__init__.py +16 -7
  4. seleniumbase/__version__.py +1 -1
  5. seleniumbase/behave/behave_sb.py +97 -32
  6. seleniumbase/common/decorators.py +16 -7
  7. seleniumbase/config/proxy_list.py +3 -3
  8. seleniumbase/config/settings.py +4 -0
  9. seleniumbase/console_scripts/logo_helper.py +47 -8
  10. seleniumbase/console_scripts/run.py +345 -335
  11. seleniumbase/console_scripts/sb_behave_gui.py +5 -12
  12. seleniumbase/console_scripts/sb_caseplans.py +6 -13
  13. seleniumbase/console_scripts/sb_commander.py +5 -12
  14. seleniumbase/console_scripts/sb_install.py +62 -54
  15. seleniumbase/console_scripts/sb_mkchart.py +13 -20
  16. seleniumbase/console_scripts/sb_mkdir.py +11 -17
  17. seleniumbase/console_scripts/sb_mkfile.py +69 -43
  18. seleniumbase/console_scripts/sb_mkpres.py +13 -20
  19. seleniumbase/console_scripts/sb_mkrec.py +88 -21
  20. seleniumbase/console_scripts/sb_objectify.py +30 -30
  21. seleniumbase/console_scripts/sb_print.py +5 -12
  22. seleniumbase/console_scripts/sb_recorder.py +16 -11
  23. seleniumbase/core/browser_launcher.py +1658 -221
  24. seleniumbase/core/detect_b_ver.py +7 -8
  25. seleniumbase/core/log_helper.py +42 -27
  26. seleniumbase/core/mysql.py +1 -4
  27. seleniumbase/core/proxy_helper.py +35 -30
  28. seleniumbase/core/recorder_helper.py +24 -5
  29. seleniumbase/core/sb_cdp.py +1951 -0
  30. seleniumbase/core/sb_driver.py +162 -8
  31. seleniumbase/core/settings_parser.py +6 -0
  32. seleniumbase/core/style_sheet.py +10 -0
  33. seleniumbase/extensions/recorder.zip +0 -0
  34. seleniumbase/fixtures/base_case.py +1234 -632
  35. seleniumbase/fixtures/constants.py +10 -1
  36. seleniumbase/fixtures/js_utils.py +171 -144
  37. seleniumbase/fixtures/page_actions.py +177 -13
  38. seleniumbase/fixtures/page_utils.py +25 -53
  39. seleniumbase/fixtures/shared_utils.py +97 -11
  40. seleniumbase/js_code/active_css_js.py +1 -1
  41. seleniumbase/js_code/recorder_js.py +1 -1
  42. seleniumbase/plugins/base_plugin.py +2 -3
  43. seleniumbase/plugins/driver_manager.py +340 -65
  44. seleniumbase/plugins/pytest_plugin.py +276 -47
  45. seleniumbase/plugins/sb_manager.py +412 -99
  46. seleniumbase/plugins/selenium_plugin.py +122 -17
  47. seleniumbase/translate/translator.py +0 -7
  48. seleniumbase/undetected/__init__.py +59 -52
  49. seleniumbase/undetected/cdp.py +0 -1
  50. seleniumbase/undetected/cdp_driver/__init__.py +1 -0
  51. seleniumbase/undetected/cdp_driver/_contradict.py +110 -0
  52. seleniumbase/undetected/cdp_driver/browser.py +829 -0
  53. seleniumbase/undetected/cdp_driver/cdp_util.py +458 -0
  54. seleniumbase/undetected/cdp_driver/config.py +334 -0
  55. seleniumbase/undetected/cdp_driver/connection.py +639 -0
  56. seleniumbase/undetected/cdp_driver/element.py +1168 -0
  57. seleniumbase/undetected/cdp_driver/tab.py +1323 -0
  58. seleniumbase/undetected/dprocess.py +4 -7
  59. seleniumbase/undetected/options.py +6 -8
  60. seleniumbase/undetected/patcher.py +11 -13
  61. seleniumbase/undetected/reactor.py +0 -1
  62. seleniumbase/undetected/webelement.py +16 -3
  63. {seleniumbase-4.24.10.dist-info → seleniumbase-4.33.15.dist-info}/LICENSE +1 -1
  64. {seleniumbase-4.24.10.dist-info → seleniumbase-4.33.15.dist-info}/METADATA +299 -252
  65. {seleniumbase-4.24.10.dist-info → seleniumbase-4.33.15.dist-info}/RECORD +68 -70
  66. {seleniumbase-4.24.10.dist-info → seleniumbase-4.33.15.dist-info}/WHEEL +1 -1
  67. sbase/ReadMe.txt +0 -2
  68. seleniumbase/ReadMe.md +0 -25
  69. seleniumbase/common/ReadMe.md +0 -71
  70. seleniumbase/console_scripts/ReadMe.md +0 -731
  71. seleniumbase/drivers/ReadMe.md +0 -27
  72. seleniumbase/extensions/ReadMe.md +0 -12
  73. seleniumbase/masterqa/ReadMe.md +0 -61
  74. seleniumbase/resources/ReadMe.md +0 -31
  75. seleniumbase/resources/favicon.ico +0 -0
  76. seleniumbase/utilities/selenium_grid/ReadMe.md +0 -84
  77. seleniumbase/utilities/selenium_ide/ReadMe.md +0 -111
  78. {seleniumbase-4.24.10.dist-info → seleniumbase-4.33.15.dist-info}/entry_points.txt +0 -0
  79. {seleniumbase-4.24.10.dist-info → seleniumbase-4.33.15.dist-info}/top_level.txt +0 -0
@@ -39,21 +39,21 @@ import sys
39
39
  def invalid_run_command(msg=None):
40
40
  exp = " ** mkrec / record / codegen **\n\n"
41
41
  exp += " Usage:\n"
42
- exp += " seleniumbase mkrec [FILE.py]\n"
43
- exp += " OR: sbase mkrec [FILE.py]\n"
42
+ exp += " seleniumbase mkrec [FILE.py]\n"
43
+ exp += " OR: sbase mkrec [FILE.py]\n"
44
44
  exp += " Examples:\n"
45
- exp += " sbase mkrec new_test.py\n"
46
- exp += " sbase mkrec new_test.py --url=wikipedia.org\n"
45
+ exp += " sbase mkrec new_test.py\n"
46
+ exp += " sbase mkrec new_test.py --url=wikipedia.org\n"
47
47
  exp += " Options:\n"
48
- exp += " --url=URL (Sets the initial start page URL.)\n"
49
- exp += " --edge (Use Edge browser instead of Chrome.)\n"
50
- exp += " --gui / --headed (Use headed mode on Linux.)\n"
51
- exp += " --uc / --undetected (Use undetectable mode.)\n"
52
- exp += " --overwrite (Overwrite file when it exists.)\n"
53
- exp += " --behave (Also output Behave/Gherkin files.)\n"
48
+ exp += " --url=URL (Sets the initial start page URL.)\n"
49
+ exp += " --edge (Use Edge browser instead of Chrome.)\n"
50
+ exp += " --gui / --headed (Use headed mode on Linux.)\n"
51
+ exp += " --uc / --undetected (Use undetectable mode.)\n"
52
+ exp += " --overwrite (Overwrite file when it exists.)\n"
53
+ exp += " --behave (Also output Behave/Gherkin files.)\n"
54
54
  exp += " Output:\n"
55
- exp += " Creates a new SeleniumBase test using the Recorder.\n"
56
- exp += " If the filename already exists, an error is raised.\n"
55
+ exp += " Creates a new SeleniumBase test using the Recorder.\n"
56
+ exp += " If the filename already exists, an error is raised.\n"
57
57
  if not msg:
58
58
  raise Exception("INVALID RUN COMMAND!\n\n%s" % exp)
59
59
  elif msg == "help":
@@ -71,13 +71,6 @@ def set_colors(use_colors):
71
71
  c7 = ""
72
72
  cr = ""
73
73
  if use_colors:
74
- if (
75
- "win32" in sys.platform
76
- and hasattr(colorama, "just_fix_windows_console")
77
- ):
78
- colorama.just_fix_windows_console()
79
- else:
80
- colorama.init(autoreset=True)
81
74
  c0 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
82
75
  c1 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
83
76
  c2 = colorama.Fore.LIGHTRED_EX + colorama.Back.LIGHTYELLOW_EX
@@ -93,6 +86,7 @@ def main():
93
86
  invalid_cmd = None
94
87
  use_edge = False
95
88
  use_uc = False
89
+ esc_end = False
96
90
  start_page = None
97
91
  next_is_url = False
98
92
  use_colors = True
@@ -145,10 +139,14 @@ def main():
145
139
  help_me = True
146
140
  elif option.lower() == "--edge":
147
141
  use_edge = True
142
+ elif option.lower() == "--ee":
143
+ esc_end = True
148
144
  elif option.lower() in ("--gui", "--headed"):
149
145
  if "linux" in sys.platform:
150
146
  force_gui = True
151
- elif option.lower() in ("--uc", "--undetected", "--undetectable"):
147
+ elif option.lower() in (
148
+ "--uc", "--cdp", "--undetected", "--undetectable"
149
+ ):
152
150
  use_uc = True
153
151
  elif option.lower() in ("--rec-behave", "--behave", "--gherkin"):
154
152
  rec_behave = True
@@ -178,11 +176,69 @@ def main():
178
176
  data.append("")
179
177
  data.append("class RecorderTest(BaseCase):")
180
178
  data.append(" def test_recording(self):")
179
+ if use_uc:
180
+ data.append(" if self.undetectable:")
181
+ if (
182
+ start_page
183
+ and (
184
+ start_page.startswith("http:")
185
+ or start_page.startswith("https:")
186
+ or start_page.startswith("file:")
187
+ )
188
+ ):
189
+ used_sp = start_page
190
+ if '"' not in start_page:
191
+ used_sp = '"%s"' % start_page
192
+ elif "'" not in start_page:
193
+ used_sp = "'%s'" % start_page
194
+ data.append(
195
+ " self.uc_open_with_disconnect(\n"
196
+ " %s\n"
197
+ " )" % used_sp
198
+ )
199
+ else:
200
+ data.append(" self.disconnect()")
181
201
  data.append(" if self.recorder_ext:")
182
202
  data.append(" # When done recording actions,")
183
203
  data.append(' # type "c", and press [Enter].')
184
204
  data.append(" import pdb; pdb.set_trace()")
185
205
  data.append("")
206
+
207
+ if esc_end:
208
+ msg = ">>> Use [SHIFT + ESC] in the browser to end recording!"
209
+ d2 = []
210
+ d2.append("from seleniumbase import BaseCase")
211
+ d2.append("")
212
+ d2.append("")
213
+ d2.append("class RecorderTest(BaseCase):")
214
+ d2.append(" def test_recording(self):")
215
+ d2.append(" if self.recorder_ext:")
216
+ d2.append(" print(")
217
+ d2.append(' "\\n\\n%s\\n"' % msg)
218
+ d2.append(" )")
219
+ d2.append(' script = self._get_rec_shift_esc_script()')
220
+ d2.append(' esc = "return document.sb_esc_end;"')
221
+ d2.append(" start_time = self.time()")
222
+ d2.append(" last_handles_num = self._get_num_handles()")
223
+ d2.append(" for i in range(1200):")
224
+ d2.append(" try:")
225
+ d2.append(" self.execute_script(script)")
226
+ d2.append(" handles_num = self._get_num_handles()")
227
+ d2.append(" if handles_num < 1:")
228
+ d2.append(" return")
229
+ d2.append(" elif handles_num != last_handles_num:")
230
+ d2.append(" self.switch_to_window(-1)")
231
+ d2.append(" last_handles_num = handles_num")
232
+ d2.append(' if self.execute_script(esc) == "yes":')
233
+ d2.append(" return")
234
+ d2.append(" elif self.time() - start_time > 600:")
235
+ d2.append(" return")
236
+ d2.append(" self.sleep(0.5)")
237
+ d2.append(" except Exception:")
238
+ d2.append(" return")
239
+ d2.append("")
240
+ data = d2
241
+
186
242
  file = codecs.open(file_path, "w+", "utf-8")
187
243
  file.writelines("\r\n".join(data))
188
244
  file.close()
@@ -192,7 +248,18 @@ def main():
192
248
  )
193
249
  print(success)
194
250
  run_cmd = None
195
- if not start_page:
251
+ if (
252
+ not start_page
253
+ or (
254
+ use_uc
255
+ and (
256
+ start_page.startswith("http:")
257
+ or start_page.startswith("https:")
258
+ or start_page.startswith("file:")
259
+ )
260
+ and not esc_end
261
+ )
262
+ ):
196
263
  run_cmd = "%s -m pytest %s --rec -q -s" % (sys_executable, file_name)
197
264
  else:
198
265
  run_cmd = "%s -m pytest %s --rec -q -s --url=%s" % (
@@ -2,11 +2,11 @@
2
2
  Converts a SeleniumBase Python file into one that uses the Page Object Pattern.
3
3
 
4
4
  Usage:
5
- seleniumbase objectify [SELENIUMBASE_PYTHON_FILE].py
5
+ seleniumbase objectify [SELENIUMBASE_PYTHON_FILE].py
6
6
  Output:
7
- A modified version of the file where the selectors
8
- have been replaced with variable names defined in
9
- "page_objects.py", supporting the Page Object Pattern.
7
+ A modified version of the file where the selectors
8
+ have been replaced with variable names defined in
9
+ "page_objects.py", supporting the Page Object Pattern.
10
10
  """
11
11
  import codecs
12
12
  import os
@@ -35,57 +35,57 @@ def invalid_run_command(shell_command):
35
35
  def invalid_objectify_run_command():
36
36
  exp = " ** objectify **\n\n"
37
37
  exp += " Usage:\n"
38
- exp += " seleniumbase objectify [SELENIUMBASE_PYTHON_FILE]\n"
38
+ exp += " seleniumbase objectify [SELENIUMBASE_PYTHON_FILE]\n"
39
39
  exp += " Options:\n"
40
- exp += " -c, --comments (Add object selectors to the comments.)\n"
41
- exp += " (Default: No added comments.)\n"
40
+ exp += " -c, --comments (Add object selectors to the comments.)\n"
41
+ exp += " (Default: No added comments.)\n"
42
42
  exp += " Output:\n"
43
- exp += " Converts a SeleniumBase Python file into one that uses\n"
44
- exp += " the Page Object Pattern by converting page selectors\n"
45
- exp += ' into objects stored in a "page_objects.py" file that is\n'
46
- exp += " autogenerated and stored in the same folder as tests.\n"
47
- exp += ' (seleniumbase "objectify" has the same outcome as\n'
48
- exp += ' combining "extract-objects" with "inject-objects")\n'
43
+ exp += " Converts a SeleniumBase Python file into one that uses\n"
44
+ exp += " the Page Object Pattern by converting page selectors\n"
45
+ exp += ' into objects stored in a "page_objects.py" file that is\n'
46
+ exp += " autogenerated and stored in the same folder as tests.\n"
47
+ exp += ' (seleniumbase "objectify" has the same outcome as\n'
48
+ exp += ' combining "extract-objects" with "inject-objects")\n'
49
49
  raise Exception("INVALID RUN COMMAND!\n\n%s" % exp)
50
50
 
51
51
 
52
52
  def invalid_inject_objects_run_command():
53
53
  exp = " ** inject-objects **\n\n"
54
54
  exp += " Usage:\n"
55
- exp += " seleniumbase inject-objects [SELENIUMBASE_PYTHON_FILE]\n"
55
+ exp += " seleniumbase inject-objects [SELENIUMBASE_PYTHON_FILE]\n"
56
56
  exp += " Options:\n"
57
- exp += " -c, --comments (Add object selectors to the comments.)\n"
58
- exp += " (Default: No added comments.)\n"
57
+ exp += " -c, --comments (Add object selectors to the comments.)\n"
58
+ exp += " (Default: No added comments.)\n"
59
59
  exp += " Output:\n"
60
- exp += ' Takes the page objects found in the "page_objects.py"\n'
61
- exp += " file and uses those to replace matching selectors in\n"
62
- exp += " the selected seleniumbase Python file.\n"
60
+ exp += ' Takes the page objects found in the "page_objects.py"\n'
61
+ exp += " file and uses those to replace matching selectors in\n"
62
+ exp += " the selected seleniumbase Python file.\n"
63
63
  raise Exception("INVALID RUN COMMAND!\n\n%s" % exp)
64
64
 
65
65
 
66
66
  def invalid_extract_objects_run_command():
67
67
  exp = " ** extract-objects **\n\n"
68
68
  exp += " Usage:\n"
69
- exp += " seleniumbase extract-objects [SELENIUMBASE_PYTHON_FILE]\n"
69
+ exp += " seleniumbase extract-objects [SELENIUMBASE_PYTHON_FILE]\n"
70
70
  exp += " Output:\n"
71
- exp += " Creates page objects based on selectors found in a\n"
72
- exp += " seleniumbase Python file and saves those objects to the\n"
73
- exp += ' "page_objects.py" file in the same folder as the tests.\n'
71
+ exp += " Creates page objects based on selectors found in a\n"
72
+ exp += " seleniumbase Python file and saves those objects to the\n"
73
+ exp += ' "page_objects.py" file in the same folder as the tests.\n'
74
74
  raise Exception("INVALID RUN COMMAND!\n\n%s" % exp)
75
75
 
76
76
 
77
77
  def invalid_revert_objects_run_command():
78
78
  exp = " ** revert-objects **\n\n"
79
79
  exp += " Usage:\n"
80
- exp += " seleniumbase revert-objects [SELENIUMBASE_PYTHON_FILE]\n"
80
+ exp += " seleniumbase revert-objects [SELENIUMBASE_PYTHON_FILE]\n"
81
81
  exp += " Options:\n"
82
- exp += " -c, --comments (Keep existing comments for the lines.)\n"
83
- exp += " (Default: No comments are kept.)\n"
82
+ exp += " -c, --comments (Keep existing comments for the lines.)\n"
83
+ exp += " (Default: No comments are kept.)\n"
84
84
  exp += " Output:\n"
85
- exp += ' Reverts the changes made by "seleniumbase objectify" or\n'
86
- exp += ' "seleniumbase inject-objects" when run against a\n'
87
- exp += " seleniumbase Python file. Objects will get replaced by\n"
88
- exp += ' selectors stored in the "page_objects.py" file.\n'
85
+ exp += ' Reverts the changes made by "seleniumbase objectify" or\n'
86
+ exp += ' "seleniumbase inject-objects" when run against a\n'
87
+ exp += " seleniumbase Python file. Objects will get replaced by\n"
88
+ exp += ' selectors stored in the "page_objects.py" file.\n'
89
89
  raise Exception("INVALID RUN COMMAND!\n\n%s" % exp)
90
90
 
91
91
 
@@ -18,13 +18,13 @@ import sys
18
18
  def invalid_run_command(msg=None):
19
19
  exp = " ** print **\n\n"
20
20
  exp += " Usage:\n"
21
- exp += " seleniumbase print [FILE] [OPTIONS]\n"
22
- exp += " OR: sbase print [FILE] [OPTIONS]\n"
21
+ exp += " seleniumbase print [FILE] [OPTIONS]\n"
22
+ exp += " OR: sbase print [FILE] [OPTIONS]\n"
23
23
  exp += " Options:\n"
24
- exp += " -n (Add line Numbers to the rows)\n"
24
+ exp += " -n (Add line Numbers to the rows)\n"
25
25
  exp += " Output:\n"
26
- exp += " Prints the code/text of any file\n"
27
- exp += " with syntax-highlighting.\n"
26
+ exp += " Prints the code/text of any file\n"
27
+ exp += " with syntax-highlighting.\n"
28
28
  if not msg:
29
29
  raise Exception("INVALID RUN COMMAND!\n\n%s" % exp)
30
30
  else:
@@ -61,13 +61,6 @@ def get_width(line):
61
61
 
62
62
 
63
63
  def main():
64
- if (
65
- "win32" in sys.platform
66
- and hasattr(colorama, "just_fix_windows_console")
67
- ):
68
- colorama.just_fix_windows_console()
69
- else:
70
- colorama.init(autoreset=True)
71
64
  c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
72
65
  c7 = colorama.Fore.BLACK + colorama.Back.MAGENTA
73
66
  cr = colorama.Style.RESET_ALL
@@ -9,6 +9,7 @@ Usage:
9
9
 
10
10
  Options:
11
11
  --uc / --undetected (Use undetectable mode.)
12
+ --cdp (Same as "--uc" and "--undetectable".)
12
13
  --behave (Also output Behave/Gherkin files.)
13
14
 
14
15
  Output:
@@ -18,23 +19,23 @@ import colorama
18
19
  import os
19
20
  import subprocess
20
21
  import sys
22
+ import tkinter as tk
21
23
  from seleniumbase import config as sb_config
22
24
  from seleniumbase.fixtures import page_utils
23
25
  from seleniumbase.fixtures import shared_utils
26
+ from tkinter import messagebox
24
27
 
25
28
  sb_config.rec_subprocess_p = None
26
29
  sb_config.rec_subprocess_used = False
27
30
  sys_executable = sys.executable
28
31
  if " " in sys_executable:
29
32
  sys_executable = "python"
30
- if sys.version_info <= (3, 7):
33
+ if sys.version_info <= (3, 8):
31
34
  current_version = ".".join(str(ver) for ver in sys.version_info[:3])
32
35
  raise Exception(
33
- "\n* Recorder Desktop requires Python 3.7 or newer!"
36
+ "\n* Recorder Desktop requires Python 3.8 or newer!"
34
37
  "\n*** You are currently using Python %s" % current_version
35
38
  )
36
- import tkinter as tk # noqa: E402
37
- from tkinter import messagebox # noqa: E402
38
39
 
39
40
 
40
41
  def set_colors(use_colors):
@@ -45,13 +46,6 @@ def set_colors(use_colors):
45
46
  c4 = ""
46
47
  cr = ""
47
48
  if use_colors:
48
- if (
49
- "win32" in sys.platform
50
- and hasattr(colorama, "just_fix_windows_console")
51
- ):
52
- colorama.just_fix_windows_console()
53
- else:
54
- colorama.init(autoreset=True)
55
49
  c0 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
56
50
  c1 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
57
51
  c2 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
@@ -158,10 +152,13 @@ def do_recording(file_name, url, overwrite_enabled, use_chrome, window):
158
152
  command += " --edge"
159
153
  if (
160
154
  "--uc" in command_args
155
+ or "--cdp" in command_args
161
156
  or "--undetected" in command_args
162
157
  or "--undetectable" in command_args
163
158
  ):
164
159
  command += " --uc"
160
+ if "--ee" in command_args:
161
+ command += " --ee"
165
162
  command += add_on
166
163
  poll = None
167
164
  if sb_config.rec_subprocess_used:
@@ -195,6 +192,14 @@ def do_playback(file_name, use_chrome, window, demo_mode=False):
195
192
  command += " --edge"
196
193
  if demo_mode:
197
194
  command += " --demo"
195
+ command_args = sys.argv[2:]
196
+ if (
197
+ "--uc" in command_args
198
+ or "--cdp" in command_args
199
+ or "--undetected" in command_args
200
+ or "--undetectable" in command_args
201
+ ):
202
+ command += " --uc"
198
203
  poll = None
199
204
  if sb_config.rec_subprocess_used:
200
205
  poll = sb_config.rec_subprocess_p.poll()