Skip to content

Commit c2f6b03

Browse files
committed
Handle UC Mode when used with incompatible modes
1 parent 71cb7a3 commit c2f6b03

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,9 @@ def get_driver(
940940
headless = True
941941
if uc_subprocess and not undetectable:
942942
undetectable = True
943+
if undetectable and mobile_emulator:
944+
mobile_emulator = False
945+
user_agent = None
943946
proxy_auth = False
944947
proxy_user = None
945948
proxy_pass = None

seleniumbase/plugins/pytest_plugin.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,17 @@ def pytest_addoption(parser):
12941294
'\n (Your browser choice was: "%s")\n' % browser_list[0]
12951295
)
12961296
raise Exception(message)
1297+
if undetectable and "--wire" in sys_argv:
1298+
raise Exception(
1299+
"\n\n SeleniumBase doesn't support mixing --uc with --wire mode!"
1300+
"\n If you need both, override get_new_driver() from BaseCase:"
1301+
"\n https://seleniumbase.io/help_docs/syntax_formats/#sb_sf_09\n"
1302+
)
1303+
if undetectable and "--mobile" in sys_argv:
1304+
raise Exception(
1305+
"\n\n SeleniumBase doesn't support mixing --uc with --mobile"
1306+
'\n UC has: "unrecognized chrome option: mobileEmulation"!\n'
1307+
)
12971308

12981309

12991310
def pytest_configure(config):

seleniumbase/plugins/selenium_plugin.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,26 @@ def beforeTest(self, test):
980980
)
981981
self.options.headless = True
982982
test.test.headless = True
983+
if self.options.use_wire and self.options.undetectable:
984+
print(
985+
"\n"
986+
"SeleniumBase doesn't support mixing --uc with --wire mode.\n"
987+
"If you need both, override get_new_driver() from BaseCase:\n"
988+
"https://seleniumbase.io/help_docs/syntax_formats/#sb_sf_09\n"
989+
"(Only UC Mode without Wire Mode will be used for this run)\n"
990+
)
991+
self.options.use_wire = False
992+
test.test.use_wire = False
993+
if self.options.mobile_emulator and self.options.undetectable:
994+
print(
995+
"\n"
996+
"SeleniumBase doesn't support mixing --uc with --mobile.\n"
997+
"(Only UC Mode without Mobile will be used for this run)\n"
998+
)
999+
self.options.mobile_emulator = False
1000+
test.test.mobile_emulator = False
1001+
self.options.user_agent = None
1002+
test.test.user_agent = None
9831003
# Recorder Mode can still optimize scripts in --headless2 mode.
9841004
if self.options.recorder_mode and self.options.headless:
9851005
self.options.headless = False

0 commit comments

Comments
 (0)