seleniumbase 4.41.3__py3-none-any.whl → 4.45.10__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 (64) hide show
  1. sbase/steps.py +9 -0
  2. seleniumbase/__version__.py +1 -1
  3. seleniumbase/behave/behave_helper.py +2 -0
  4. seleniumbase/behave/behave_sb.py +21 -8
  5. seleniumbase/common/decorators.py +3 -1
  6. seleniumbase/console_scripts/run.py +1 -0
  7. seleniumbase/console_scripts/sb_caseplans.py +3 -4
  8. seleniumbase/console_scripts/sb_install.py +142 -11
  9. seleniumbase/console_scripts/sb_mkchart.py +1 -2
  10. seleniumbase/console_scripts/sb_mkdir.py +99 -29
  11. seleniumbase/console_scripts/sb_mkfile.py +1 -2
  12. seleniumbase/console_scripts/sb_mkpres.py +1 -2
  13. seleniumbase/console_scripts/sb_mkrec.py +26 -2
  14. seleniumbase/console_scripts/sb_objectify.py +4 -5
  15. seleniumbase/console_scripts/sb_print.py +1 -1
  16. seleniumbase/console_scripts/sb_recorder.py +40 -3
  17. seleniumbase/core/browser_launcher.py +474 -151
  18. seleniumbase/core/detect_b_ver.py +258 -16
  19. seleniumbase/core/log_helper.py +15 -21
  20. seleniumbase/core/mysql.py +1 -1
  21. seleniumbase/core/recorder_helper.py +3 -0
  22. seleniumbase/core/report_helper.py +9 -12
  23. seleniumbase/core/sb_cdp.py +734 -215
  24. seleniumbase/core/sb_driver.py +46 -5
  25. seleniumbase/core/session_helper.py +2 -4
  26. seleniumbase/core/tour_helper.py +1 -2
  27. seleniumbase/drivers/atlas_drivers/__init__.py +0 -0
  28. seleniumbase/drivers/brave_drivers/__init__.py +0 -0
  29. seleniumbase/drivers/chromium_drivers/__init__.py +0 -0
  30. seleniumbase/drivers/comet_drivers/__init__.py +0 -0
  31. seleniumbase/drivers/opera_drivers/__init__.py +0 -0
  32. seleniumbase/fixtures/base_case.py +448 -251
  33. seleniumbase/fixtures/constants.py +36 -9
  34. seleniumbase/fixtures/js_utils.py +77 -18
  35. seleniumbase/fixtures/page_actions.py +41 -13
  36. seleniumbase/fixtures/page_utils.py +19 -12
  37. seleniumbase/fixtures/shared_utils.py +64 -6
  38. seleniumbase/masterqa/master_qa.py +16 -2
  39. seleniumbase/plugins/base_plugin.py +8 -0
  40. seleniumbase/plugins/basic_test_info.py +2 -3
  41. seleniumbase/plugins/driver_manager.py +131 -5
  42. seleniumbase/plugins/page_source.py +2 -3
  43. seleniumbase/plugins/pytest_plugin.py +244 -79
  44. seleniumbase/plugins/sb_manager.py +143 -20
  45. seleniumbase/plugins/selenium_plugin.py +144 -12
  46. seleniumbase/translate/translator.py +2 -3
  47. seleniumbase/undetected/__init__.py +17 -13
  48. seleniumbase/undetected/cdp.py +1 -12
  49. seleniumbase/undetected/cdp_driver/browser.py +330 -129
  50. seleniumbase/undetected/cdp_driver/cdp_util.py +328 -61
  51. seleniumbase/undetected/cdp_driver/config.py +110 -14
  52. seleniumbase/undetected/cdp_driver/connection.py +18 -48
  53. seleniumbase/undetected/cdp_driver/element.py +105 -33
  54. seleniumbase/undetected/cdp_driver/tab.py +414 -39
  55. seleniumbase/utilities/selenium_grid/download_selenium_server.py +1 -1
  56. seleniumbase/utilities/selenium_grid/grid_hub.py +1 -2
  57. seleniumbase/utilities/selenium_grid/grid_node.py +2 -3
  58. seleniumbase/utilities/selenium_ide/convert_ide.py +2 -3
  59. {seleniumbase-4.41.3.dist-info → seleniumbase-4.45.10.dist-info}/METADATA +193 -166
  60. {seleniumbase-4.41.3.dist-info → seleniumbase-4.45.10.dist-info}/RECORD +64 -59
  61. {seleniumbase-4.41.3.dist-info → seleniumbase-4.45.10.dist-info}/licenses/LICENSE +1 -1
  62. {seleniumbase-4.41.3.dist-info → seleniumbase-4.45.10.dist-info}/WHEEL +0 -0
  63. {seleniumbase-4.41.3.dist-info → seleniumbase-4.45.10.dist-info}/entry_points.txt +0 -0
  64. {seleniumbase-4.41.3.dist-info → seleniumbase-4.45.10.dist-info}/top_level.txt +0 -0
