seleniumbase 4.30.8__py3-none-any.whl → 4.31.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 (45) hide show
  1. sbase/__init__.py +1 -0
  2. seleniumbase/__init__.py +2 -3
  3. seleniumbase/__version__.py +1 -1
  4. seleniumbase/behave/behave_sb.py +47 -9
  5. seleniumbase/config/settings.py +4 -0
  6. seleniumbase/console_scripts/sb_behave_gui.py +5 -5
  7. seleniumbase/console_scripts/sb_caseplans.py +6 -6
  8. seleniumbase/console_scripts/sb_commander.py +5 -5
  9. seleniumbase/console_scripts/sb_install.py +10 -2
  10. seleniumbase/console_scripts/sb_recorder.py +4 -4
  11. seleniumbase/core/browser_launcher.py +138 -103
  12. seleniumbase/core/mysql.py +1 -4
  13. seleniumbase/core/recorder_helper.py +24 -5
  14. seleniumbase/core/sb_driver.py +2 -3
  15. seleniumbase/core/settings_parser.py +4 -0
  16. seleniumbase/fixtures/base_case.py +307 -492
  17. seleniumbase/fixtures/js_utils.py +19 -52
  18. seleniumbase/fixtures/page_actions.py +3 -6
  19. seleniumbase/fixtures/page_utils.py +20 -58
  20. seleniumbase/plugins/base_plugin.py +2 -3
  21. seleniumbase/plugins/driver_manager.py +169 -3
  22. seleniumbase/plugins/pytest_plugin.py +34 -21
  23. seleniumbase/plugins/sb_manager.py +170 -3
  24. seleniumbase/plugins/selenium_plugin.py +52 -6
  25. seleniumbase/undetected/__init__.py +13 -38
  26. seleniumbase/undetected/dprocess.py +4 -6
  27. seleniumbase/undetected/options.py +3 -6
  28. seleniumbase/undetected/patcher.py +2 -3
  29. {seleniumbase-4.30.8.dist-info → seleniumbase-4.31.0.dist-info}/METADATA +108 -123
  30. {seleniumbase-4.30.8.dist-info → seleniumbase-4.31.0.dist-info}/RECORD +34 -45
  31. {seleniumbase-4.30.8.dist-info → seleniumbase-4.31.0.dist-info}/WHEEL +1 -1
  32. sbase/ReadMe.txt +0 -2
  33. seleniumbase/ReadMe.md +0 -25
  34. seleniumbase/common/ReadMe.md +0 -71
  35. seleniumbase/console_scripts/ReadMe.md +0 -734
  36. seleniumbase/drivers/ReadMe.md +0 -27
  37. seleniumbase/extensions/ReadMe.md +0 -12
  38. seleniumbase/masterqa/ReadMe.md +0 -61
  39. seleniumbase/resources/ReadMe.md +0 -31
  40. seleniumbase/resources/favicon.ico +0 -0
  41. seleniumbase/utilities/selenium_grid/ReadMe.md +0 -84
  42. seleniumbase/utilities/selenium_ide/ReadMe.md +0 -111
  43. {seleniumbase-4.30.8.dist-info → seleniumbase-4.31.0.dist-info}/LICENSE +0 -0
  44. {seleniumbase-4.30.8.dist-info → seleniumbase-4.31.0.dist-info}/entry_points.txt +0 -0
  45. {seleniumbase-4.30.8.dist-info → seleniumbase-4.31.0.dist-info}/top_level.txt +0 -0
@@ -9,6 +9,7 @@ import time
9
9
  import types
10
10
  import urllib3
11
11
  import warnings
12
+ from contextlib import suppress
12
13
  from selenium import webdriver
13
14
  from selenium.common.exceptions import ElementClickInterceptedException
14
15
  from selenium.common.exceptions import InvalidSessionIdException
@@ -277,7 +278,7 @@ def chromedriver_on_path():
277
278
  def get_uc_driver_version(full=False):
278
279
  uc_driver_version = None
279
280
  if os.path.exists(LOCAL_UC_DRIVER):
280
- try:
281
+ with suppress(Exception):
281
282
  output = subprocess.check_output(
282
283
  '"%s" --version' % LOCAL_UC_DRIVER, shell=True
283
284
  )
@@ -292,8 +293,6 @@ def get_uc_driver_version(full=False):
292
293
  uc_driver_version = full_version
