seleniumbase 4.31.6a4__py3-none-any.whl → 4.32.1__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,2 @@
1
1
  # seleniumbase package
2
- __version__ = "4.31.6a4"
2
+ __version__ = "4.32.1"
@@ -43,23 +43,24 @@ def print_runtime(description=None, limit=None):
43
43
  finally:
44
44
  end_time = time.time()
45
45
  run_time = end_time - start_time
46
+ name = description
46
47
  # Print times with a statistically significant number of decimal places
47
48
  if run_time < 0.0001:
48
- print(" {%s} ran for %.7f seconds." % (description, run_time))
49
+ print("<info> - {%s} ran for %.7f seconds." % (name, run_time))
49
50
  elif run_time < 0.001:
50
- print(" {%s} ran for %.6f seconds." % (description, run_time))
51
+ print("<info> - {%s} ran for %.6f seconds." % (name, run_time))
51
52
  elif run_time < 0.01:
52
- print(" {%s} ran for %.5f seconds." % (description, run_time))
53
+ print("<info> - {%s} ran for %.5f seconds." % (name, run_time))
53
54
  elif run_time < 0.1:
54
- print(" {%s} ran for %.4f seconds." % (description, run_time))
55
+ print("<info> - {%s} ran for %.4f seconds." % (name, run_time))
55
56
  elif run_time < 1:
56
- print(" {%s} ran for %.3f seconds." % (description, run_time))
57
+ print("<info> - {%s} ran for %.3f seconds." % (name, run_time))
57
58
  else:
58
- print(" {%s} ran for %.2f seconds." % (description, run_time))
59
+ print("<info> - {%s} ran for %.2f seconds." % (name, run_time))
59
60
  if limit and limit > 0 and run_time > limit:
60
61
  message = (
61
62
  "\n {%s} duration of %.2fs exceeded the time limit of %.2fs!"
62
- % (description, run_time, limit)
63
+ % (name, run_time, limit)
63
64
  )
64
65
  if exception:
65
66
  message = exception.msg + "\nAND " + message
@@ -811,7 +811,7 @@ def main(override=None, intel_for_uc=None, force_uc=None):
811
811
  zip_ref.extractall(downloads_folder)
812
812
  zip_ref.close()
813
813
  os.remove(zip_file_path)
814
- shutil.copyfile(driver_path, os.path.join(downloads_folder, filename))
814
+ shutil.copy3(driver_path, os.path.join(downloads_folder, filename))
815
815
  log_d("%sUnzip Complete!%s\n" % (c2, cr))
816
816
  to_remove = [
817
817
  "%s/%s/ruby_example/Gemfile" % (downloads_folder, h_ie_fn),
@@ -953,7 +953,7 @@ def main(override=None, intel_for_uc=None, force_uc=None):
953
953
  )
954
954
  if copy_to_path and os.path.exists(LOCAL_PATH):
955
955
  path_file = LOCAL_PATH + f_name
956
- shutil.copyfile(new_file, path_file)
956
+ shutil.copy2(new_file, path_file)
957
957
  make_executable(path_file)
958
958
  log_d("Also copied to: %s%s%s" % (c3, path_file, cr))
959
959
  log_d("")
@@ -1042,7 +1042,7 @@ def main(override=None, intel_for_uc=None, force_uc=None):
1042
1042
  )
1043
1043
  if copy_to_path and os.path.exists(LOCAL_PATH):
1044
1044
  path_file = LOCAL_PATH + f_name
1045
- shutil.copyfile(new_file, path_file)
1045
+ shutil.copy2(new_file, path_file)
1046
1046
  make_executable(path_file)
1047
1047
  log_d("Also copied to: %s%s%s" % (c3, path_file, cr))
1048
1048
  log_d("")
@@ -1078,7 +1078,7 @@ def main(override=None, intel_for_uc=None, force_uc=None):
1078
1078
  )
1079
1079
  if copy_to_path and os.path.exists(LOCAL_PATH):
1080
1080
  path_file = LOCAL_PATH + f_name
1081
- shutil.copyfile(new_file, path_file)
1081
+ shutil.copy2(new_file, path_file)
1082
1082
  make_executable(path_file)
1083
1083
  log_d("Also copied to: %s%s%s" % (c3, path_file, cr))
