seleniumbase 4.31.0__py3-none-any.whl → 4.31.2__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.
@@ -1,2 +1,2 @@
1
1
  # seleniumbase package
2
- __version__ = "4.31.0"
2
+ __version__ = "4.31.2"
@@ -44,8 +44,9 @@ behave -D agent="User Agent String" -D demo
44
44
  -D sjw (Skip JS Waits for readyState to be "complete" or Angular to load.)
45
45
  -D wfa (Wait for AngularJS to be done loading after specific web actions.)
46
46
  -D pls=PLS (Set pageLoadStrategy on Chrome: "normal", "eager", or "none".)
47
- -D headless (Run tests in headless mode. The default arg on Linux OS.)
48
- -D headless2 (Use the new headless mode, which supports extensions.)
47
+ -D headless (The default headless mode. Linux uses this mode by default.)
48
+ -D headless1 (Use Chrome's old headless mode. Fast, but has limitations.)
49
+ -D headless2 (Use Chrome's new headless mode, which supports extensions.)
49
50
  -D headed (Run tests in headed/GUI mode on Linux OS, where not default.)
50
51
  -D xvfb (Run tests using the Xvfb virtual display server on Linux OS.)
51
52
  -D xvfb-metrics=STRING (Set Xvfb display size on Linux: "Width,Height".)
@@ -70,7 +71,8 @@ behave -D agent="User Agent String" -D demo
70
71
  -D rec-behave (Same as Recorder Mode, but also generates behave-gherkin.)
71
72
  -D rec-sleep (If the Recorder is enabled, also records self.sleep calls.)
72
73
  -D rec-print (If the Recorder is enabled, prints output after tests end.)
73
- -D disable-js (Disable JavaScript on Chromium. May break websites!)
74
+ -D disable-cookies (Disable Cookies on websites. Pages might break!)
75
+ -D disable-js (Disable JavaScript on websites. Pages might break!)
74
76
  -D disable-csp (Disable the Content Security Policy of websites.)
75
77
  -D disable-ws (Disable Web Security on Chromium-based browsers.)
76
78
  -D enable-ws (Enable Web Security on Chromium-based browsers.)
@@ -144,6 +146,7 @@ def get_configured_sb(context):
144
146
  sb.browser = "chrome"
145
147
  sb.is_behave = True
146
148
  sb.headless = False
149
+ sb.headless1 = False
147
150
  sb.headless2 = False
148
151
  sb.headless_active = False
149
152
  sb.headed = False
@@ -178,6 +181,7 @@ def get_configured_sb(context):
178
181
  sb.database_env = "test"
179
182
  sb.log_path = constants.Logs.LATEST + os.sep
180
183
  sb.archive_logs = False
184
+ sb.disable_cookies = False
181
185
  sb.disable_js = False
182
186
  sb.disable_csp = False
183
187
  sb.disable_ws = False
@@ -296,6 +300,11 @@ def get_configured_sb(context):
296
300
  sb.headless = True
297
301
  continue
298
302
  # Handle: -D headless2
303
+ if low_key == "headless1":
304
+ sb.headless1 = True
305
+ sb.headless = True
306
+ continue
307
+ # Handle: -D headless2
299
308
  if low_key == "headless2":
300
309
  sb.headless2 = True
301
310
  continue
@@ -528,6 +537,10 @@ def get_configured_sb(context):
528
537
  if low_key in ["archive-logs", "archive_logs"]:
529
538
  sb.archive_logs = True
530
539
  continue
540
+ # Handle: -D disable-cookies / disable_cookies
541
+ if low_key in ["disable-cookies", "disable_cookies"]:
542
+ sb.disable_cookies = True
543
+ continue
531
544
  # Handle: -D disable-js / disable_js
532
545
  if low_key in ["disable-js", "disable_js"]:
533
546
  sb.disable_js = True
@@ -864,6 +877,7 @@ def get_configured_sb(context):
864
877
  # Recorder Mode can still optimize scripts in "-D headless2" mode.
865
878
  if sb.recorder_ext and sb.headless:
866
879
  sb.headless = False
880
+ sb.headless1 = False
867
881
  sb.headless2 = True
868
882
  if sb.headless2 and sb.browser == "firefox":
869
883
  sb.headless2 = False # Only for Chromium browsers
@@ -900,11 +914,13 @@ def get_configured_sb(context):
900
914
  # Recorder Mode can still optimize scripts in --headless2 mode.
901
915
  if sb.recorder_mode and sb.headless:
902
916
  sb.headless = False
917
+ sb.headless1 = False
903
918
  sb.headless2 = True
904
919
  if not sb.headless and not sb.headless2:
905
920
  sb.headed = True
906
921
  if sb.browser == "safari" and sb.headless:
907
922
  sb.headless = False # Safari doesn't support headless mode
923
+ sb.headless1 = False
908
924
  if sb.save_screenshot_after_test and sb.no_screenshot_after_test:
909
925
  sb.save_screenshot_after_test = False # "no_screenshot" has priority
910
926
  if sb.servername != "localhost":
@@ -995,6 +1011,7 @@ def get_configured_sb(context):
995
1011
  sb_config.pdb_option = sb.pdb_option
996
1012
  sb_config.rec_behave = sb.rec_behave
997
1013
  sb_config.rec_print = sb.rec_print
1014
+ sb_config.disable_cookies = sb.disable_cookies
998
1015
  sb_config.disable_js = sb.disable_js
999
1016
  sb_config.disable_csp = sb.disable_csp
1000
1017
  sb_config.record_sleep = sb.record_sleep
@@ -3,7 +3,9 @@
3
3
  http://www.patorjk.com/software/taag/#p=display&f=Slant&t=SeleniumBase """
4
4
 
5
5
  import colorama
6
+ import os
6
7
  import sys
8
+ from contextlib import suppress
7
9
 
8
10
  r"""
9
11
  ______ __ _ ____
@@ -66,4 +68,49 @@ def get_seleniumbase_logo():
66
68
  sb += " "
67
69
  sb += cr
68
70
  sb += cr
71
+ with suppress(Exception):
72
+ terminal_width = os.get_terminal_size().columns
73
+ if isinstance(terminal_width, int) and terminal_width >= 66:
74
+ return sb
75
+
76
+ # If the logo is wider than the screen width, use a smaller one:
77
+ r"""
78
+ ___ _ _ ___
79
+ / __| ___| |___ _ _ (_)_ _ _ __ | _ ) __ _ ______
80
+ \__ \/ -_) / -_) ' \| | \| | ' \ | _ \/ _` (_-< -_)
81
+ |___/\___|_\___|_||_|_|\_,_|_|_|_\|___/\__,_/__|___|
82
+ """
83
+ sb = " "
84
+ sb += cr
85
+ sb += "\n"
86
+ sb += c1
87
+ sb += " ___ _ _ "
88
+ sb += c2
89
+ sb += " ___ "
90
+ sb += cr
91
+ sb += "\n"
92
+ sb += c1
93
+ sb += "/ __| ___| |___ _ _ (_)_ _ _ __ "
94
+ sb += c2
95
+ sb += "| _ ) __ _ ______ "
96
+ sb += cr
97
+ sb += "\n"
98
+ sb += c1
99
+ sb += "\\__ \\/ -_) / -_) ' \\| | \\| | ' \\ "
100
+ sb += c2
101
+ sb += "| _ \\/ _` (_-< -_)"
102
+ sb += cr
103
+ sb += "\n"
104
+ sb += c1
105
+ sb += "|___/\\___|_\\___|_||_|_|\\_,_|_|_|_\\"
106
+ sb += c2
107
+ sb += "|___/\\__,_/__|___|"
108
+ sb += cr
109
+ sb += "\n"
110
+ sb += c3
111
+ sb += " "
112
+ sb += c4
113
+ sb += " "
114
+ sb += cr
115
+ sb += cr
69
116
  return sb
