Skip to content

Commit 4f69387

Browse files
committed
Refactoring and timing updates
1 parent 0a4808f commit 4f69387

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

seleniumbase/behave/behave_sb.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
The SeleniumBase-Behave Connector configures command-line options.
43
******************************************************************

seleniumbase/fixtures/js_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,13 @@ def activate_jquery(driver):
171171
pass
172172
jquery_js = constants.JQuery.MIN_JS
173173
add_js_link(driver, jquery_js)
174-
for x in range(27):
174+
for x in range(32):
175175
# jQuery needs a small amount of time to activate.
176176
try:
177177
driver.execute_script("jQuery('html');")
178178
return
179179
except Exception:
180-
if x == 15:
180+
if x == 16:
181181
add_js_link(driver, jquery_js)
182182
time.sleep(0.1)
183183
# Since jQuery still isn't activating, give up and raise an exception
@@ -768,7 +768,7 @@ def set_messenger_theme(
768768
time.sleep(0.1)
769769

770770

771-
def post_message(driver, message, msg_dur, style="info"):
771+
def post_message(driver, message, msg_dur=None, style="info"):
772772
"""A helper method to post a message on the screen with Messenger.
773773
(Should only be called from post_message() in base_case.py)"""
774774
if not msg_dur:
@@ -797,7 +797,7 @@ def post_message(driver, message, msg_dur, style="info"):
797797
driver.execute_script(messenger_script)
798798

799799

800-
def post_messenger_success_message(driver, message, msg_dur):
800+
def post_messenger_success_message(driver, message, msg_dur=None):
801801
if not msg_dur:
802802
msg_dur = settings.DEFAULT_MESSAGE_DURATION
803803
msg_dur = float(msg_dur)
@@ -813,7 +813,7 @@ def post_messenger_success_message(driver, message, msg_dur):
813813
pass
814814

815815

816-
def post_messenger_error_message(driver, message, msg_dur):
816+
def post_messenger_error_message(driver, message, msg_dur=None):
817817
if not msg_dur:
818818
msg_dur = settings.DEFAULT_MESSAGE_DURATION
819819
msg_dur = float(msg_dur)

seleniumbase/plugins/pytest_plugin.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,8 +935,7 @@ def pytest_addoption(parser):
935935
default=None,
936936
help="""(DEPRECATED) - (UC Mode always uses this now.)
937937
Use undetectable-chromedriver as a subprocess,
938-
which can help avoid issues that might result.
939-
It may reduce UC's ability to avoid detection.""",
938+
which can help avoid issues that might result.""",
940939
)
941940
parser.addoption(
942941
"--no_sandbox",

seleniumbase/plugins/selenium_plugin.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,7 @@ def options(self, parser, env):
692692
default=None,
693693
help="""(DEPRECATED) - (UC Mode always uses this now.)
694694
Use undetectable-chromedriver as a subprocess,
695-
which can help avoid issues that might result.
696-
It may reduce UC's ability to avoid detection.""",
695+
which can help avoid issues that might result.""",
697696
)
698697
parser.add_option(
699698
"--no_sandbox",

seleniumbase/undetected/__init__.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import logging
33
import os
44
import re
5+
import subprocess
56
import sys
67
import time
78
import selenium.webdriver.chrome.service
@@ -214,7 +215,7 @@ def __init__(
214215
options.binary_location = (
215216
browser_executable_path or find_chrome_executable()
216217
)
217-
self._delay = 3
218+
self._delay = 2
218219
self.user_data_dir = user_data_dir
219220
self.keep_user_data_dir = keep_user_data_dir
220221
if suppress_welcome:
@@ -256,18 +257,15 @@ def __init__(
256257
logger.debug("Fixed exit_type flag.")
257258
except Exception:
258259
logger.debug("Did not find a bad exit_type flag.")
260+
creationflags = 0
261+
if "win32" in sys_plat or "win64" in sys_plat or "x64" in sys_plat:
262+
creationflags = subprocess.CREATE_NO_WINDOW
259263
self.options = options
260264
if not use_subprocess:
261265
self.browser_pid = start_detached(
262266
options.binary_location, *options.arguments
263267
)
264268
else:
265-
import subprocess
266-
267-
creationflags = 0
268-
sys_plat = sys.platform
269-
if "win32" in sys_plat or "win64" in sys_plat or "x64" in sys_plat:
270-
creationflags = subprocess.CREATE_NO_WINDOW
271269
browser = subprocess.Popen(
272270
[options.binary_location, *options.arguments],
273271
stdin=subprocess.PIPE,
@@ -288,6 +286,10 @@ def __init__(
288286
executable_path=driver_executable_path,
289287
log_path=os.devnull,
290288
)
289+
if hasattr(service_, "creationflags"):
290+
setattr(service_, "creationflags", creationflags)
291+
if hasattr(service_, "creation_flags"):
292+
setattr(service_, "creation_flags", creationflags)
291293
super().__init__(
292294
port=port,
293295
options=options,

0 commit comments

Comments
 (0)