seleniumbase 4.30.7__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 +153 -104
  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.7.dist-info → seleniumbase-4.31.0.dist-info}/METADATA +108 -123
  30. {seleniumbase-4.30.7.dist-info → seleniumbase-4.31.0.dist-info}/RECORD +34 -45
  31. {seleniumbase-4.30.7.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.7.dist-info → seleniumbase-4.31.0.dist-info}/LICENSE +0 -0
  44. {seleniumbase-4.30.7.dist-info → seleniumbase-4.31.0.dist-info}/entry_points.txt +0 -0
  45. {seleniumbase-4.30.7.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
 
@@ -1188,8 +1191,10 @@ def _uc_gui_handle_captcha_(driver, frame="iframe", ctype=None):
1188
1191
  for i in range(10):
1189
1192
  pyautogui.hotkey("shift", "tab")
1190
1193
  time.sleep(0.027)
1194
+ tab_count = 0
1191
1195
  for i in range(34):
1192
1196
  pyautogui.press("\t")
1197
+ tab_count += 1
1193
1198
  time.sleep(0.027)
1194
1199
  active_element_css = js_utils.get_active_element_css(driver)
1195
1200
  if (
@@ -1198,6 +1203,7 @@ def _uc_gui_handle_captcha_(driver, frame="iframe", ctype=None):
1198
1203
  or (special_form and active_element_css.endswith(" div"))
1199
1204
  ):
1200
1205
  found_checkbox = True
1206
+ sb_config._saved_cf_tab_count = tab_count
1201
1207
  break
1202
1208
  time.sleep(0.02)
1203
1209
  if not found_checkbox:
@@ -1207,11 +1213,20 @@ def _uc_gui_handle_captcha_(driver, frame="iframe", ctype=None):
1207
1213
  driver.switch_to.default_content()
1208
1214
  except Exception:
1209
1215
  return
1210
- driver.disconnect()
1211
- try:
1216
+ if (
1217
+ driver.is_element_present(".footer .clearfix .ray-id")
1218
+ and hasattr(sb_config, "_saved_cf_tab_count")
1219
+ and sb_config._saved_cf_tab_count
1220
+ ):
1221
+ driver.uc_open_with_disconnect(driver.current_url, 3.8)
1222
+ with suppress(Exception):
1223
+ for i in range(sb_config._saved_cf_tab_count):
1224
+ pyautogui.press("\t")
1225
+ time.sleep(0.027)
1226
+ pyautogui.press(" ")
1227
+ else:
1228
+ driver.disconnect()
1212
1229
  pyautogui.press(" ")
1213
- except Exception:
1214
- pass
1215
1230
  reconnect_time = (float(constants.UC.RECONNECT_TIME) / 2.0) + 0.6
1216
1231
  if IS_LINUX:
1217
1232
  reconnect_time = constants.UC.RECONNECT_TIME + 0.2
@@ -1655,18 +1670,49 @@ def _set_chrome_options(
1655
1670
  chrome_options.add_experimental_option(
1656
1671
  "mobileEmulation", emulator_settings
1657
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
1658
1690
  if headless or headless2:
1659
- chrome_options.add_argument(
1660
- "--window-size=%s,%s" % (
1661
- 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
+ )
1662
1702
  )
1663
- )
1664
1703
  else:
1665
- chrome_options.add_argument(
1666
- "--window-size=%s,%s" % (
1667
- 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
+ )
1668
1715
  )
1669
- )
1670
1716
  if (
1671
1717
  not proxy_auth
1672
1718
  and not disable_csp
@@ -1844,8 +1890,12 @@ def _set_chrome_options(
1844
1890
  binary_location = binary_loc
1845
1891
  extra_disabled_features = []
1846
1892
  if chromium_arg:
1847
- # Can be a comma-separated list of Chromium args
1848
- 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(",")
1849
1899
  for chromium_arg_item in chromium_arg_list:
1850
1900
  chromium_arg_item = chromium_arg_item.strip()
1851
1901
  if not chromium_arg_item.startswith("--"):
@@ -1854,13 +1904,11 @@ def _set_chrome_options(
1854
1904
  else:
1855
1905
  chromium_arg_item = "--" + chromium_arg_item
1856
1906
  if "remote-debugging-port=" in chromium_arg_item:
1857
- try:
1907
+ with suppress(Exception):
1858
1908
  # Extra processing for UC Mode
1859
1909
  chrome_options._remote_debugging_port = int(
1860
1910
  chromium_arg_item.split("remote-debugging-port=")[1]
1861
1911
  )
1862
- except Exception:
1863
- pass
1864
1912
  if "set-binary" in chromium_arg_item and not binary_location:
1865
1913
  br_app = "google-chrome"
1866
1914
  binary_loc = detect_b_ver.get_binary_location(
@@ -2512,14 +2560,12 @@ def get_remote_driver(
2512
2560
  try:
2513
2561
  from seleniumwire import webdriver
2514
2562
  import blinker
2515
- try:
2563
+ with suppress(Exception):
2516
2564
  use_blinker_ver = constants.SeleniumWire.BLINKER_VER
2517
2565
  if blinker.__version__ != use_blinker_ver:
2518
2566
  shared_utils.pip_install(
2519
2567
  "blinker", version=use_blinker_ver
2520
2568
  )
2521
- except Exception:
2522
- pass
2523
2569
  del blinker
2524
2570
  except Exception:
2525
2571
  shared_utils.pip_install(
@@ -2943,14 +2989,12 @@ def get_local_driver(
2943
2989
  try:
2944
2990
  from seleniumwire import webdriver
2945
2991
  import blinker
2946
- try:
2992
+ with suppress(Exception):
2947
2993
  use_blinker_ver = constants.SeleniumWire.BLINKER_VER
2948
2994
  if blinker.__version__ != use_blinker_ver:
2949
2995
  shared_utils.pip_install(
2950
2996
  "blinker", version=use_blinker_ver
2951
2997
  )
2952
- except Exception:
2953
- pass
2954
2998
  del blinker
2955
2999
  except Exception:
2956
3000
  shared_utils.pip_install(
@@ -3241,7 +3285,7 @@ def get_local_driver(
3241
3285
  edge_driver_version = None
3242
3286
  edgedriver_upgrade_needed = False
3243
3287
  if os.path.exists(LOCAL_EDGEDRIVER):
3244
- try:
3288
+ with suppress(Exception):
3245
3289
  output = subprocess.check_output(
3246
3290
  '"%s" --version' % LOCAL_EDGEDRIVER, shell=True
3247
3291
  )
@@ -3267,8 +3311,6 @@ def get_local_driver(
3267
3311
  edge_driver_version = output
3268
3312
  if driver_version == "keep":
3269
3313
  driver_version = edge_driver_version
3270
- except Exception:
3271
- pass
3272
3314
  use_version = find_edgedriver_version_to_use(
3273
3315
  use_version, driver_version
3274
3316
  )
@@ -3372,7 +3414,7 @@ def get_local_driver(
3372
3414
  edge_options.add_argument("--headless=new")
3373
3415
  elif headless and undetectable:
3374
3416
  # (For later: UC Mode doesn't support Edge now)
3375
- try:
3417
+ with suppress(Exception):
3376
3418
  if int(use_version) >= 109:
3377
3419
  edge_options.add_argument("--headless=new")
3378
3420
  elif (
@@ -3382,8 +3424,6 @@ def get_local_driver(
3382
3424
  edge_options.add_argument("--headless=chrome")
3383
3425
  else:
3384
3426
  pass # Will need Xvfb on Linux
3385
- except Exception:
3386
- pass
3387
3427
  elif headless:
3388
3428
  if "--headless" not in edge_options.arguments:
3389
3429
  edge_options.add_argument("--headless")
@@ -3408,20 +3448,49 @@ def get_local_driver(
3408
3448
  edge_options.add_experimental_option(
3409
3449
  "mobileEmulation", emulator_settings
3410
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
3411
3468
  if headless or headless2:
3412
- edge_options.add_argument(
3413
- "--window-size=%s,%s" % (
3414
- settings.HEADLESS_START_WIDTH,
3415
- 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
+ )
3416
3480
  )
3417
- )
3418
3481
  else:
3419
- edge_options.add_argument(
3420
- "--window-size=%s,%s" % (
3421
- settings.CHROME_START_WIDTH,
3422
- 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
+ )
3423
3493
  )
3424
- )
3425
3494
  if user_data_dir and not is_using_uc(undetectable, browser_name):
3426
3495
  abs_path = os.path.abspath(user_data_dir)
3427
3496
  edge_options.add_argument("--user-data-dir=%s" % abs_path)
@@ -3555,7 +3624,11 @@ def get_local_driver(
3555
3624
  set_binary = False
3556
3625
  if chromium_arg:
3557
3626
  # Can be a comma-separated list of Chromium args
3558
- 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(",")
3559
3632
  for chromium_arg_item in chromium_arg_list:
3560
3633
  chromium_arg_item = chromium_arg_item.strip()
3561
3634
  if not chromium_arg_item.startswith("--"):
@@ -3650,19 +3723,15 @@ def get_local_driver(
3650
3723
  constants.MultiBrowser.DRIVER_FIXING_LOCK
3651
3724
  )
3652
3725
  with edgedriver_fixing_lock:
3653
- try:
3726
+ with suppress(Exception):
3654
3727
  if not _was_driver_repaired():
3655
3728
  _repair_edgedriver(edge_version)
3656
3729
  _mark_driver_repaired()
3657
- except Exception:
3658
- pass
3659
3730
  else:
3660
- try:
3731
+ with suppress(Exception):
3661
3732
  if not _was_driver_repaired():
3662
3733
  _repair_edgedriver(edge_version)
3663
3734
  _mark_driver_repaired()
3664
- except Exception:
3665
- pass
3666
3735
  driver = Edge(service=service, options=edge_options)
3667
3736
  return extend_driver(driver)
3668
3737
  elif browser_name == constants.Browser.SAFARI:
@@ -3814,7 +3883,7 @@ def get_local_driver(
3814
3883
  ch_driver_version = None
3815
3884
  path_chromedriver = chromedriver_on_path()
3816
3885
  if os.path.exists(LOCAL_CHROMEDRIVER):
3817
- try:
3886
+ with suppress(Exception):
3818
3887
  output = subprocess.check_output(
3819
3888
  '"%s" --version' % LOCAL_CHROMEDRIVER, shell=True
3820
3889
  )
@@ -3828,8 +3897,6 @@ def get_local_driver(
3828
3897
  ch_driver_version = output
3829
3898
  if driver_version == "keep":
3830
3899
  driver_version = ch_driver_version
3831
- except Exception:
3832
- pass
3833
3900
  elif path_chromedriver:
3834
3901
  try:
3835
3902
  make_driver_executable_if_not(path_chromedriver)
@@ -3838,7 +3905,7 @@ def get_local_driver(
3838
3905
  "\nWarning: Could not make chromedriver"
3839
3906
  " executable: %s" % e
3840
3907
  )
3841
- try:
3908
+ with suppress(Exception):
3842
3909
  output = subprocess.check_output(
3843
3910
  '"%s" --version' % path_chromedriver, shell=True
3844
3911
  )
@@ -3852,8 +3919,6 @@ def get_local_driver(
3852
3919
  ch_driver_version = output
3853
3920
  if driver_version == "keep":
3854
3921
  use_version = ch_driver_version
3855
- except Exception:
3856
- pass
3857
3922
  disable_build_check = True
3858
3923
  uc_driver_version = None
3859
3924
  if is_using_uc(undetectable, browser_name):
@@ -4046,7 +4111,7 @@ def get_local_driver(
4046
4111
  if IS_ARM_MAC and use_uc:
4047
4112
  intel_for_uc = True # Use Intel driver for UC Mode
4048
4113
  if os.path.exists(LOCAL_CHROMEDRIVER):
4049
- try:
4114
+ with suppress(Exception):
4050
4115
  output = subprocess.check_output(
4051
4116
  '"%s" --version' % LOCAL_CHROMEDRIVER,
4052
4117
  shell=True,
@@ -4059,8 +4124,6 @@ def get_local_driver(
4059
4124
  output = full_ch_driver_version.split(".")[0]
4060
4125
  if int(output) >= 2:
4061
4126
  ch_driver_version = output
4062
- except Exception:
4063
- pass
4064
4127
  if (
4065
4128
  (
4066
4129
  not use_uc
@@ -4198,7 +4261,7 @@ def get_local_driver(
4198
4261
  chrome_options.add_argument(
4199
4262
  "--user-agent=%s" % user_agent
4200
4263
  )
4201
- try:
4264
+ with suppress(Exception):
4202
4265
  if (
4203
4266
  (
4204
4267
  not user_agent
@@ -4304,7 +4367,7 @@ def get_local_driver(
4304
4367
  service=service,
4305
4368
  options=headless_options,
4306
4369
  )
4307
- try:
4370
+ with suppress(Exception):
4308
4371
  user_agent = driver.execute_script(
4309
4372
  "return navigator.userAgent;"
4310
4373
  )
@@ -4326,11 +4389,7 @@ def get_local_driver(
4326
4389
  "--user-agent=%s" % user_agent
4327
4390
  )
4328
4391
  sb_config.uc_agent_cache = user_agent
4329
- except Exception:
4330
- pass
4331
4392
  driver.quit()
4332
- except Exception:
4333
- pass
4334
4393
  uc_path = None
4335
4394
  if os.path.exists(LOCAL_UC_DRIVER):
4336
4395
  uc_path = LOCAL_UC_DRIVER
@@ -4653,13 +4712,11 @@ def get_local_driver(
4653
4712
  "mobile": True
4654
4713
  }
4655
4714
  )
4656
- try:
4715
+ with suppress(Exception):
4657
4716
  driver.execute_cdp_cmd(
4658
4717
  'Emulation.setDeviceMetricsOverride',
4659
4718
  set_device_metrics_override
4660
4719
  )
4661
- except Exception:
4662
- pass
4663
4720
  return extend_driver(driver)
4664
4721
  else: # Running headless on Linux (and not using --uc)
4665
4722
  try:
@@ -4705,23 +4762,19 @@ def get_local_driver(
4705
4762
  )
4706
4763
  with chromedr_fixing_lock:
4707
4764
  if not _was_driver_repaired():
4708
- try:
4765
+ with suppress(Exception):
4709
4766
  _repair_chromedriver(
4710
4767
  chrome_options, chrome_options, mcv
4711
4768
  )
4712
4769
  _mark_driver_repaired()
4713
- except Exception:
4714
- pass
4715
4770
  else:
4716
4771
  if not _was_driver_repaired():
4717
- try:
4772
+ with suppress(Exception):
4718
4773
  _repair_chromedriver(
4719
4774
  chrome_options, chrome_options, mcv
4720
4775
  )
4721
- except Exception:
4722
- pass
4723
4776
  _mark_driver_repaired()
4724
- try:
4777
+ with suppress(Exception):
4725
4778
  service = ChromeService(
4726
4779
  log_output=os.devnull,
4727
4780
  service_args=["--disable-build-check"],
@@ -4731,8 +4784,6 @@ def get_local_driver(
4731
4784
  options=chrome_options,
4732
4785
  )
4733
4786
  return extend_driver(driver)
4734
- except Exception:
4735
- pass
4736
4787
  # Use the virtual display on Linux during headless errors
4737
4788
  logging.debug(
4738
4789
  "\nWarning: Chrome failed to launch in"
@@ -4753,14 +4804,12 @@ def get_local_driver(
4753
4804
  if is_using_uc(undetectable, browser_name):
4754
4805
  raise
4755
4806
  # Try again if Chrome didn't launch
4756
- try:
4807
+ with suppress(Exception):
4757
4808
  service = ChromeService(service_args=["--disable-build-check"])
4758
4809
  driver = webdriver.Chrome(
4759
4810
  service=service, options=chrome_options
4760
4811
  )
4761
4812
  return extend_driver(driver)
4762
- except Exception:
4763
- pass
4764
4813
  if user_data_dir:
4765
4814
  print("\nUnable to set user_data_dir while starting Chrome!\n")
4766
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
  )