@@ -54,8 +54,8 @@ else:
54
54
  def show_usage():
55
55
  show_basic_usage()
56
56
  sc = ""
57
- sc += ' Type "sbase help [COMMAND]" for specific command info.\n'
58
- sc += ' For info on all commands, type: "seleniumbase --help".\n'
57
+ sc += ' Type "sbase help [COMMAND]" for specific info.\n'
58
+ sc += ' For all commands, type: "seleniumbase --help".\n'
59
59
  sc += ' Use "pytest" for running tests.\n'
60
60
  if "linux" not in sys.platform:
61
61
  c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
@@ -76,12 +76,15 @@ def show_basic_usage():
76
76
 
77
77
  seleniumbase_logo = logo_helper.get_seleniumbase_logo()
78
78
  print(seleniumbase_logo)
79
+ time.sleep(0.044)
79
80
  print("")
80
- time.sleep(0.28) # Enough time to see the logo
81
+ time.sleep(0.033)
81
82
  show_package_location()
83
+ time.sleep(0.032)
82
84
  show_version_info()
85
+ time.sleep(0.031)
83
86
  print("")
84
- time.sleep(0.62) # Enough time to see the version
87
+ time.sleep(0.68) # Enough time to see the logo & version
85
88
  sc = ""
86
89
  sc += ' * USAGE: "seleniumbase [COMMAND] [PARAMETERS]"\n'
