Skip to content

Commit 4324cae

Browse files
committed
Improve undetectable mode compatibility
1 parent ae4df0e commit 4324cae

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ def _set_chrome_options(
511511
chrome_options.add_argument("--guest")
512512
else:
513513
pass
514-
if user_data_dir and not undetectable:
514+
if user_data_dir and not is_using_uc(undetectable, browser_name):
515515
abs_path = os.path.abspath(user_data_dir)
516516
chrome_options.add_argument("user-data-dir=%s" % abs_path)
517517
if extension_zip:
@@ -597,10 +597,11 @@ def _set_chrome_options(
597597
chrome_options.add_argument("--proxy-pac-url=%s" % proxy_pac_url)
598598
if browser_name != constants.Browser.OPERA:
599599
# Opera Chromium doesn't support these switches
600-
chrome_options.add_argument("--ignore-certificate-errors")
600+
if not is_using_uc(undetectable, browser_name) or not enable_ws:
601+
chrome_options.add_argument("--ignore-certificate-errors")
601602
if not enable_ws:
602603
chrome_options.add_argument("--disable-web-security")
603-
if "linux" in PLATFORM or not undetectable:
604+
if "linux" in PLATFORM or not is_using_uc(undetectable, browser_name):
604605
chrome_options.add_argument("--no-sandbox")
605606
else:
606607
# Opera Chromium only!
@@ -946,7 +947,7 @@ def get_driver(
946947
headless = True
947948
if uc_subprocess and not undetectable:
948949
undetectable = True
949-
if undetectable and mobile_emulator:
950+
if is_using_uc(undetectable, browser_name) and mobile_emulator:
950951
mobile_emulator = False
951952
user_agent = None
952953
proxy_auth = False
@@ -2164,7 +2165,7 @@ def get_local_driver(
21642165
edge_options.add_argument("--allow-running-insecure-content")
21652166
if user_agent:
21662167
edge_options.add_argument("--user-agent=%s" % user_agent)
2167-
if "linux" in PLATFORM or not undetectable:
2168+
if "linux" in PLATFORM or not is_using_uc(undetectable, browser_name):
21682169
edge_options.add_argument("--no-sandbox")
21692170
if remote_debug:
21702171
# To access the Remote Debugger, go to: http://localhost:9222
@@ -2656,7 +2657,7 @@ def get_local_driver(
26562657
if selenium4_or_newer:
26572658
if headless and "linux" not in PLATFORM:
26582659
undetectable = False # No support for headless
2659-
if undetectable:
2660+
if is_using_uc(undetectable, browser_name):
26602661
from seleniumbase import undetected
26612662
from urllib.error import URLError
26622663

seleniumbase/fixtures/base_case.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3122,6 +3122,12 @@ def set_content_to_parent_frame(self):
31223122
def open_new_window(self, switch_to=True):
31233123
"""Opens a new browser tab/window and switches to it by default."""
31243124
self.wait_for_ready_state_complete()
3125+
if hasattr(self.driver, "tab_new"):
3126+
self.driver.tab_new("about:blank")
3127+
if switch_to:
3128+
self.switch_to_newest_window()
3129+
time.sleep(0.01)
3130+
return
31253131
if selenium4_or_newer and switch_to:
31263132
self.driver.switch_to.new_window("tab")
31273133
else:

0 commit comments

Comments
 (0)