From d4355ed493f3d933b9bfbd6fa0d6401f2fb11438 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Sun, 13 Aug 2023 18:34:03 -0400 Subject: [PATCH 1/5] Fix issue that occurs if a driver path contains spaces --- seleniumbase/core/browser_launcher.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/seleniumbase/core/browser_launcher.py b/seleniumbase/core/browser_launcher.py index d5f02e4edb9..cdfe8817cd1 100644 --- a/seleniumbase/core/browser_launcher.py +++ b/seleniumbase/core/browser_launcher.py @@ -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") @@ -2276,7 +2276,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") @@ -2912,7 +2912,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") @@ -2926,7 +2926,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") From 3b1643be55eafa9fbe1888de88f88a41220bbb01 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Sun, 13 Aug 2023 18:45:33 -0400 Subject: [PATCH 2/5] Update UC Mode --- seleniumbase/core/browser_launcher.py | 39 ++++++++++++++++++--------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/seleniumbase/core/browser_launcher.py b/seleniumbase/core/browser_launcher.py index cdfe8817cd1..c202d22160f 100644 --- a/seleniumbase/core/browser_launcher.py +++ b/seleniumbase/core/browser_launcher.py @@ -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 @@ -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 @@ -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 From ae9b92e86424c92eaf0411f4a382d48baba363ba Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Sun, 13 Aug 2023 18:52:40 -0400 Subject: [PATCH 3/5] Refresh optional Python dependencies --- requirements.txt | 3 ++- setup.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 6cc3e1a9e58..85653da8716 100755 --- a/requirements.txt +++ b/requirements.txt @@ -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" diff --git a/setup.py b/setup.py index 740934bfa90..feea05dcb38 100755 --- a/setup.py +++ b/setup.py @@ -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"', ], From 0cca424a72686de0db9afa197eb24e93c2d8e3a8 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Sun, 13 Aug 2023 18:54:20 -0400 Subject: [PATCH 4/5] Refresh Python dependencies (Pdb+) --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 85653da8716..4a97c2c892b 100755 --- a/requirements.txt +++ b/requirements.txt @@ -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" diff --git a/setup.py b/setup.py index feea05dcb38..8f9218bd5cc 100755 --- a/setup.py +++ b/setup.py @@ -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"', From 94e4b7cdde79b97863a755e1075691c6b7b03669 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Sun, 13 Aug 2023 18:54:38 -0400 Subject: [PATCH 5/5] Version 4.17.4 --- seleniumbase/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seleniumbase/__version__.py b/seleniumbase/__version__.py index 13489a2bf99..3c88fa9eaf8 100755 --- a/seleniumbase/__version__.py +++ b/seleniumbase/__version__.py @@ -1,2 +1,2 @@ # seleniumbase package -__version__ = "4.17.3" +__version__ = "4.17.4"