Skip to content

Commit 2609139

Browse files
authored
Merge pull request #1999 from seleniumbase/browser-launcher-updates
Fix a bug, update UC Mode, and upgrade Pdb+
2 parents 3d22534 + 94e4b7c commit 2609139

File tree

4 files changed

+38
-21
lines changed

4 files changed

+38
-21
lines changed

requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pygments==2.14.0;python_version<"3.7"
7070
pygments==2.16.1;python_version>="3.7"
7171
pyreadline3==3.4.1;platform_system=="Windows"
7272
tabcompleter==1.2.1
73-
pdbp==1.4.5
73+
pdbp==1.4.6
7474
colorama==0.4.5;python_version<"3.7"
7575
colorama==0.4.6;python_version>="3.7"
7676
exceptiongroup==1.1.2;python_version>="3.7"
@@ -89,7 +89,8 @@ rich==13.5.2;python_version>="3.7"
8989
# ("pip install -r requirements.txt" also installs this, but "pip install -e ." won't.)
9090

9191
coverage==6.2;python_version<"3.7"
92-
coverage==7.2.7;python_version>="3.7"
92+
coverage==7.2.7;python_version>="3.7" and python_version<"3.8"
93+
coverage==7.3.0;python_version>="3.8"
9394
pytest-cov==4.0.0;python_version<"3.7"
9495
pytest-cov==4.1.0;python_version>="3.7"
9596
flake8==5.0.4;python_version<"3.9"

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.17.3"
2+
__version__ = "4.17.4"

seleniumbase/core/browser_launcher.py

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def get_uc_driver_version():
158158
if os.path.exists(LOCAL_UC_DRIVER):
159159
try:
160160
output = subprocess.check_output(
161-
"%s --version" % LOCAL_UC_DRIVER, shell=True
161+
'"%s" --version' % LOCAL_UC_DRIVER, shell=True
162162
)
163163
if IS_WINDOWS:
164164
output = output.decode("latin1")
@@ -209,15 +209,30 @@ def has_cf(text):
209209

210210
def uc_special_open_if_cf(driver, url, proxy_string=None):
211211
if (
212-
(url.startswith("http:") or url.startswith("https:"))
213-
and has_cf(requests_get(url, proxy_string).text)
212+
url.startswith("http:") or url.startswith("https:")
214213
):
215-
with driver:
216-
time.sleep(0.25)
217-
driver.execute_script('window.open("%s","_blank");' % url)
218-
driver.close()
219-
driver.switch_to.window(driver.window_handles[-1])
220-
time.sleep(0.11)
214+
special = False
215+
try:
216+
req_get = requests_get(url, proxy_string)
217+
status_str = str(req_get.status_code)
218+
if (
219+
status_str.startswith("3")
220+
or status_str.startswith("4")
221+
or status_str.startswith("5")
222+
or has_cf(req_get.text)
223+
):
224+
special = True
225+
except Exception:
226+
pass
227+
if special:
228+
with driver:
229+
time.sleep(0.2)
230+
driver.execute_script('window.open("%s","_blank");' % url)
231+
driver.close()
232+
driver.switch_to.window(driver.window_handles[-1])
233+
time.sleep(0.2)
234+
else:
235+
driver.open(url) # The original one
221236
else:
222237
driver.open(url) # The original one
223238
return None
@@ -226,9 +241,9 @@ def uc_special_open_if_cf(driver, url, proxy_string=None):
226241
def uc_open(driver, url):
227242
if (url.startswith("http:") or url.startswith("https:")):
228243
with driver:
229-
time.sleep(0.25)
244+
time.sleep(0.2)
230245
driver.open(url)
231-
time.sleep(0.11)
246+
time.sleep(0.2)
232247
else:
233248
driver.open(url) # The original one
234249
return None
@@ -237,11 +252,11 @@ def uc_open(driver, url):
237252
def uc_open_with_tab(driver, url):
238253
if (url.startswith("http:") or url.startswith("https:")):
239254
with driver:
240-
time.sleep(0.25)
255+
time.sleep(0.2)
241256
driver.execute_script('window.open("%s","_blank");' % url)
242257
driver.close()
243258
driver.switch_to.window(driver.window_handles[-1])
244-
time.sleep(0.11)
259+
time.sleep(0.2)
245260
else:
246261
driver.open(url) # The original one
247262
return None
@@ -2276,7 +2291,7 @@ def get_local_driver(
22762291
if os.path.exists(LOCAL_EDGEDRIVER):
22772292
try:
22782293
output = subprocess.check_output(
2279-
"%s --version" % LOCAL_EDGEDRIVER, shell=True
2294+
'"%s" --version' % LOCAL_EDGEDRIVER, shell=True
22802295
)
22812296
if IS_WINDOWS:
22822297
output = output.decode("latin1")
@@ -2912,7 +2927,7 @@ def get_local_driver(
29122927
if os.path.exists(LOCAL_CHROMEDRIVER):
29132928
try:
29142929
output = subprocess.check_output(
2915-
"%s --version" % LOCAL_CHROMEDRIVER, shell=True
2930+
'"%s" --version' % LOCAL_CHROMEDRIVER, shell=True
29162931
)
29172932
if IS_WINDOWS:
29182933
output = output.decode("latin1")
@@ -2926,7 +2941,7 @@ def get_local_driver(
29262941
elif path_chromedriver:
29272942
try:
29282943
output = subprocess.check_output(
2929-
"%s --version" % path_chromedriver, shell=True
2944+
'"%s" --version' % path_chromedriver, shell=True
29302945
)
29312946
if IS_WINDOWS:
29322947
output = output.decode("latin1")

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@
204204
'pygments==2.16.1;python_version>="3.7"',
205205
'pyreadline3==3.4.1;platform_system=="Windows"',
206206
"tabcompleter==1.2.1",
207-
"pdbp==1.4.5",
207+
"pdbp==1.4.6",
208208
'colorama==0.4.5;python_version<"3.7"',
209209
'colorama==0.4.6;python_version>="3.7"',
210210
'exceptiongroup==1.1.2;python_version>="3.7"',
@@ -235,7 +235,8 @@
235235
# Usage: coverage run -m pytest; coverage html; coverage report
236236
"coverage": [
237237
'coverage==6.2;python_version<"3.7"',
238-
'coverage==7.2.7;python_version>="3.7"',
238+
'coverage==7.2.7;python_version>="3.7" and python_version<"3.8"',
239+
'coverage==7.3.0;python_version>="3.8"',
239240
'pytest-cov==4.0.0;python_version<"3.7"',
240241
'pytest-cov==4.1.0;python_version>="3.7"',
241242
],

0 commit comments

Comments
 (0)