293
294
  else:
294
295
  uc_driver_version = output
295
- except Exception:
296
- pass
297
296
  return uc_driver_version
298
297
 
299
298
 
@@ -372,7 +371,7 @@ def uc_special_open_if_cf(
372
371
  ):
373
372
  if url.startswith("http:") or url.startswith("https:"):
374
373
  special = False
375
- try:
374
+ with suppress(Exception):
376
375
  req_get = requests_get(url, proxy_string)
377
376
  status_str = str(req_get.status_code)
378
377
  if (
@@ -384,8 +383,6 @@ def uc_special_open_if_cf(
384
383
  special = True
385
384
  if status_str == "403" or status_str == "429":
386
385
  time.sleep(0.06) # Forbidden / Blocked! (Wait first!)
387
- except Exception:
388
- pass
389
386
  if special:
390
387
  time.sleep(0.05)
391
388
  with driver:
@@ -416,13 +413,11 @@ def uc_special_open_if_cf(
416
413
  "mobile": True
417
414
  }
418
415
  )
419
- try:
416
+ with suppress(Exception):
420
417
  driver.execute_cdp_cmd(
421
418
  'Emulation.setDeviceMetricsOverride',
422
419
  set_device_metrics_override
423
420
  )
424
- except Exception:
425
- pass
426
421
  if not mobile_emulator:
427
422
  page_actions.switch_to_window(
428
423
  driver, driver.window_handles[-1], 2
@@ -529,13 +524,11 @@ def uc_click(
529
524
  timeout=settings.SMALL_TIMEOUT,
530
525
  reconnect_time=None,
531
526
  ):
532
- try:
527
+ with suppress(Exception):
533
528
  rct = float(by) # Add shortcut: driver.uc_click(selector, RCT)
534
529
  if not reconnect_time:
535
530
  reconnect_time = rct
536
531
  by = "css selector"
537
- except Exception:
538
- pass
539
532
  element = driver.wait_for_selector(selector, by=by, timeout=timeout)
540
533
  tag_name = element.tag_name
541
534
  if not tag_name == "span" and not tag_name == "input": # Must be "visible"
@@ -574,7 +567,7 @@ def install_pyautogui_if_missing(driver):
574
567
  with pip_find_lock: # Prevent issues with multiple processes
575
568
  try:
576
569
  import pyautogui
577
- try:
570
+ with suppress(Exception):
578
571
  use_pyautogui_ver = constants.PyAutoGUI.VER
579
572
  if pyautogui.__version__ != use_pyautogui_ver:
580
573
  del pyautogui
@@ -582,8 +575,6 @@ def install_pyautogui_if_missing(driver):
582
575
  "pyautogui", version=use_pyautogui_ver
583
576
  )
584
577
  import pyautogui
585
- except Exception:
586
- pass
587
578
  except Exception:
588
579
  print("\nPyAutoGUI required! Installing now...")
589
580
  shared_utils.pip_install(
@@ -602,16 +593,32 @@ def install_pyautogui_if_missing(driver):
602
593
  and not (sb_config.headless or sb_config.headless2)
603
594
  ):
604
595
  from sbvirtualdisplay import Display
605
- try:
596
+ xvfb_width = 1366
597
+ xvfb_height = 768
598
+ if (
599
+ hasattr(sb_config, "_xvfb_width")
600
+ and sb_config._xvfb_width
601
+ and isinstance(sb_config._xvfb_width, int)
602
+ and hasattr(sb_config, "_xvfb_height")
603
+ and sb_config._xvfb_height
604
+ and isinstance(sb_config._xvfb_height, int)
605
+ ):
606
+ xvfb_width = sb_config._xvfb_width
607
+ xvfb_height = sb_config._xvfb_height
608
+ if xvfb_width < 1024:
609
+ xvfb_width = 1024
610
+ sb_config._xvfb_width = xvfb_width
611
+ if xvfb_height < 768:
612
+ xvfb_height = 768
613
+ sb_config._xvfb_height = xvfb_height
614
+ with suppress(Exception):
606
615
  xvfb_display = Display(
607
616
  visible=True,
608
- size=(1366, 768),
617
+ size=(xvfb_width, xvfb_height),
609
618
  backend="xvfb",
610
619
  use_xauth=True,
611
620
  )
612
621
  xvfb_display.start()
613
- except Exception:
614
- pass
615
622
 
616
623
 
617
624
  def get_configured_pyautogui(pyautogui_copy):
@@ -778,12 +785,10 @@ def uc_gui_click_x_y(driver, x, y, timeframe=0.25):
778
785
  y = y * width_ratio
779
786
  _uc_gui_click_x_y(driver, x, y, timeframe=timeframe, uc_lock=False)
780
787
  return
781
- try:
788
+ with suppress(Exception):
782
789
  page_actions.switch_to_window(
783
790
  driver, driver.current_window_handle, 2, uc_lock=False
784
791
  )
785
- except Exception:
786
- pass
787
792
  _uc_gui_click_x_y(driver, x, y, timeframe=timeframe, uc_lock=False)
788
793
 
789
794
 
@@ -986,10 +991,8 @@ def _uc_gui_click_captcha(
986
991
  driver.uc_open_with_disconnect(driver.current_url, 3.8)
987
992
  else:
988
993
  driver.disconnect()
989
- try:
990
- _uc_gui_click_x_y(driver, x, y, timeframe=0.54321)
991
- except Exception:
992
- pass
994
+ with suppress(Exception):
995
+ _uc_gui_click_x_y(driver, x, y, timeframe=0.32)
993
996
  reconnect_time = (float(constants.UC.RECONNECT_TIME) / 2.0) + 0.6
994
997
  if IS_LINUX:
995
998
  reconnect_time = constants.UC.RECONNECT_TIME + 0.2
@@ -1031,12 +1034,12 @@ def _uc_gui_click_captcha(
1031
1034
  return
1032
1035
  if blind:
1033
1036
  driver.uc_open_with_disconnect(driver.current_url, 3.8)
1034
- _uc_gui_click_x_y(driver, x, y, timeframe=1.05)
1037
+ _uc_gui_click_x_y(driver, x, y, timeframe=0.32)
1035
1038
  else:
1036
1039
  driver.uc_open_with_reconnect(driver.current_url, 3.8)
1037
1040
  if _on_a_captcha_page(driver):
1038
1041
  driver.disconnect()
1039
- _uc_gui_click_x_y(driver, x, y, timeframe=1.05)
1042
+ _uc_gui_click_x_y(driver, x, y, timeframe=0.32)
1040
1043
  driver.reconnect(reconnect_time)
1041
1044
 
1042
1045
 
@@ -1216,13 +1219,11 @@ def _uc_gui_handle_captcha_(driver, frame="iframe", ctype=None):
1216
1219
  and sb_config._saved_cf_tab_count
1217
1220
  ):
1218
1221
  driver.uc_open_with_disconnect(driver.current_url, 3.8)
1219
- try:
1222
+ with suppress(Exception):
1220
1223
  for i in range(sb_config._saved_cf_tab_count):
1221
1224
  pyautogui.press("\t")
1222
1225
  time.sleep(0.027)
1223
1226
  pyautogui.press(" ")
1224
- except Exception:
1225
- pass
1226
1227
  else:
1227
1228
  driver.disconnect()
1228
1229
  pyautogui.press(" ")
@@ -1669,18 +1670,49 @@ def _set_chrome_options(
1669
1670
  chrome_options.add_experimental_option(
1670
1671
  "mobileEmulation", emulator_settings
1671
1672
  )
1673
+ # Handle Window Position
1674
+ if (headless or headless2) and IS_WINDOWS:
1675
+ # https://stackoverflow.com/a/78999088/7058266
1676
+ chrome_options.add_argument("--window-position=-2400,-2400")
1677
+ else:
1678
+ if (
1679
+ hasattr(settings, "WINDOW_START_X")
1680
+ and isinstance(settings.WINDOW_START_X, int)
1681
+ and hasattr(settings, "WINDOW_START_Y")
1682
+ and isinstance(settings.WINDOW_START_Y, int)
1683
+ ):
1684
+ chrome_options.add_argument(
1685
+ "--window-position=%s,%s" % (
1686
+ settings.WINDOW_START_X, settings.WINDOW_START_Y
1687
+ )
1688
+ )
1689
+ # Handle Window Size
1672
1690
  if headless or headless2:
1673
- chrome_options.add_argument(
1674
- "--window-size=%s,%s" % (
1675
- settings.HEADLESS_START_WIDTH, settings.HEADLESS_START_HEIGHT
1691
+ if (
1692
+ hasattr(settings, "HEADLESS_START_WIDTH")
1693
+ and isinstance(settings.HEADLESS_START_WIDTH, int)
1694
+ and hasattr(settings, "HEADLESS_START_HEIGHT")
1695
+ and isinstance(settings.HEADLESS_START_HEIGHT, int)
1696
+ ):
1697
+ chrome_options.add_argument(
1698
+ "--window-size=%s,%s" % (
1699
+ settings.HEADLESS_START_WIDTH,
1700
+ settings.HEADLESS_START_HEIGHT,
1701
+ )
1676
1702
  )
1677
- )
1678
1703
  else:
1679
- chrome_options.add_argument(
1680
- "--window-size=%s,%s" % (
1681
- settings.CHROME_START_WIDTH, settings.CHROME_START_HEIGHT
1704
+ if (
1705
+ hasattr(settings, "CHROME_START_WIDTH")
1706
+ and isinstance(settings.CHROME_START_WIDTH, int)
1707
+ and hasattr(settings, "CHROME_START_HEIGHT")
1708
+ and isinstance(settings.CHROME_START_HEIGHT, int)
1709
+ ):
1710
+ chrome_options.add_argument(
1711
+ "--window-size=%s,%s" % (
1712
+ settings.CHROME_START_WIDTH,
1713
+ settings.CHROME_START_HEIGHT,
1714
+ )
1682
1715
  )
1683
- )
1684
1716
  if (
1685
1717
  not proxy_auth
1686
1718
  and not disable_csp
@@ -1858,8 +1890,12 @@ def _set_chrome_options(
1858
1890
  binary_location = binary_loc
1859
1891
  extra_disabled_features = []
1860
1892
  if chromium_arg:
1861
- # Can be a comma-separated list of Chromium args
1862
- chromium_arg_list = chromium_arg.split(",")
1893
+ # Can be a comma-separated list of Chromium args or a list
1894
+ chromium_arg_list = None
1895
+ if isinstance(chromium_arg, (list, tuple)):
1896
+ chromium_arg_list = chromium_arg
1897
+ else:
1898
+ chromium_arg_list = chromium_arg.split(",")
1863
1899
  for chromium_arg_item in chromium_arg_list:
1864
1900
  chromium_arg_item = chromium_arg_item.strip()
1865
1901
  if not chromium_arg_item.startswith("--"):
@@ -1868,13 +1904,11 @@ def _set_chrome_options(
1868
1904
  else:
1869
1905
  chromium_arg_item = "--" + chromium_arg_item
1870
1906
  if "remote-debugging-port=" in chromium_arg_item:
1871
- try:
1907
+ with suppress(Exception):
1872
1908
  # Extra processing for UC Mode
1873
1909
  chrome_options._remote_debugging_port = int(
1874
1910
  chromium_arg_item.split("remote-debugging-port=")[1]
1875
1911
  )
1876
- except Exception:
1877
- pass
1878
1912
  if "set-binary" in chromium_arg_item and not binary_location:
1879
1913
  br_app = "google-chrome"
1880
1914
  binary_loc = detect_b_ver.get_binary_location(
@@ -2526,14 +2560,12 @@ def get_remote_driver(
2526
2560
  try:
2527
2561
  from seleniumwire import webdriver
2528
2562
  import blinker
2529
- try:
2563
+ with suppress(Exception):
2530
2564
  use_blinker_ver = constants.SeleniumWire.BLINKER_VER
2531
2565
  if blinker.__version__ != use_blinker_ver:
2532
2566
  shared_utils.pip_install(
2533
2567
  "blinker", version=use_blinker_ver
2534
2568
  )
2535
- except Exception:
2536
- pass
2537
2569
  del blinker
2538
2570
  except Exception:
2539
2571
  shared_utils.pip_install(
@@ -2957,14 +2989,12 @@ def get_local_driver(
2957
2989
  try:
2958
2990
  from seleniumwire import webdriver
2959
2991
  import blinker
2960
- try:
2992
+ with suppress(Exception):
2961
2993
  use_blinker_ver = constants.SeleniumWire.BLINKER_VER
2962
2994
  if blinker.__version__ != use_blinker_ver:
2963
2995
  shared_utils.pip_install(
2964
2996
  "blinker", version=use_blinker_ver
2965
2997
  )
2966
- except Exception:
2967
- pass
2968
2998
  del blinker
2969
2999
  except Exception:
2970
3000
  shared_utils.pip_install(
@@ -3255,7 +3285,7 @@ def get_local_driver(
3255
3285
  edge_driver_version = None
3256
3286
  edgedriver_upgrade_needed = False
3257
3287
  if os.path.exists(LOCAL_EDGEDRIVER):
3258
- try:
3288
+ with suppress(Exception):
3259
3289
  output = subprocess.check_output(
3260
3290
  '"%s" --version' % LOCAL_EDGEDRIVER, shell=True
3261
3291
  )
@@ -3281,8 +3311,6 @@ def get_local_driver(
3281
3311
  edge_driver_version = output
3282
3312
  if driver_version == "keep":
3283
3313
  driver_version = edge_driver_version
3284
- except Exception:
3285
- pass
3286
3314
  use_version = find_edgedriver_version_to_use(
3287
3315
  use_version, driver_version
3288
3316
  )
@@ -3386,7 +3414,7 @@ def get_local_driver(
3386
3414
  edge_options.add_argument("--headless=new")
3387
3415
  elif headless and undetectable:
3388
3416
  # (For later: UC Mode doesn't support Edge now)
3389
- try:
3417
+ with suppress(Exception):
3390
3418
  if int(use_version) >= 109:
3391
3419
  edge_options.add_argument("--headless=new")
3392
3420
  elif (
@@ -3396,8 +3424,6 @@ def get_local_driver(
3396
3424
  edge_options.add_argument("--headless=chrome")
3397
3425
  else:
3398
3426
  pass # Will need Xvfb on Linux
3399
- except Exception:
3400
- pass
3401
3427
  elif headless:
3402
3428
  if "--headless" not in edge_options.arguments:
3403
3429
  edge_options.add_argument("--headless")
@@ -3422,20 +3448,49 @@ def get_local_driver(
3422
3448
  edge_options.add_experimental_option(
3423
3449
  "mobileEmulation", emulator_settings
3424
3450
  )
3451
+ # Handle Window Position
3452
+ if (headless or headless2) and IS_WINDOWS:
3453
+ # https://stackoverflow.com/a/78999088/7058266
3454
+ edge_options.add_argument("--window-position=-2400,-2400")
3455
+ else:
3456
+ if (
3457
+ hasattr(settings, "WINDOW_START_X")
3458
+ and isinstance(settings.WINDOW_START_X, int)
3459
+ and hasattr(settings, "WINDOW_START_Y")
3460
+ and isinstance(settings.WINDOW_START_Y, int)
3461
+ ):
3462
+ edge_options.add_argument(
3463
+ "--window-position=%s,%s" % (
3464
+ settings.WINDOW_START_X, settings.WINDOW_START_Y
3465
+ )
3466
+ )
3467
+ # Handle Window Size
3425
3468
  if headless or headless2:
3426
- edge_options.add_argument(
3427
- "--window-size=%s,%s" % (
3428
- settings.HEADLESS_START_WIDTH,
3429
- settings.HEADLESS_START_HEIGHT,
3469
+ if (
3470
+ hasattr(settings, "HEADLESS_START_WIDTH")
3471
+ and isinstance(settings.HEADLESS_START_WIDTH, int)
3472
+ and hasattr(settings, "HEADLESS_START_HEIGHT")
3473
+ and isinstance(settings.HEADLESS_START_HEIGHT, int)
3474
+ ):
3475
+ edge_options.add_argument(
3476
+ "--window-size=%s,%s" % (
3477
+ settings.HEADLESS_START_WIDTH,
3478
+ settings.HEADLESS_START_HEIGHT,
3479
+ )
3430
3480
  )
3431
- )
3432
3481
  else:
3433
- edge_options.add_argument(
3434
- "--window-size=%s,%s" % (
3435
- settings.CHROME_START_WIDTH,
3436
- settings.CHROME_START_HEIGHT,
3482
+ if (
3483
+ hasattr(settings, "CHROME_START_WIDTH")
3484
+ and isinstance(settings.CHROME_START_WIDTH, int)
3485
+ and hasattr(settings, "CHROME_START_HEIGHT")
3486
+ and isinstance(settings.CHROME_START_HEIGHT, int)
3487
+ ):
3488
+ edge_options.add_argument(
3489
+ "--window-size=%s,%s" % (
3490
+ settings.CHROME_START_WIDTH,
3491
+ settings.CHROME_START_HEIGHT,
3492
+ )
3437
3493
  )
3438
- )
3439
3494
  if user_data_dir and not is_using_uc(undetectable, browser_name):
3440
3495
  abs_path = os.path.abspath(user_data_dir)
3441
3496
  edge_options.add_argument("--user-data-dir=%s" % abs_path)
@@ -3569,7 +3624,11 @@ def get_local_driver(
3569
3624
  set_binary = False
3570
3625
  if chromium_arg:
3571
3626
  # Can be a comma-separated list of Chromium args
3572
- chromium_arg_list = chromium_arg.split(",")
3627
+ chromium_arg_list = None
3628
+ if isinstance(chromium_arg, (list, tuple)):
3629
+ chromium_arg_list = chromium_arg
3630
+ else:
3631
+ chromium_arg_list = chromium_arg.split(",")
3573
3632
  for chromium_arg_item in chromium_arg_list:
3574
3633
  chromium_arg_item = chromium_arg_item.strip()
3575
3634
  if not chromium_arg_item.startswith("--"):
@@ -3664,19 +3723,15 @@ def get_local_driver(
3664
3723
  constants.MultiBrowser.DRIVER_FIXING_LOCK
3665
3724
  )
3666
3725
  with edgedriver_fixing_lock:
3667
- try:
3726
+ with suppress(Exception):
3668
3727
  if not _was_driver_repaired():
3669
3728
  _repair_edgedriver(edge_version)
3670
3729
  _mark_driver_repaired()
3671
- except Exception:
3672
- pass
3673
3730
  else:
3674
- try:
3731
+ with suppress(Exception):
3675
3732
  if not _was_driver_repaired():
3676
3733
  _repair_edgedriver(edge_version)
3677
3734
  _mark_driver_repaired()
3678
- except Exception:
3679
- pass
3680
3735
  driver = Edge(service=service, options=edge_options)
3681
3736
  return extend_driver(driver)
3682
3737
  elif browser_name == constants.Browser.SAFARI:
@@ -3828,7 +3883,7 @@ def get_local_driver(
3828
3883
  ch_driver_version = None
3829
3884
  path_chromedriver = chromedriver_on_path()
3830
3885
  if os.path.exists(LOCAL_CHROMEDRIVER):
3831
- try:
3886
+ with suppress(Exception):
3832
3887
  output = subprocess.check_output(
3833
3888
  '"%s" --version' % LOCAL_CHROMEDRIVER, shell=True
3834
3889
  )
@@ -3842,8 +3897,6 @@ def get_local_driver(
3842
3897
  ch_driver_version = output
3843
3898
  if driver_version == "keep":
3844
3899
  driver_version = ch_driver_version
3845
- except Exception:
3846
- pass
3847
3900
  elif path_chromedriver:
3848
3901
  try:
3849
3902
  make_driver_executable_if_not(path_chromedriver)
@@ -3852,7 +3905,7 @@ def get_local_driver(
3852
3905
  "\nWarning: Could not make chromedriver"
3853
3906
  " executable: %s" % e
3854
3907
  )
3855
- try:
3908
+ with suppress(Exception):
3856
3909
  output = subprocess.check_output(
3857
3910
  '"%s" --version' % path_chromedriver, shell=True
3858
3911
  )
@@ -3866,8 +3919,6 @@ def get_local_driver(
3866
3919
  ch_driver_version = output
3867
3920
  if driver_version == "keep":
3868
3921
  use_version = ch_driver_version
3869
- except Exception:
3870
- pass
3871
3922
  disable_build_check = True
3872
3923
  uc_driver_version = None
3873
3924
  if is_using_uc(undetectable, browser_name):
@@ -4060,7 +4111,7 @@ def get_local_driver(
4060
4111
  if IS_ARM_MAC and use_uc:
4061
4112
  intel_for_uc = True # Use Intel driver for UC Mode
4062
4113
  if os.path.exists(LOCAL_CHROMEDRIVER):
4063
- try:
4114
+ with suppress(Exception):
4064
4115
  output = subprocess.check_output(
4065
4116
  '"%s" --version' % LOCAL_CHROMEDRIVER,
4066
4117
  shell=True,
@@ -4073,8 +4124,6 @@ def get_local_driver(
4073
4124
  output = full_ch_driver_version.split(".")[0]
4074
4125
  if int(output) >= 2:
4075
4126
  ch_driver_version = output
4076
- except Exception:
4077
- pass
4078
4127
  if (
4079
4128
  (
4080
4129
  not use_uc
@@ -4212,7 +4261,7 @@ def get_local_driver(
4212
4261
  chrome_options.add_argument(
4213
4262
  "--user-agent=%s" % user_agent
4214
4263
  )
4215
- try:
4264
+ with suppress(Exception):
4216
4265
  if (
4217
4266
  (
4218
4267
  not user_agent
@@ -4318,7 +4367,7 @@ def get_local_driver(
4318
4367
  service=service,
4319
4368
  options=headless_options,
4320
4369
  )
4321
- try:
4370
+ with suppress(Exception):
4322
4371
  user_agent = driver.execute_script(
4323
4372
  "return navigator.userAgent;"
4324
4373
  )
@@ -4340,11 +4389,7 @@ def get_local_driver(
4340
4389
  "--user-agent=%s" % user_agent
4341
4390
  )
4342
4391
  sb_config.uc_agent_cache = user_agent
4343
- except Exception:
4344
- pass
4345
4392
  driver.quit()
4346
- except Exception:
4347
- pass
4348
4393
  uc_path = None
4349
4394
  if os.path.exists(LOCAL_UC_DRIVER):
4350
4395
  uc_path = LOCAL_UC_DRIVER
@@ -4667,13 +4712,11 @@ def get_local_driver(
4667
4712
  "mobile": True
4668
4713
  }
4669
4714
  )
4670
- try:
4715
+ with suppress(Exception):
4671
4716
  driver.execute_cdp_cmd(
4672
4717
  'Emulation.setDeviceMetricsOverride',
4673
4718
  set_device_metrics_override
4674
4719
  )
4675
- except Exception:
4676
- pass
4677
4720
  return extend_driver(driver)
4678
4721
  else: # Running headless on Linux (and not using --uc)
4679
4722
  try:
@@ -4719,23 +4762,19 @@ def get_local_driver(
4719
4762
  )
4720
4763
  with chromedr_fixing_lock:
4721
4764
  if not _was_driver_repaired():
4722
- try:
4765
+ with suppress(Exception):
4723
4766
  _repair_chromedriver(
4724
4767
  chrome_options, chrome_options, mcv
4725
4768
  )
4726
4769
  _mark_driver_repaired()
4727
- except Exception:
4728
- pass
4729
4770
  else:
4730
4771
  if not _was_driver_repaired():
4731
- try:
4772
+ with suppress(Exception):
4732
4773
  _repair_chromedriver(
4733
4774
  chrome_options, chrome_options, mcv
4734
4775
  )
4735
- except Exception:
4736
- pass
4737
4776
  _mark_driver_repaired()
4738
- try:
4777
+ with suppress(Exception):
4739
4778
  service = ChromeService(
4740
4779
  log_output=os.devnull,
4741
4780
  service_args=["--disable-build-check"],
@@ -4745,8 +4784,6 @@ def get_local_driver(
4745
4784
  options=chrome_options,
4746
4785
  )
4747
4786
  return extend_driver(driver)
4748
- except Exception:
4749
- pass
4750
4787
  # Use the virtual display on Linux during headless errors
4751
4788
  logging.debug(
4752
4789
  "\nWarning: Chrome failed to launch in"
@@ -4767,14 +4804,12 @@ def get_local_driver(
4767
4804
  if is_using_uc(undetectable, browser_name):
4768
4805
  raise
4769
4806
  # Try again if Chrome didn't launch
4770
- try:
4807
+ with suppress(Exception):
4771
4808
  service = ChromeService(service_args=["--disable-build-check"])
4772
4809
  driver = webdriver.Chrome(
4773
4810
  service=service, options=chrome_options
4774
4811
  )
4775
4812
  return extend_driver(driver)
4776
- except Exception:
4777
- pass
4778
4813
  if user_data_dir:
4779
4814
  print("\nUnable to set user_data_dir while starting Chrome!\n")
4780
4815
  raise
@@ -35,10 +35,7 @@ class DatabaseManager:
35
35
  import cryptography # noqa: F401
36
36
  import pymysql
37
37
  except Exception:
38
- if sys.version_info < (3, 7):
39
- shared_utils.pip_install("PyMySQL[rsa]", version="1.0.2")
40
- else:
41
- shared_utils.pip_install("PyMySQL[rsa]", version="1.1.0")
38
+ shared_utils.pip_install("PyMySQL[rsa]", version="1.1.1")
42
39
  import pymysql
43
40
  db_server = settings.DB_HOST
44
41
  db_port = settings.DB_PORT
@@ -422,9 +422,14 @@ def generate_sbase_code(srt_actions):
422
422
  ):
423
423
  import unicodedata
424
424
 
425
- action[1][0] = unicodedata.normalize("NFKC", action[1][0])
426
- action[1][0] = action[1][0].replace("\n", "\\n")
427
- action[1][0] = action[1][0].replace("\u00B6", "")
425
+ text_list = False
426
+ try:
427
+ action[1][0] = unicodedata.normalize("NFKC", action[1][0])
428
+ action[1][0] = action[1][0].replace("\n", "\\n")
429
+ action[1][0] = action[1][0].replace("\u00B6", "")
430
+ except Exception:
431
+ text_list = True
432
+
428
433
  method = "assert_text"
429
434
  if action[0] == "as_et":
430
435
  method = "assert_exact_text"
@@ -437,7 +442,17 @@ def generate_sbase_code(srt_actions):
437
442
  elif action[0] == "da_et":
438
443
  method = "deferred_assert_exact_text"
439
444
  if action[1][1] != "html":
440
- if '"' not in action[1][0] and '"' not in action[1][1]:
445
+ if text_list and '"' not in action[1][1]:
446
+ sb_actions.append(
447
+ 'self.%s(%s, "%s")'
448
+ % (method, action[1][0], action[1][1])
449
+ )
450
+ elif text_list and "'" not in action[1][1]:
451
+ sb_actions.append(
452
+ "self.%s(%s, '%s')"
453
+ % (method, action[1][0], action[1][1])
454
+ )
455
+ elif '"' not in action[1][0] and '"' not in action[1][1]:
441
456
  sb_actions.append(
442
457
  'self.%s("%s", "%s")'
443
458
  % (method, action[1][0], action[1][1])
@@ -458,7 +473,11 @@ def generate_sbase_code(srt_actions):
458
473
  % (method, action[1][0], action[1][1])
459
474
  )
460
475
  else:
461
- if '"' not in action[1][0]:
476
+ if text_list:
477
+ sb_actions.append(
478
+ 'self.%s(%s)' % (method, action[1][0])
479
+ )
480
+ elif '"' not in action[1][0]:
462
481
  sb_actions.append(
463
482
  'self.%s("%s")' % (method, action[1][0])
464
483
  )
@@ -1,4 +1,5 @@
1
1
  """Add new methods to extend the driver"""
2
+ from contextlib import suppress
2
3
  from selenium.webdriver.remote.webelement import WebElement
3
4
  from seleniumbase.fixtures import js_utils
4
5
  from seleniumbase.fixtures import page_actions
@@ -36,10 +37,8 @@ class DriverMethods():
36
37
  selector, by = page_utils.swap_selector_and_by_if_reversed(
37
38
  selector, by
38
39
  )
39
- try:
40
+ with suppress(Exception):
40
41
  return self.driver.default_find_element(by=by, value=selector)
41
- except Exception:
42
- pass
43
42
  raise Exception('No such Element: {%s} (by="%s")!' % (selector, by))
44
43
 
45
44
  def get_attribute(self, selector, attribute, by="css selector"):
@@ -113,6 +113,10 @@ def set_settings(settings_file):
113
113
  settings.RAISE_INVALID_PROXY_STRING_EXCEPTION = override_settings[
114
114
  key
115
115
  ]
116
+ elif key == "WINDOW_START_X":
117
+ settings.WINDOW_START_X = override_settings[key]
118
+ elif key == "WINDOW_START_Y":
119
+ settings.WINDOW_START_Y = override_settings[key]
116
120
  elif key == "CHROME_START_WIDTH":
117
121
  settings.CHROME_START_WIDTH = override_settings[key]
118
122
  elif key == "CHROME_START_HEIGHT":