Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug, update UC Mode, and upgrade Pdb+ #1999

Merged
merged 5 commits into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pygments==2.14.0;python_version<"3.7"
pygments==2.16.1;python_version>="3.7"
pyreadline3==3.4.1;platform_system=="Windows"
tabcompleter==1.2.1
pdbp==1.4.5
pdbp==1.4.6
colorama==0.4.5;python_version<"3.7"
colorama==0.4.6;python_version>="3.7"
exceptiongroup==1.1.2;python_version>="3.7"
Expand All @@ -89,7 +89,8 @@ rich==13.5.2;python_version>="3.7"
# ("pip install -r requirements.txt" also installs this, but "pip install -e ." won't.)

coverage==6.2;python_version<"3.7"
coverage==7.2.7;python_version>="3.7"
coverage==7.2.7;python_version>="3.7" and python_version<"3.8"
coverage==7.3.0;python_version>="3.8"
pytest-cov==4.0.0;python_version<"3.7"
pytest-cov==4.1.0;python_version>="3.7"
flake8==5.0.4;python_version<"3.9"
Expand Down
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "4.17.3"
__version__ = "4.17.4"
47 changes: 31 additions & 16 deletions seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def get_uc_driver_version():
if os.path.exists(LOCAL_UC_DRIVER):
try:
output = subprocess.check_output(
"%s --version" % LOCAL_UC_DRIVER, shell=True
'"%s" --version' % LOCAL_UC_DRIVER, shell=True
)
if IS_WINDOWS:
output = output.decode("latin1")
Expand Down Expand Up @@ -209,15 +209,30 @@ def has_cf(text):

def uc_special_open_if_cf(driver, url, proxy_string=None):
if (
(url.startswith("http:") or url.startswith("https:"))
and has_cf(requests_get(url, proxy_string).text)
url.startswith("http:") or url.startswith("https:")
):
with driver:
time.sleep(0.25)
driver.execute_script('window.open("%s","_blank");' % url)
driver.close()
driver.switch_to.window(driver.window_handles[-1])
time.sleep(0.11)
special = False
try:
req_get = requests_get(url, proxy_string)
status_str = str(req_get.status_code)
if (
status_str.startswith("3")
or status_str.startswith("4")
or status_str.startswith("5")
or has_cf(req_get.text)
):
special = True
except Exception:
pass
if special:
with driver:
time.sleep(0.2)
driver.execute_script('window.open("%s","_blank");' % url)
driver.close()
driver.switch_to.window(driver.window_handles[-1])
time.sleep(0.2)
else:
driver.open(url) # The original one
else:
driver.open(url) # The original one
return None
Expand All @@ -226,9 +241,9 @@ def uc_special_open_if_cf(driver, url, proxy_string=None):
def uc_open(driver, url):
if (url.startswith("http:") or url.startswith("https:")):
with driver:
time.sleep(0.25)
time.sleep(0.2)
driver.open(url)
time.sleep(0.11)
time.sleep(0.2)
else:
driver.open(url) # The original one
return None
Expand All @@ -237,11 +252,11 @@ def uc_open(driver, url):
def uc_open_with_tab(driver, url):
if (url.startswith("http:") or url.startswith("https:")):
with driver:
time.sleep(0.25)
time.sleep(0.2)
driver.execute_script('window.open("%s","_blank");' % url)
driver.close()
driver.switch_to.window(driver.window_handles[-1])
time.sleep(0.11)
time.sleep(0.2)
else:
driver.open(url) # The original one
return None
Expand Down Expand Up @@ -2276,7 +2291,7 @@ def get_local_driver(
if os.path.exists(LOCAL_EDGEDRIVER):
try:
output = subprocess.check_output(
"%s --version" % LOCAL_EDGEDRIVER, shell=True
'"%s" --version' % LOCAL_EDGEDRIVER, shell=True
)
if IS_WINDOWS:
output = output.decode("latin1")
Expand Down Expand Up @@ -2912,7 +2927,7 @@ def get_local_driver(
if os.path.exists(LOCAL_CHROMEDRIVER):
try:
output = subprocess.check_output(
"%s --version" % LOCAL_CHROMEDRIVER, shell=True
'"%s" --version' % LOCAL_CHROMEDRIVER, shell=True
)
if IS_WINDOWS:
output = output.decode("latin1")
Expand All @@ -2926,7 +2941,7 @@ def get_local_driver(
elif path_chromedriver:
try:
output = subprocess.check_output(
"%s --version" % path_chromedriver, shell=True
'"%s" --version' % path_chromedriver, shell=True
)
if IS_WINDOWS:
output = output.decode("latin1")
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
'pygments==2.16.1;python_version>="3.7"',
'pyreadline3==3.4.1;platform_system=="Windows"',
"tabcompleter==1.2.1",
"pdbp==1.4.5",
"pdbp==1.4.6",
'colorama==0.4.5;python_version<"3.7"',
'colorama==0.4.6;python_version>="3.7"',
'exceptiongroup==1.1.2;python_version>="3.7"',
Expand Down Expand Up @@ -235,7 +235,8 @@
# Usage: coverage run -m pytest; coverage html; coverage report
"coverage": [
'coverage==6.2;python_version<"3.7"',
'coverage==7.2.7;python_version>="3.7"',
'coverage==7.2.7;python_version>="3.7" and python_version<"3.8"',
'coverage==7.3.0;python_version>="3.8"',
'pytest-cov==4.0.0;python_version<"3.7"',
'pytest-cov==4.1.0;python_version>="3.7"',
],
Expand Down