1084
1084
  log_d("")
@@ -29,6 +29,7 @@ from seleniumbase.core import detect_b_ver
29
29
  from seleniumbase.core import download_helper
30
30
  from seleniumbase.core import proxy_helper
31
31
  from seleniumbase.core import sb_driver
32
+ from seleniumbase.core import sb_cdp
32
33
  from seleniumbase.fixtures import constants
33
34
  from seleniumbase.fixtures import js_utils
34
35
  from seleniumbase.fixtures import page_actions
@@ -153,8 +154,10 @@ def extend_driver(driver):
153
154
  page.find_element = DM.find_element
154
155
  page.find_elements = DM.find_elements
155
156
  page.locator = DM.locator
157
+ page.get_current_url = DM.get_current_url
156
158
  page.get_page_source = DM.get_page_source
157
159
  page.get_title = DM.get_title
160
+ page.get_page_title = DM.get_title
158
161
  page.switch_to_default_window = DM.switch_to_default_window
159
162
  page.switch_to_newest_window = DM.switch_to_newest_window
160
163
  page.open_new_window = DM.open_new_window
@@ -206,6 +209,9 @@ def extend_driver(driver):
206
209
  driver.is_valid_url = DM.is_valid_url
207
210
  driver.is_alert_present = DM.is_alert_present
208
211
  driver.is_online = DM.is_online
212
+ driver.is_connected = DM.is_connected
213
+ driver.is_uc_mode_active = DM.is_uc_mode_active
214
+ driver.is_cdp_mode_active = DM.is_cdp_mode_active
209
215
  driver.js_click = DM.js_click
210
216
  driver.get_text = DM.get_text
211
217
  driver.get_active_element_css = DM.get_active_element_css
@@ -217,8 +223,10 @@ def extend_driver(driver):
217
223
  driver.highlight_if_visible = DM.highlight_if_visible
218
224
  driver.sleep = time.sleep
219
225
  driver.get_attribute = DM.get_attribute
226
+ driver.get_current_url = DM.get_current_url
220
227
  driver.get_page_source = DM.get_page_source
221
228
  driver.get_title = DM.get_title
229
+ driver.get_page_title = DM.get_title
222
230
  driver.switch_to_default_window = DM.switch_to_default_window
223
231
  driver.switch_to_newest_window = DM.switch_to_newest_window
224
232
  driver.open_new_window = DM.open_new_window
@@ -362,6 +370,11 @@ def has_captcha(text):
362
370
  return False
363
371
 
364
372
 