@@ -140,6 +140,7 @@ def Driver(
140
140
  pls=None, # Shortcut / Duplicate of "page_load_strategy".
141
141
  cft=None, # Use "Chrome for Testing"
142
142
  chs=None, # Use "Chrome-Headless-Shell"
143
+ use_chromium=None, # Use base "Chromium"
143
144
  ) -> sb_driver.DriverMethods:
144
145
  """
145
146
  * SeleniumBase Driver as a Python Context Manager or a returnable object. *
@@ -239,6 +240,7 @@ def Driver(
239
240
  from seleniumbase import config as sb_config
240
241
  from seleniumbase.config import settings
241
242
  from seleniumbase.core import browser_launcher
243
+ from seleniumbase.core import detect_b_ver
242
244
  from seleniumbase.fixtures import constants
243
245
  from seleniumbase.fixtures import shared_utils
244
246
 
@@ -271,10 +273,37 @@ def Driver(
271
273
  )
272
274
  elif existing_runner:
273
275
  sb_config._context_of_runner = True
276
+ sb_config._browser_shortcut = None
277
+ sb_config._cdp_browser = None
278
+ sb_config._cdp_bin_loc = None
274
279
  browser_changes = 0
275
280
  browser_set = None
276
281
  browser_text = None
277
282
  browser_list = []
283
+ # Check if binary-location in options
284
+ bin_loc_in_options = False
285
+ if (
286
+ binary_location
287
+ and len(str(binary_location)) > 5
288
+ and os.path.exists(str(binary_location))
289
+ ):
290
+ bin_loc_in_options = True
291
+ else:
292
+ for arg in sys_argv:
293
+ if arg in ["--binary-location", "--binary_location", "--bl"]:
294
+ bin_loc_in_options = True
295
+ if (
296
+ browser
297
+ and browser in constants.ChromiumSubs.chromium_subs
298
+ and not bin_loc_in_options
299
+ ):
300
+ bin_loc = detect_b_ver.get_binary_location(browser)
301
+ if bin_loc and os.path.exists(bin_loc):
302
+ if browser in bin_loc.lower().split("/")[-1].split("\\")[-1]:
303
+ sb_config._cdp_browser = browser
304
+ sb_config._cdp_bin_loc = bin_loc
305
+ binary_location = bin_loc
306
+ bin_loc_in_options = True
278
307
  # As a shortcut, you can use "--edge" instead of "--browser=edge", etc,
279
308
  # but you can only specify one default browser for tests. (Default: chrome)
280
309
  if "--browser=chrome" in sys_argv or "--browser chrome" in sys_argv:
@@ -301,6 +330,46 @@ def Driver(
301
330
  browser_changes += 1
302
331
  browser_set = "remote"
303
332
  browser_list.append("--browser=remote")
333
+ if "--browser=opera" in sys_argv or "--browser opera" in sys_argv:
334
+ if not bin_loc_in_options:
335
+ bin_loc = detect_b_ver.get_binary_location("opera")
336
+ if os.path.exists(bin_loc):
337
+ browser_changes += 1
338
+ browser_set = "opera"
339
+ sb_config._browser_shortcut = "opera"
340
+ sb_config._cdp_browser = "opera"
341
+ sb_config._cdp_bin_loc = bin_loc
342
+ browser_list.append("--browser=opera")
343
+ if "--browser=brave" in sys_argv or "--browser brave" in sys_argv:
344
+ if not bin_loc_in_options:
345
+ bin_loc = detect_b_ver.get_binary_location("brave")
346
+ if os.path.exists(bin_loc):
347
+ browser_changes += 1
348
+ browser_set = "brave"
349
+ sb_config._browser_shortcut = "brave"
350
+ sb_config._cdp_browser = "brave"
351
+ sb_config._cdp_bin_loc = bin_loc
352
+ browser_list.append("--browser=brave")
353
+ if "--browser=comet" in sys_argv or "--browser comet" in sys_argv:
354
+ if not bin_loc_in_options:
355
+ bin_loc = detect_b_ver.get_binary_location("comet")
356
+ if os.path.exists(bin_loc):
357
+ browser_changes += 1
358
+ browser_set = "comet"
359
+ sb_config._browser_shortcut = "comet"
360
+ sb_config._cdp_browser = "comet"
361
+ sb_config._cdp_bin_loc = bin_loc
362
+ browser_list.append("--browser=comet")
363
+ if "--browser=atlas" in sys_argv or "--browser atlas" in sys_argv:
364
+ if not bin_loc_in_options:
365
+ bin_loc = detect_b_ver.get_binary_location("atlas")
366
+ if os.path.exists(bin_loc):
367
+ browser_changes += 1
368
+ browser_set = "atlas"
369
+ sb_config._browser_shortcut = "atlas"
370
+ sb_config._cdp_browser = "atlas"
371
+ sb_config._cdp_bin_loc = bin_loc
372
+ browser_list.append("--browser=atlas")
304
373
  browser_text = browser_set
305
374
  if "--chrome" in sys_argv and not browser_set == "chrome":
306
375
  browser_changes += 1
@@ -322,6 +391,46 @@ def Driver(
322
391
  browser_changes += 1
323
392
  browser_text = "safari"
324
393
  browser_list.append("--safari")
394
+ if "--opera" in sys_argv and not browser_set == "opera":
395
+ if not bin_loc_in_options:
396
+ bin_loc = detect_b_ver.get_binary_location("opera")
397
+ if os.path.exists(bin_loc):
398
+ browser_changes += 1
399
+ browser_text = "opera"
400
+ sb_config._browser_shortcut = "opera"
401
+ sb_config._cdp_browser = "opera"
402
+ sb_config._cdp_bin_loc = bin_loc
403
+ browser_list.append("--opera")
404
+ if "--brave" in sys_argv and not browser_set == "brave":
405
+ if not bin_loc_in_options:
406
+ bin_loc = detect_b_ver.get_binary_location("brave")
407
+ if os.path.exists(bin_loc):
408
+ browser_changes += 1
409
+ browser_text = "brave"
410
+ sb_config._browser_shortcut = "brave"
411
+ sb_config._cdp_browser = "brave"
412
+ sb_config._cdp_bin_loc = bin_loc
413
+ browser_list.append("--brave")
414
+ if "--comet" in sys_argv and not browser_set == "comet":
415
+ if not bin_loc_in_options:
416
+ bin_loc = detect_b_ver.get_binary_location("comet")
417
+ if os.path.exists(bin_loc):
418
+ browser_changes += 1
419
+ browser_text = "comet"
420
+ sb_config._browser_shortcut = "comet"
421
+ sb_config._cdp_browser = "comet"
422
+ sb_config._cdp_bin_loc = bin_loc
423
+ browser_list.append("--comet")
424
+ if "--atlas" in sys_argv and not browser_set == "atlas":
425
+ if not bin_loc_in_options:
426
+ bin_loc = detect_b_ver.get_binary_location("atlas")
427
+ if os.path.exists(bin_loc):
428
+ browser_changes += 1
429
+ browser_text = "atlas"
430
+ sb_config._browser_shortcut = "atlas"
431
+ sb_config._cdp_browser = "atlas"
432
+ sb_config._cdp_bin_loc = bin_loc
433
+ browser_list.append("--atlas")
325
434
  if browser_changes > 1:
326
435
  message = "\n\n TOO MANY browser types were entered!"
327
436
  message += "\n There were %s found:\n > %s" % (
@@ -345,6 +454,8 @@ def Driver(
345
454
  "Browser: {%s} is not a valid browser option. "
346
455
  "Valid options = {%s}" % (browser, valid_browsers)
347
456
  )
457
+ if sb_config._browser_shortcut:
458
+ browser = sb_config._browser_shortcut
348
459
  if headless is None:
349
460
  if "--headless" in sys_argv:
350
461
  headless = True
@@ -534,6 +645,8 @@ def Driver(
534
645
  count += 1
535
646
  user_agent = agent
536
647
  found_bl = None
648
+ if hasattr(sb_config, "_cdp_bin_loc") and sb_config._cdp_bin_loc:
649
+ binary_location = sb_config._cdp_bin_loc
537
650
  if binary_location is None and "--binary-location" in arg_join:
538
651
  count = 0
539
652
  for arg in sys_argv:
@@ -553,11 +666,15 @@ def Driver(
553
666
  if arg.startswith("--bl="):
554
667
  binary_location = arg.split("--bl=")[1]
555
668
  break
556
- if cft and not binary_location:
669
+ if use_chromium and not binary_location:
670
+ binary_location = "_chromium_"
671
+ elif cft and not binary_location:
557
672
  binary_location = "cft"
558
673
  elif chs and not binary_location:
559
674
  binary_location = "chs"
560
- if "--cft" in sys_argv and not binary_location:
675
+ if "--use-chromium" in sys_argv and not binary_location:
676
+ binary_location = "_chromium_"
677
+ elif "--cft" in sys_argv and not binary_location:
561
678
  binary_location = "cft"
562
679
  elif "--chs" in sys_argv and not binary_location:
563
680
  binary_location = "chs"
@@ -630,9 +747,12 @@ def Driver(
630
747
  uc_cdp_events = True
631
748
  else:
632
749
  uc_cdp_events = False
633
- if undetectable and browser != "chrome":
750
+ if (
751
+ undetectable
752
+ and browser not in ["chrome", "opera", "brave", "comet", "atlas"]
753
+ ):
634
754
  message = (
635
- '\n Undetected-Chromedriver Mode ONLY supports Chrome!'
755
+ '\n Undetected-Chromedriver Mode ONLY supports Chromium browsers!'
636
756
  '\n ("uc=True" / "undetectable=True" / "--uc")'
637
757
  '\n (Your browser choice was: "%s".)'
638
758
  '\n (Will use "%s" without UC Mode.)\n' % (browser, browser)
@@ -663,7 +783,9 @@ def Driver(
663
783
  if headless2 and browser == "firefox":
664
784
  headless2 = False # Only for Chromium browsers
665
785
  headless = True # Firefox has regular headless
666
- elif browser not in ["chrome", "edge"]:
786
+ elif browser not in [
787
+ "chrome", "edge", "opera", "brave", "comet", "atlas"
788
+ ]:
667
789
  headless2 = False # Only for Chromium browsers
668
790
  if disable_csp is None:
669
791
  if (
@@ -839,6 +961,10 @@ def Driver(
839
961
  driver_version = None
840
962
  break
841
963
  count += 1
964
+ if browser in constants.ChromiumSubs.chromium_subs:
965
+ if not binary_location:
966
+ browser = "chrome" # Still uses chromedriver
967
+ sb_config._browser_shortcut = browser
842
968
  browser_name = browser
843
969
 
844
970
  # Launch a web browser
@@ -1,6 +1,5 @@
1
1
  """PageSource Plugin for SeleniumBase tests that run with pynose / nosetests"""
2
2
  import os
3
- import codecs
4
3
  from nose.plugins import Plugin
5
4
  from seleniumbase.config import settings
6
5
  from seleniumbase.core import log_helper
@@ -29,7 +28,7 @@ class PageSource(Plugin):
29
28
  if not os.path.exists(test_logpath):
30
29
  os.makedirs(test_logpath)
31
30
  html_file_name = os.path.join(test_logpath, self.logfile_name)
32
- html_file = codecs.open(html_file_name, "w+", "utf-8")
31
+ html_file = open(html_file_name, mode="w+", encoding="utf-8")
33
32
  rendered_source = log_helper.get_html_source_with_base_href(
34
33
  test.driver, page_source
35
34
  )
@@ -45,7 +44,7 @@ class PageSource(Plugin):
45
44
  if not os.path.exists(test_logpath):
46
45
  os.makedirs(test_logpath)
47
46
  html_file_name = os.path.join(test_logpath, self.logfile_name)
48
- html_file = codecs.open(html_file_name, "w+", "utf-8")
47
+ html_file = open(html_file_name, mode="w+", encoding="utf-8")
49
48
  rendered_source = log_helper.get_html_source_with_base_href(
50
49
  test.driver, page_source
51
50
  )