87
90
  sc += ' * OR: "sbase [COMMAND] [PARAMETERS]"\n'
@@ -203,6 +203,8 @@ def extend_driver(driver):
203
203
  driver.is_exact_text_visible = DM.is_exact_text_visible
204
204
  driver.is_attribute_present = DM.is_attribute_present
205
205
  driver.is_non_empty_text_visible = DM.is_non_empty_text_visible
206
+ driver.is_valid_url = DM.is_valid_url
207
+ driver.is_alert_present = DM.is_alert_present
206
208
  driver.is_online = DM.is_online
207
209
  driver.js_click = DM.js_click
208
210
  driver.get_text = DM.get_text
@@ -1542,6 +1544,7 @@ def _set_chrome_options(
1542
1544
  multi_proxy,
1543
1545
  user_agent,
1544
1546
  recorder_ext,
1547
+ disable_cookies,
1545
1548
  disable_js,
1546
1549
  disable_csp,
1547
1550
  enable_ws,
@@ -1553,6 +1556,7 @@ def _set_chrome_options(
1553
1556
  log_cdp_events,
1554
1557
  no_sandbox,
1555
1558
  disable_gpu,
1559
+ headless1,
1556
1560
  headless2,
1557
1561
  incognito,
1558
1562
  guest_mode,
@@ -1618,6 +1622,8 @@ def _set_chrome_options(
1618
1622
  prefs["intl.accept_languages"] = locale_code
1619
1623
  if block_images:
1620
1624
  prefs["profile.managed_default_content_settings.images"] = 2
1625
+ if disable_cookies:
1626
+ prefs["profile.default_content_setting_values.cookies"] = 2
1621
1627
  if disable_js:
1622
1628
  prefs["profile.managed_default_content_settings.javascript"] = 2
1623
1629
  if do_not_track:
@@ -1771,7 +1777,10 @@ def _set_chrome_options(
1771
1777
  pass # Processed After Version Check
1772
1778
  elif headless:
1773
1779
  if not undetectable:
1774
- chrome_options.add_argument("--headless")
1780
+ if headless1:
1781
+ chrome_options.add_argument("--headless=old")
1782
+ else:
1783
+ chrome_options.add_argument("--headless")
1775
1784
  if undetectable and servername and servername != "localhost":
1776
1785
  # The Grid Node will need Chrome 109 or newer
1777
1786
  chrome_options.add_argument("--headless=new")
@@ -2010,6 +2019,7 @@ def _set_firefox_options(
2010
2019
  proxy_bypass_list,
2011
2020
  proxy_pac_url,
2012
2021
  user_agent,
2022
+ disable_cookies,
2013
2023
  disable_js,
2014
2024
  disable_csp,
2015
2025
  firefox_arg,
@@ -2083,6 +2093,8 @@ def _set_firefox_options(
2083
2093
  "security.mixed_content.block_active_content", False
2084
2094
  )
2085
2095
  options.set_preference("security.warn_submit_insecure", False)
2096
+ if disable_cookies:
2097
+ options.set_preference("network.cookie.cookieBehavior", 2)
2086
2098
  if disable_js:
2087
2099
  options.set_preference("javascript.enabled", False)
2088
2100
  if settings.DISABLE_CSP_ON_FIREFOX or disable_csp:
@@ -2182,6 +2194,7 @@ def get_driver(
2182
2194
  cap_file=None,
2183
2195
  cap_string=None,
2184
2196
  recorder_ext=False,
2197
+ disable_cookies=False,
2185
2198
  disable_js=False,
2186
2199
  disable_csp=False,
2187
2200
  enable_ws=False,
@@ -2193,6 +2206,7 @@ def get_driver(
2193
2206
  log_cdp_events=False,
2194
2207
  no_sandbox=False,
2195
2208
  disable_gpu=False,
2209
+ headless1=False,
2196
2210
  headless2=False,
2197
2211
  incognito=False,
2198
2212
  guest_mode=False,
@@ -2341,6 +2355,7 @@ def get_driver(
2341
2355
  headless
2342
2356
  and (
2343
2357
  proxy_auth
2358
+ or disable_cookies
2344
2359
  or disable_js
2345
2360
  or ad_block_on
2346
2361
  or disable_csp
@@ -2395,6 +2410,7 @@ def get_driver(
2395
2410
  cap_file,
2396
2411
  cap_string,
2397
2412
  recorder_ext,
2413
+ disable_cookies,
2398
2414
  disable_js,
2399
2415
  disable_csp,
2400
2416
  enable_ws,
@@ -2406,6 +2422,7 @@ def get_driver(
2406
2422
  log_cdp_events,
2407
2423
  no_sandbox,
2408
2424
  disable_gpu,
2425
+ headless1,
2409
2426
  headless2,
2410
2427
  incognito,
2411
2428
  guest_mode,
@@ -2451,6 +2468,7 @@ def get_driver(
2451
2468
  multi_proxy,
2452
2469
  user_agent,
2453
2470
  recorder_ext,
2471
+ disable_cookies,
2454
2472
  disable_js,
2455
2473
  disable_csp,
2456
2474
  enable_ws,
@@ -2462,6 +2480,7 @@ def get_driver(
2462
2480
  log_cdp_events,
2463
2481
  no_sandbox,
2464
2482
  disable_gpu,
2483
+ headless1,
2465
2484
  headless2,
2466
2485
  incognito,
2467
2486
  guest_mode,
@@ -2511,6 +2530,7 @@ def get_remote_driver(
2511
2530
  cap_file,
2512
2531
  cap_string,
2513
2532
  recorder_ext,
2533
+ disable_cookies,
2514
2534
  disable_js,
2515
2535
  disable_csp,
2516
2536
  enable_ws,
@@ -2522,6 +2542,7 @@ def get_remote_driver(
2522
2542
  log_cdp_events,
2523
2543
  no_sandbox,
2524
2544
  disable_gpu,
2545
+ headless1,
2525
2546
  headless2,
2526
2547
  incognito,
2527
2548
  guest_mode,
@@ -2646,6 +2667,7 @@ def get_remote_driver(
2646
2667
  multi_proxy,
2647
2668
  user_agent,
2648
2669
  recorder_ext,
2670
+ disable_cookies,
2649
2671
  disable_js,
2650
2672
  disable_csp,
2651
2673
  enable_ws,
@@ -2657,6 +2679,7 @@ def get_remote_driver(
2657
2679
  log_cdp_events,
2658
2680
  no_sandbox,
2659
2681
  disable_gpu,
2682
+ headless1,
2660
2683
  headless2,
2661
2684
  incognito,
2662
2685
  guest_mode,
@@ -2740,6 +2763,7 @@ def get_remote_driver(
2740
2763
  proxy_bypass_list,
2741
2764
  proxy_pac_url,
2742
2765
  user_agent,
2766
+ disable_cookies,
2743
2767
  disable_js,
2744
2768
  disable_csp,
2745
2769
  firefox_arg,
@@ -2818,6 +2842,7 @@ def get_remote_driver(
2818
2842
  multi_proxy,
2819
2843
  user_agent,
2820
2844
  recorder_ext,
2845
+ disable_cookies,
2821
2846
  disable_js,
2822
2847
  disable_csp,
2823
2848
  enable_ws,
@@ -2829,6 +2854,7 @@ def get_remote_driver(
2829
2854
  log_cdp_events,
2830
2855
  no_sandbox,
2831
2856
  disable_gpu,
2857
+ headless1,
2832
2858
  headless2,
2833
2859
  incognito,
2834
2860
  guest_mode,
@@ -2937,6 +2963,7 @@ def get_local_driver(
2937
2963
  multi_proxy,
2938
2964
  user_agent,
2939
2965
  recorder_ext,
2966
+ disable_cookies,
2940
2967
  disable_js,
2941
2968
  disable_csp,
2942
2969
  enable_ws,
@@ -2948,6 +2975,7 @@ def get_local_driver(
2948
2975
  log_cdp_events,
2949
2976
  no_sandbox,
2950
2977
  disable_gpu,
2978
+ headless1,
2951
2979
  headless2,
2952
2980
  incognito,
2953
2981
  guest_mode,
@@ -3017,6 +3045,7 @@ def get_local_driver(
3017
3045
  proxy_bypass_list,
3018
3046
  proxy_pac_url,
3019
3047
  user_agent,
3048
+ disable_cookies,
3020
3049
  disable_js,
3021
3050
  disable_csp,
3022
3051
  firefox_arg,
@@ -3373,6 +3402,8 @@ def get_local_driver(
3373
3402
  prefs["intl.accept_languages"] = locale_code
3374
3403
  if block_images:
3375
3404
  prefs["profile.managed_default_content_settings.images"] = 2
3405
+ if disable_cookies:
3406
+ prefs["profile.default_content_setting_values.cookies"] = 2
3376
3407
  if disable_js:
3377
3408
  prefs["profile.managed_default_content_settings.javascript"] = 2
3378
3409
  if do_not_track:
@@ -3425,8 +3456,14 @@ def get_local_driver(
3425
3456
  else:
3426
3457
  pass # Will need Xvfb on Linux
3427
3458
  elif headless:
3428
- if "--headless" not in edge_options.arguments:
3429
- edge_options.add_argument("--headless")
3459
+ if (
3460
+ "--headless" not in edge_options.arguments
3461
+ and "--headless=old" not in edge_options.arguments
3462
+ ):
3463
+ if headless1:
3464
+ edge_options.add_argument("--headless=old")
3465
+ else:
3466
+ edge_options.add_argument("--headless")
3430
3467
  if mobile_emulator and not is_using_uc(undetectable, browser_name):
3431
3468
  emulator_settings = {}
3432
3469
  device_metrics = {}
@@ -3777,6 +3814,7 @@ def get_local_driver(
3777
3814
  multi_proxy,
3778
3815
  user_agent,
3779
3816
  recorder_ext,
3817
+ disable_cookies,
3780
3818
  disable_js,
3781
3819
  disable_csp,
3782
3820
  enable_ws,
@@ -3788,6 +3826,7 @@ def get_local_driver(
3788
3826
  log_cdp_events,
3789
3827
  no_sandbox,
3790
3828
  disable_gpu,
3829
+ headless1,
3791
3830
  headless2,
3792
3831
  incognito,
3793
3832
  guest_mode,
@@ -3960,8 +3999,14 @@ def get_local_driver(
3960
3999
  except Exception:
3961
4000
  pass # Will need Xvfb on Linux
3962
4001
  elif headless:
3963
- if "--headless" not in chrome_options.arguments:
3964
- chrome_options.add_argument("--headless")
4002
+ if (
4003
+ "--headless" not in chrome_options.arguments
4004
+ and "--headless=old" not in chrome_options.arguments
4005
+ ):
4006
+ if headless1:
4007
+ chrome_options.add_argument("--headless=old")
4008
+ else:
4009
+ chrome_options.add_argument("--headless")
3965
4010
  if LOCAL_CHROMEDRIVER and os.path.exists(LOCAL_CHROMEDRIVER):
3966
4011
  try:
3967
4012
  make_driver_executable_if_not(LOCAL_CHROMEDRIVER)
@@ -4227,6 +4272,12 @@ def get_local_driver(
4227
4272
  chrome_options.arguments.remove(
4228
4273
  "--headless"
4229
4274
  )
4275
+ if "--headless=old" in (
4276
+ chrome_options.arguments
4277
+ ):
4278
+ chrome_options.arguments.remove(
4279
+ "--headless=old"
4280
+ )
4230
4281
  uc_chrome_version = None
4231
4282
  if (
4232
4283
  use_version.isnumeric()
@@ -4289,6 +4340,7 @@ def get_local_driver(
4289
4340
  None, # multi_proxy
4290
4341
  None, # user_agent
4291
4342
  None, # recorder_ext
4343
+ disable_cookies,
4292
4344
  disable_js,
4293
4345
  disable_csp,
4294
4346
  enable_ws,
@@ -4300,6 +4352,7 @@ def get_local_driver(
4300
4352
  False, # log_cdp_events
4301
4353
  no_sandbox,
4302
4354
  disable_gpu,
4355
+ False, # headless1
4303
4356
  False, # headless2
4304
4357
  incognito,
4305
4358
  guest_mode,
@@ -4530,6 +4583,7 @@ def get_local_driver(
4530
4583
  None, # multi_proxy
4531
4584
  None, # user_agent
4532
4585
  None, # recorder_ext
4586
+ disable_cookies,
4533
4587
  disable_js,
4534
4588
  disable_csp,
4535
4589
  enable_ws,
@@ -4541,6 +4595,7 @@ def get_local_driver(
4541
4595
  False, # log_cdp_events
4542
4596
  no_sandbox,
4543
4597
  disable_gpu,
4598
+ False, # headless1
4544
4599
  False, # headless2
4545
4600
  incognito,
4546
4601
  guest_mode,
@@ -4792,6 +4847,8 @@ def get_local_driver(
4792
4847
  )
4793
4848
  if "--headless" in chrome_options.arguments:
4794
4849
  chrome_options.arguments.remove("--headless")
4850
+ if "--headless=old" in chrome_options.arguments:
4851
+ chrome_options.arguments.remove("--headless=old")
4795
4852
  service = ChromeService(
4796
4853
  log_output=os.devnull,
4797
4854
  service_args=["--disable-build-check"]
@@ -161,6 +161,17 @@ class DriverMethods():
161
161
  self.driver, *args, **kwargs
162
162
  )
163
163
 
164
+ def is_valid_url(self, url):
165
+ """Return True if the url is a valid url."""
166
+ return page_utils.is_valid_url(url)
167
+
168
+ def is_alert_present(self):
169
+ try:
170
+ self.driver.switch_to.alert
171
+ return True
172
+ except Exception:
173
+ return False
174
+
164
175
  def is_online(self):
165
176
  return self.driver.execute_script("return navigator.onLine;")
166
177
 
@@ -3760,6 +3760,7 @@ class BaseCase(unittest.TestCase):
3760
3760
  cap_file=None,
3761
3761
  cap_string=None,
3762
3762
  recorder_ext=None,
3763
+ disable_cookies=None,
3763
3764
  disable_js=None,
3764
3765
  disable_csp=None,
3765
3766
  enable_ws=None,
@@ -3771,6 +3772,7 @@ class BaseCase(unittest.TestCase):
3771
3772
  log_cdp_events=None,
3772
3773
  no_sandbox=None,
3773
3774
  disable_gpu=None,
3775
+ headless1=None,
3774
3776
  headless2=None,
3775
3777
  incognito=None,
3776
3778
  guest_mode=None,
@@ -3819,6 +3821,7 @@ class BaseCase(unittest.TestCase):
3819
3821
  cap_file - the file containing desired capabilities for the browser
3820
3822
  cap_string - the string with desired capabilities for the browser
3821
3823
  recorder_ext - the option to enable the SBase Recorder extension
3824
+ disable_cookies - the option to disable Cookies (May break things!)
3822
3825
  disable_js - the option to disable JavaScript (May break websites!)
3823
3826
  disable_csp - an option to disable Chrome's Content Security Policy
3824
3827
  enable_ws - the option to enable the Web Security feature (Chrome)
@@ -3830,6 +3833,7 @@ class BaseCase(unittest.TestCase):
3830
3833
  log_cdp_events - capture {"performance": "ALL", "browser": "ALL"})
3831
3834
  no_sandbox - the option to enable the "No-Sandbox" feature (Chrome)
3832
3835
  disable_gpu - the option to enable Chrome's "Disable GPU" feature
3836
+ headless1 - the option to use the older headless mode (Chromium)
3833
3837
  headless2 - the option to use the newer headless mode (Chromium)
3834
3838
  incognito - the option to enable Chrome's Incognito mode (Chrome)
3835
3839
  guest_mode - the option to enable Chrome's Guest mode (Chrome)
@@ -3916,6 +3920,8 @@ class BaseCase(unittest.TestCase):
3916
3920
  user_agent = self.user_agent
3917
3921
  if recorder_ext is None:
3918
3922
  recorder_ext = self.recorder_ext
3923
+ if disable_cookies is None:
3924
+ disable_cookies = self.disable_cookies
3919
3925
  if disable_js is None:
3920
3926
  disable_js = self.disable_js
3921
3927
  if disable_csp is None:
@@ -3938,6 +3944,8 @@ class BaseCase(unittest.TestCase):
3938
3944
  no_sandbox = self.no_sandbox
3939
3945
  if disable_gpu is None:
3940
3946
  disable_gpu = self.disable_gpu
3947
+ if headless1 is None:
3948
+ headless1 = self.headless1
3941
3949
  if headless2 is None:
3942
3950
  headless2 = self.headless2
3943
3951
  if incognito is None:
@@ -4025,6 +4033,7 @@ class BaseCase(unittest.TestCase):
4025
4033
  cap_file=cap_file,
4026
4034
  cap_string=cap_string,
4027
4035
  recorder_ext=recorder_ext,
4036
+ disable_cookies=disable_cookies,
4028
4037
  disable_js=disable_js,
4029
4038
  disable_csp=disable_csp,
4030
4039
  enable_ws=enable_ws,
@@ -4036,6 +4045,7 @@ class BaseCase(unittest.TestCase):
4036
4045
  log_cdp_events=log_cdp_events,
4037
4046
  no_sandbox=no_sandbox,
4038
4047
  disable_gpu=disable_gpu,
4048
+ headless1=headless1,
4039
4049
  headless2=headless2,
4040
4050
  incognito=incognito,
4041
4051
  guest_mode=guest_mode,
@@ -7808,6 +7818,13 @@ class BaseCase(unittest.TestCase):
7808
7818
  """Return True if the url is a valid url."""
7809
7819
  return page_utils.is_valid_url(url)
7810
7820
 
7821
+ def is_alert_present(self):
7822
+ try:
7823
+ self.driver.switch_to.alert
7824
+ return True
7825
+ except Exception:
7826
+ return False
7827
+
7811
7828
  def is_online(self):
7812
7829
  """Return True if connected to the Internet."""
7813
7830
  return self.execute_script("return navigator.onLine;")
@@ -14324,6 +14341,10 @@ class BaseCase(unittest.TestCase):
14324
14341
  self.env = self.environment # Add a shortened version
14325
14342
  self.with_selenium = sb_config.with_selenium # Should be True
14326
14343
  self.headless = sb_config.headless
14344
+ self.headless1 = sb_config.headless1
14345
+ if self.headless1:
14346
+ self.headless = True
14347
+ self.headless2 = sb_config.headless2
14327
14348
  self.headless_active = False
14328
14349
  sb_config.headless_active = False
14329
14350
  self.headed = sb_config.headed
@@ -14378,6 +14399,7 @@ class BaseCase(unittest.TestCase):
14378
14399
  elif self.record_sleep and not self.recorder_mode:
14379
14400
  self.recorder_mode = True
14380
14401
  self.recorder_ext = True
14402
+ self.disable_cookies = sb_config.disable_cookies
14381
14403
  self.disable_js = sb_config.disable_js
14382
14404
  self.disable_csp = sb_config.disable_csp
14383
14405
  self.disable_ws = sb_config.disable_ws
@@ -14392,7 +14414,6 @@ class BaseCase(unittest.TestCase):
14392
14414
  self.log_cdp_events = sb_config.log_cdp_events
14393
14415
  self.no_sandbox = sb_config.no_sandbox
14394
14416
  self.disable_gpu = sb_config.disable_gpu
14395
- self.headless2 = sb_config.headless2
14396
14417
  self.incognito = sb_config.incognito
14397
14418
  self.guest_mode = sb_config.guest_mode
14398
14419
  self.dark_mode = sb_config.dark_mode
@@ -14757,6 +14778,7 @@ class BaseCase(unittest.TestCase):
14757
14778
  cap_file=self.cap_file,
14758
14779
  cap_string=self.cap_string,
14759
14780
  recorder_ext=self.recorder_ext,
14781
+ disable_cookies=self.disable_cookies,
14760
14782
  disable_js=self.disable_js,
14761
14783
  disable_csp=self.disable_csp,
14762
14784
  enable_ws=self.enable_ws,
@@ -14768,6 +14790,7 @@ class BaseCase(unittest.TestCase):
14768
14790
  log_cdp_events=self.log_cdp_events,
14769
14791
  no_sandbox=self.no_sandbox,
14770
14792
  disable_gpu=self.disable_gpu,
14793
+ headless1=self.headless1,
14771
14794
  headless2=self.headless2,
14772
14795
  incognito=self.incognito,
14773
14796
  guest_mode=self.guest_mode,
@@ -163,12 +163,15 @@ def is_valid_url(url):
163
163
  r"(?:/?|[/?]\S+)$",
164
164
  re.IGNORECASE,
165
165
  )
166
- return (
166
+ if (
167
167
  regex.match(url)
168
168
  or url.startswith((
169
169
  "about:", "blob:", "chrome:", "data:", "edge:", "file:"
170
170
  ))
171
- )
171
+ ):
172
+ return True
173
+ else:
174
+ return False
172
175
 
173
176
 
174
177
  def _get_unique_links(page_url, soup):