373
+ def __is_cdp_swap_needed(driver):
374
+ """If the driver is disconnected, use a CDP method when available."""
375
+ return shared_utils.is_cdp_swap_needed(driver)
376
+
377
+
365
378
  def uc_special_open_if_cf(
366
379
  driver,
367
380
  url,
@@ -432,10 +445,11 @@ def uc_special_open_if_cf(
432
445
 
433
446
 
434
447
  def uc_open(driver, url):
435
- if url.startswith("//"):
436
- url = "https:" + url
437
- elif ":" not in url:
438
- url = "https://" + url
448
+ url = shared_utils.fix_url_as_needed(url)
449
+ if __is_cdp_swap_needed(driver):
450
+ driver.cdp.get(url)
451
+ time.sleep(0.3)
452
+ return
439
453
  if (url.startswith("http:") or url.startswith("https:")):
440
454
  with driver:
441
455
  script = 'window.location.href = "%s";' % url
@@ -446,10 +460,11 @@ def uc_open(driver, url):
446
460
 
447
461
 
448
462
  def uc_open_with_tab(driver, url):
449
- if url.startswith("//"):
450
- url = "https:" + url
451
- elif ":" not in url:
452
- url = "https://" + url
463
+ url = shared_utils.fix_url_as_needed(url)
464
+ if __is_cdp_swap_needed(driver):
465
+ driver.cdp.get(url)
466
+ time.sleep(0.3)
467
+ return
453
468
  if (url.startswith("http:") or url.startswith("https:")):
454
469
  with driver:
455
470
  driver.execute_script('window.open("%s","_blank");' % url)
@@ -462,12 +477,13 @@ def uc_open_with_tab(driver, url):
462
477
 
463
478
  def uc_open_with_reconnect(driver, url, reconnect_time=None):
464
479
  """Open a url, disconnect chromedriver, wait, and reconnect."""
480
+ url = shared_utils.fix_url_as_needed(url)
481
+ if __is_cdp_swap_needed(driver):
482
+ driver.cdp.get(url)
483
+ time.sleep(0.3)
484
+ return
465
485
  if not reconnect_time:
466
486
  reconnect_time = constants.UC.RECONNECT_TIME
467
- if url.startswith("//"):
468
- url = "https:" + url
469
- elif ":" not in url:
470
- url = "https://" + url
471
487
  if (url.startswith("http:") or url.startswith("https:")):
472
488
  script = 'window.open("%s","_blank");' % url
473
489
  driver.execute_script(script)
@@ -493,15 +509,155 @@ def uc_open_with_reconnect(driver, url, reconnect_time=None):
493
509
  return None
494
510
 
495
511
 
512
+ def uc_open_with_cdp_mode(driver, url=None):
513
+ import asyncio
514
+ from seleniumbase.undetected.cdp_driver import cdp_util
515
+
516
+ current_url = None
517
+ try:
518
+ current_url = driver.current_url
519
+ except Exception:
520
+ driver.connect()
521
+ current_url = driver.current_url
522
+ url_protocol = current_url.split(":")[0]
523
+ if url_protocol not in ["about", "data", "chrome"]:
524
+ script = 'window.open("data:,","_blank");'
525
+ js_utils.call_me_later(driver, script, 3)
526
+ time.sleep(0.012)
527
+ driver.close()
528
+ driver.disconnect()
529
+
530
+ cdp_details = driver._get_cdp_details()
531
+ cdp_host = cdp_details[1].split("://")[1].split(":")[0]
532
+ cdp_port = int(cdp_details[1].split("://")[1].split(":")[1].split("/")[0])
533
+
534
+ url = shared_utils.fix_url_as_needed(url)
535
+ url_protocol = url.split(":")[0]
536
+ safe_url = True
537
+ if url_protocol not in ["about", "data", "chrome"]:
538
+ safe_url = False
539
+
540
+ loop = asyncio.new_event_loop()
541
+ asyncio.set_event_loop(loop)
542
+ driver.cdp_base = loop.run_until_complete(
543
+ cdp_util.start(host=cdp_host, port=cdp_port)
544
+ )
545
+ page = loop.run_until_complete(driver.cdp_base.get(url))
546
+ loop.run_until_complete(page.activate())
547
+ if not safe_url:
548
+ time.sleep(constants.UC.CDP_MODE_OPEN_WAIT)
549
+ cdp = types.SimpleNamespace()
550
+ CDPM = sb_cdp.CDPMethods(loop, page, driver)
551
+ cdp.get = CDPM.get
552
+ cdp.open = CDPM.get
553
+ cdp.reload = CDPM.reload
554
+ cdp.refresh = CDPM.refresh
555
+ cdp.add_handler = CDPM.add_handler
556
+ cdp.get_event_loop = CDPM.get_event_loop
557
+ cdp.find_element = CDPM.find_element
558
+ cdp.find = CDPM.find_element
559
+ cdp.locator = CDPM.find_element
560
+ cdp.find_all = CDPM.find_all
561
+ cdp.find_elements_by_text = CDPM.find_elements_by_text
562
+ cdp.select = CDPM.select
563
+ cdp.select_all = CDPM.select_all
564
+ cdp.click_link = CDPM.click_link
565
+ cdp.tile_windows = CDPM.tile_windows
566
+ cdp.get_all_cookies = CDPM.get_all_cookies
567
+ cdp.set_all_cookies = CDPM.set_all_cookies
568
+ cdp.save_cookies = CDPM.save_cookies
569
+ cdp.load_cookies = CDPM.load_cookies
570
+ cdp.clear_cookies = CDPM.clear_cookies
571
+ cdp.bring_active_window_to_front = CDPM.bring_active_window_to_front
572
+ cdp.bring_to_front = CDPM.bring_active_window_to_front
573
+ cdp.get_active_element = CDPM.get_active_element
574
+ cdp.get_active_element_css = CDPM.get_active_element_css
575
+ cdp.click = CDPM.click
576
+ cdp.click_active_element = CDPM.click_active_element
577
+ cdp.click_if_visible = CDPM.click_if_visible
578
+ cdp.mouse_click = CDPM.mouse_click
579
+ cdp.remove_element = CDPM.remove_element
580
+ cdp.remove_from_dom = CDPM.remove_from_dom
581
+ cdp.remove_elements = CDPM.remove_elements
582
+ cdp.scroll_into_view = CDPM.scroll_into_view
583
+ cdp.send_keys = CDPM.send_keys
584
+ cdp.press_keys = CDPM.press_keys
585
+ cdp.type = CDPM.type
586
+ cdp.evaluate = CDPM.evaluate
587
+ cdp.js_dumps = CDPM.js_dumps
588
+ cdp.maximize = CDPM.maximize
589
+ cdp.minimize = CDPM.minimize
590
+ cdp.medimize = CDPM.medimize
591
+ cdp.set_window_rect = CDPM.set_window_rect
592
+ cdp.reset_window_size = CDPM.reset_window_size
593
+ cdp.set_attributes = CDPM.set_attributes
594
+ cdp.internalize_links = CDPM.internalize_links
595
+ cdp.get_window = CDPM.get_window
596
+ cdp.get_element_attributes = CDPM.get_element_attributes
597
+ cdp.get_element_html = CDPM.get_element_html
598
+ cdp.get_element_rect = CDPM.get_element_rect
599
+ cdp.get_element_size = CDPM.get_element_size
600
+ cdp.get_element_position = CDPM.get_element_position
601
+ cdp.get_gui_element_rect = CDPM.get_gui_element_rect
602
+ cdp.get_gui_element_center = CDPM.get_gui_element_center
603
+ cdp.get_page_source = CDPM.get_page_source
604
+ cdp.get_user_agent = CDPM.get_user_agent
605
+ cdp.get_cookie_string = CDPM.get_cookie_string
606
+ cdp.get_locale_code = CDPM.get_locale_code
607
+ cdp.get_text = CDPM.get_text
608
+ cdp.get_title = CDPM.get_title
609
+ cdp.get_page_title = CDPM.get_title
610
+ cdp.get_current_url = CDPM.get_current_url
611
+ cdp.get_origin = CDPM.get_origin
612
+ cdp.get_nested_element = CDPM.get_nested_element
613
+ cdp.get_document = CDPM.get_document
614
+ cdp.get_flattened_document = CDPM.get_flattened_document
615
+ cdp.get_screen_rect = CDPM.get_screen_rect
616
+ cdp.get_window_rect = CDPM.get_window_rect
617
+ cdp.get_window_size = CDPM.get_window_size
618
+ cdp.nested_click = CDPM.nested_click
619
+ cdp.flash = CDPM.flash
620
+ cdp.focus = CDPM.focus
621
+ cdp.highlight_overlay = CDPM.highlight_overlay
622
+ cdp.get_window_position = CDPM.get_window_position
623
+ cdp.is_element_present = CDPM.is_element_present
624
+ cdp.is_element_visible = CDPM.is_element_visible
625
+ cdp.assert_element_present = CDPM.assert_element_present
626
+ cdp.assert_element = CDPM.assert_element
627
+ cdp.assert_element_visible = CDPM.assert_element
628
+ cdp.assert_text = CDPM.assert_text
629
+ cdp.assert_exact_text = CDPM.assert_exact_text
630
+ cdp.save_screenshot = CDPM.save_screenshot
631
+ cdp.page = page # async world
632
+ cdp.driver = driver.cdp_base # async world
633
+ cdp.tab = cdp.page # shortcut (original)
634
+ cdp.browser = driver.cdp_base # shortcut (original)
635
+ cdp.util = cdp_util # shortcut (original)
636
+ core_items = types.SimpleNamespace()
637
+ core_items.browser = cdp.browser
638
+ core_items.tab = cdp.tab
639
+ core_items.util = cdp.util
640
+ cdp.core = core_items
641
+ driver.cdp = cdp
642
+ driver._is_using_cdp = True
643
+
644
+
645
+ def uc_activate_cdp_mode(driver, url=None):
646
+ uc_open_with_cdp_mode(driver, url=url)
647
+
648
+
496
649
  def uc_open_with_disconnect(driver, url, timeout=None):
497
650
  """Open a url and disconnect chromedriver.
498
651
  Then waits for the duration of the timeout.
499
652
  Note: You can't perform Selenium actions again
500
653
  until after you've called driver.connect()."""
501
- if url.startswith("//"):
502
- url = "https:" + url
503
- elif ":" not in url:
504
- url = "https://" + url
654
+ url = shared_utils.fix_url_as_needed(url)
655
+ if __is_cdp_swap_needed(driver):
656
+ driver.cdp.get(url)
657
+ time.sleep(0.3)
658
+ return
659
+ if not driver.is_connected():
660
+ driver.connect()
505
661
  if (url.startswith("http:") or url.startswith("https:")):
506
662
  script = 'window.open("%s","_blank");' % url
507
663
  driver.execute_script(script)
@@ -685,6 +841,9 @@ def uc_gui_write(driver, text):
685
841
 
686
842
 
687
843
  def get_gui_element_position(driver, selector):
844
+ if __is_cdp_swap_needed(driver):
845
+ element_rect = driver.cdp.get_gui_element_rect(selector)
846
+ return (element_rect["x"], element_rect["y"])
688
847
  element = driver.wait_for_element_present(selector, timeout=3)
689
848
  element_rect = element.rect
690
849
  window_rect = driver.get_window_rect()
@@ -823,6 +982,7 @@ def _uc_gui_click_captcha(
823
982
  blind=False,
824
983
  ctype=None,
825
984
  ):
985
+ cdp_mode_on_at_start = __is_cdp_swap_needed(driver)
826
986
  _on_a_captcha_page = None
827
987
  if ctype == "cf_t":
828
988
  if not _on_a_cf_turnstile_page(driver):
@@ -864,10 +1024,13 @@ def _uc_gui_click_captcha(
864
1024
  is_in_frame = js_utils.is_in_frame(driver)
865
1025
  if not is_in_frame:
866
1026
  # Make sure the window is on top
867
- page_actions.switch_to_window(
868
- driver, driver.current_window_handle, 2, uc_lock=False
869
- )
870
- if IS_WINDOWS:
1027
+ if __is_cdp_swap_needed(driver):
1028
+ driver.cdp.bring_active_window_to_front()
1029
+ else:
1030
+ page_actions.switch_to_window(
1031
+ driver, driver.current_window_handle, 2, uc_lock=False
1032
+ )
1033
+ if IS_WINDOWS and not __is_cdp_swap_needed(driver):
871
1034
  window_rect = driver.get_window_rect()
872
1035
  width = window_rect["width"]
873
1036
  height = window_rect["height"]
@@ -950,7 +1113,10 @@ def _uc_gui_click_captcha(
950
1113
  new_class = the_class.replaceAll('center', 'left');
951
1114
  $elements[index].setAttribute('class', new_class);}"""
952
1115
  )
953
- driver.execute_script(script)
1116
+ if __is_cdp_swap_needed(driver):
1117
+ driver.cdp.evaluate(script)
1118
+ else:
1119
+ driver.execute_script(script)
954
1120
  if not is_in_frame or needs_switch:
955
1121
  # Currently not in frame (or nested frame outside CF one)
956
1122
  try:
@@ -961,16 +1127,22 @@ def _uc_gui_click_captcha(
961
1127
  if visible_iframe:
962
1128
  if driver.is_element_present("iframe"):
963
1129
  i_x, i_y = get_gui_element_position(driver, "iframe")
964
- driver.switch_to_frame("iframe")
1130
+ if driver.is_connected():
1131
+ driver.switch_to_frame("iframe")
965
1132
  else:
966
1133
  return
967
1134
  if not i_x or not i_y:
968
1135
  return
969
1136
  try:
970
- if visible_iframe:
1137
+ if ctype == "g_rc" and not driver.is_connected():
1138
+ x = (i_x + 32) * width_ratio
1139
+ y = (i_y + 34) * width_ratio
1140
+ elif visible_iframe:
971
1141
  selector = "span"
972
1142
  if ctype == "g_rc":
973
1143
  selector = "span.recaptcha-checkbox"
1144
+ if not driver.is_connected():
1145
+ selector = "iframe"
974
1146
  element = driver.wait_for_element_present(
975
1147
  selector, timeout=2.5
976
1148
  )
@@ -981,16 +1153,18 @@ def _uc_gui_click_captcha(
981
1153
  else:
982
1154
  x = (i_x + 34) * width_ratio
983
1155
  y = (i_y + 34) * width_ratio
984
- driver.switch_to.default_content()
985
- except Exception:
986
- try:
1156
+ if driver.is_connected():
987
1157
  driver.switch_to.default_content()
988
- except Exception:
989
- return
1158
+ except Exception:
1159
+ if driver.is_connected():
1160
+ try:
1161
+ driver.switch_to.default_content()
1162
+ except Exception:
1163
+ return
990
1164
  if x and y:
991
1165
  sb_config._saved_cf_x_y = (x, y)
992
1166
  if driver.is_element_present(".footer .clearfix .ray-id"):
993
- driver.uc_open_with_disconnect(driver.current_url, 3.8)
1167
+ driver.uc_open_with_disconnect(driver.get_current_url(), 3.8)
994
1168
  else:
995
1169
  driver.disconnect()
996
1170
  with suppress(Exception):
@@ -1013,9 +1187,12 @@ def _uc_gui_click_captcha(
1013
1187
  if retry and x and y and (caught or _on_a_captcha_page(driver)):
1014
1188
  with gui_lock: # Prevent issues with multiple processes
1015
1189
  # Make sure the window is on top
1016
- page_actions.switch_to_window(
1017
- driver, driver.current_window_handle, 2, uc_lock=False
1018
- )
1190
+ if __is_cdp_swap_needed(driver):
1191
+ driver.cdp.bring_active_window_to_front()
1192
+ else:
1193
+ page_actions.switch_to_window(
1194
+ driver, driver.current_window_handle, 2, uc_lock=False
1195
+ )
1019
1196
  if driver.is_element_present("iframe"):
1020
1197
  try:
1021
1198
  driver.switch_to_frame(frame)
@@ -1035,14 +1212,18 @@ def _uc_gui_click_captcha(
1035
1212
  driver.switch_to.parent_frame(checkbox_success)
1036
1213
  return
1037
1214
  if blind:
1038
- driver.uc_open_with_disconnect(driver.current_url, 3.8)
1039
- _uc_gui_click_x_y(driver, x, y, timeframe=0.32)
1215
+ driver.uc_open_with_disconnect(driver.get_current_url(), 3.8)
1216
+ if __is_cdp_swap_needed(driver) and _on_a_captcha_page(driver):
1217
+ _uc_gui_click_x_y(driver, x, y, timeframe=0.32)
1218
+ else:
1219
+ time.sleep(0.1)
1040
1220
  else:
1041
- driver.uc_open_with_reconnect(driver.current_url, 3.8)
1221
+ driver.uc_open_with_reconnect(driver.get_current_url(), 3.8)
1042
1222
  if _on_a_captcha_page(driver):
1043
1223
  driver.disconnect()
1044
1224
  _uc_gui_click_x_y(driver, x, y, timeframe=0.32)
1045
- driver.reconnect(reconnect_time)
1225
+ if not cdp_mode_on_at_start:
1226
+ driver.reconnect(reconnect_time)
1046
1227
 
1047
1228
 
1048
1229
  def uc_gui_click_captcha(driver, frame="iframe", retry=False, blind=False):
@@ -1089,6 +1270,9 @@ def _uc_gui_handle_captcha_(driver, frame="iframe", ctype=None):
1089
1270
  ctype = "cf_t"
1090
1271
  else:
1091
1272
  return
1273
+ if not driver.is_connected():
1274
+ driver.connect()
1275
+ time.sleep(2)
1092
1276
  install_pyautogui_if_missing(driver)
1093
1277
  import pyautogui
1094
1278
  pyautogui = get_configured_pyautogui(pyautogui)
@@ -1111,9 +1295,12 @@ def _uc_gui_handle_captcha_(driver, frame="iframe", ctype=None):
1111
1295
  page_actions.switch_to_window(
1112
1296
  driver, driver.current_window_handle, 2, uc_lock=False
1113
1297
  )
1114
- if IS_WINDOWS and hasattr(pyautogui, "getActiveWindowTitle"):
1298
+ if (
1299
+ IS_WINDOWS
1300
+ and hasattr(pyautogui, "getActiveWindowTitle")
1301
+ ):
1115
1302
  py_a_g_title = pyautogui.getActiveWindowTitle()
1116
- window_title = driver.title
1303
+ window_title = driver.get_title()
1117
1304
  if not py_a_g_title.startswith(window_title):
1118
1305
  window_rect = driver.get_window_rect()
1119
1306
  width = window_rect["width"]
@@ -1614,6 +1801,7 @@ def _set_chrome_options(
1614
1801
  prefs["default_content_settings.popups"] = 0
1615
1802
  prefs["managed_default_content_settings.popups"] = 0
1616
1803
  prefs["profile.password_manager_enabled"] = False
1804
+ prefs["profile.password_manager_leak_detection"] = False
1617
1805
  prefs["profile.default_content_setting_values.notifications"] = 2
1618
1806
  prefs["profile.default_content_settings.popups"] = 0
1619
1807
  prefs["profile.managed_default_content_settings.popups"] = 0
@@ -3271,6 +3459,7 @@ def get_local_driver(
3271
3459
  "default_content_settings.popups": 0,
3272
3460
  "managed_default_content_settings.popups": 0,
3273
3461
  "profile.password_manager_enabled": False,
3462
+ "profile.password_manager_leak_detection": False,
3274
3463
  "profile.default_content_setting_values.notifications": 2,
3275
3464
  "profile.default_content_settings.popups": 0,
3276
3465
  "profile.managed_default_content_settings.popups": 0,
@@ -4244,13 +4433,17 @@ def get_local_driver(
4244
4433
  with uc_lock: # Avoid multithreaded issues
4245
4434
  if make_uc_driver_from_chromedriver:
4246
4435
  if os.path.exists(LOCAL_CHROMEDRIVER):
4247
- shutil.copyfile(
4248
- LOCAL_CHROMEDRIVER, LOCAL_UC_DRIVER
4249
- )
4436
+ with suppress(Exception):
4437
+ make_driver_executable_if_not(
4438
+ LOCAL_CHROMEDRIVER
4439
+ )
4440
+ shutil.copy2(LOCAL_CHROMEDRIVER, LOCAL_UC_DRIVER)
4250
4441
  elif os.path.exists(path_chromedriver):
4251
- shutil.copyfile(
4252
- path_chromedriver, LOCAL_UC_DRIVER
4253
- )
4442
+ with suppress(Exception):
4443
+ make_driver_executable_if_not(
4444
+ path_chromedriver
4445
+ )
4446
+ shutil.copy2(path_chromedriver, LOCAL_UC_DRIVER)
4254
4447
  try:
4255
4448
  make_driver_executable_if_not(LOCAL_UC_DRIVER)
4256
4449
  except Exception as e:
@@ -4670,6 +4863,9 @@ def get_local_driver(
4670
4863
  options=chrome_options,
4671
4864
  )
4672
4865
  driver.default_get = driver.get # Save copy of original
4866
+ driver.cdp = None # Set a placeholder
4867
+ driver._is_using_cdp = False
4868
+ driver._is_connected = True
4673
4869
  if uc_activated:
4674
4870
  driver.get = lambda url: uc_special_open_if_cf(
4675
4871
  driver,
@@ -4697,6 +4893,16 @@ def get_local_driver(
4697
4893
  driver.uc_click = lambda *args, **kwargs: uc_click(
4698
4894
  driver, *args, **kwargs
4699
4895
  )
4896
+ driver.uc_activate_cdp_mode = (
4897
+ lambda *args, **kwargs: uc_activate_cdp_mode(
4898
+ driver, *args, **kwargs
4899
+ )
4900
+ )
4901
+ driver.uc_open_with_cdp_mode = (
4902
+ lambda *args, **kwargs: uc_open_with_cdp_mode(
4903
+ driver, *args, **kwargs
4904
+ )
4905
+ )
4700
4906
  driver.uc_gui_press_key = (
4701
4907
  lambda *args, **kwargs: uc_gui_press_key(
4702
4908
  driver, *args, **kwargs