From 4624edd2d9c1a4de6272890a598fa9816d4482f8 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Fri, 19 Jul 2024 16:44:52 -0400 Subject: [PATCH 1/3] Refactor UC Mode --- seleniumbase/core/browser_launcher.py | 23 ++++++++++++ seleniumbase/fixtures/base_case.py | 52 ++++++++++++++------------- 2 files changed, 50 insertions(+), 25 deletions(-) diff --git a/seleniumbase/core/browser_launcher.py b/seleniumbase/core/browser_launcher.py index 5e19abbfc76..924b4f534c6 100644 --- a/seleniumbase/core/browser_launcher.py +++ b/seleniumbase/core/browser_launcher.py @@ -586,6 +586,29 @@ def install_pyautogui_if_missing(driver): shared_utils.pip_install( "pyautogui", version=constants.PyAutoGUI.VER ) + try: + import pyautogui + except Exception: + if ( + IS_LINUX + and hasattr(sb_config, "xvfb") + and hasattr(sb_config, "headed") + and hasattr(sb_config, "headless") + and hasattr(sb_config, "headless2") + and (not sb_config.headed or sb_config.xvfb) + and not (sb_config.headless or sb_config.headless2) + ): + from sbvirtualdisplay import Display + try: + xvfb_display = Display( + visible=True, + size=(1366, 768), + backend="xvfb", + use_xauth=True, + ) + xvfb_display.start() + except Exception: + pass def get_configured_pyautogui(pyautogui_copy): diff --git a/seleniumbase/fixtures/base_case.py b/seleniumbase/fixtures/base_case.py index fbbaa711f4d..07d07caec98 100644 --- a/seleniumbase/fixtures/base_case.py +++ b/seleniumbase/fixtures/base_case.py @@ -13788,31 +13788,33 @@ def __activate_virtual_display_as_needed(self): which is the default mode on Linux unless using another arg.""" if "linux" in sys.platform and (not self.headed or self.xvfb): from sbvirtualdisplay import Display - if self.undetectable and not (self.headless or self.headless2): - import Xlib.display - try: - self._xvfb_display = Display( - visible=True, - size=(1366, 768), - backend="xvfb", - use_xauth=True, - ) - self._xvfb_display.start() - if "DISPLAY" not in os.environ.keys(): + pip_find_lock = fasteners.InterProcessLock( + constants.PipInstall.FINDLOCK + ) + with pip_find_lock: # Prevent issues with multiple processes + if self.undetectable and not (self.headless or self.headless2): + import Xlib.display + try: + self._xvfb_display = Display( + visible=True, + size=(1366, 768), + backend="xvfb", + use_xauth=True, + ) + self._xvfb_display.start() + if "DISPLAY" not in os.environ.keys(): + print( + "\nX11 display failed! Will use regular xvfb!" + ) + self.__activate_standard_virtual_display() + except Exception as e: + if hasattr(e, "msg"): + print("\n" + str(e.msg)) + else: + print(e) print("\nX11 display failed! Will use regular xvfb!") self.__activate_standard_virtual_display() - except Exception as e: - if hasattr(e, "msg"): - print("\n" + str(e.msg)) - else: - print(e) - print("\nX11 display failed! Will use regular xvfb!") - self.__activate_standard_virtual_display() - return - pip_find_lock = fasteners.InterProcessLock( - constants.PipInstall.FINDLOCK - ) - with pip_find_lock: # Prevent issues with multiple processes + return pyautogui_is_installed = False try: import pyautogui @@ -13854,8 +13856,8 @@ def __activate_virtual_display_as_needed(self): print("\n" + str(e.msg)) else: print(e) - else: - self.__activate_standard_virtual_display() + else: + self.__activate_standard_virtual_display() def __ad_block_as_needed(self): """This is an internal method for handling ad-blocking. From d636b8e19855d52016f71dd8348baea7bfaf3b02 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Fri, 19 Jul 2024 16:45:27 -0400 Subject: [PATCH 2/3] Refresh Python dependencies --- mkdocs_build/requirements.txt | 6 +++--- requirements.txt | 8 ++++---- setup.py | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mkdocs_build/requirements.txt b/mkdocs_build/requirements.txt index eaf0295a961..288bfe0f1f0 100644 --- a/mkdocs_build/requirements.txt +++ b/mkdocs_build/requirements.txt @@ -3,10 +3,10 @@ regex>=2024.5.15 pymdown-extensions>=10.8.1 -pipdeptree>=2.23.0 +pipdeptree>=2.23.1 python-dateutil>=2.8.2 Markdown==3.6 -markdown2==2.4.13 +markdown2==2.5.0 MarkupSafe==2.1.5 Jinja2==3.1.4 click==8.1.7 @@ -20,7 +20,7 @@ lxml==5.2.2 pyquery==2.0.0 readtime==3.0.0 mkdocs==1.6.0 -mkdocs-material==9.5.28 +mkdocs-material==9.5.29 mkdocs-exclude-search==0.6.6 mkdocs-simple-hooks==0.1.5 mkdocs-material-extensions==1.3.1 diff --git a/requirements.txt b/requirements.txt index d372994d94c..e9aa3658893 100755 --- a/requirements.txt +++ b/requirements.txt @@ -25,7 +25,7 @@ charset-normalizer==3.3.2 urllib3>=1.26.19,<2;python_version<"3.10" urllib3>=1.26.19,<2.3.0;python_version>="3.10" requests==2.31.0 -pynose==1.5.1 +pynose==1.5.2 sniffio==1.3.1 h11==0.14.0 outcome==1.3.0.post0 @@ -64,8 +64,8 @@ beautifulsoup4==4.12.3 pygments==2.17.2;python_version<"3.8" pygments==2.18.0;python_version>="3.8" pyreadline3==3.4.1;platform_system=="Windows" -tabcompleter==1.3.0 -pdbp==1.5.1 +tabcompleter==1.3.3 +pdbp==1.5.3 colorama==0.4.6 pyotp==2.9.0 python-xlib==0.33;platform_system=="Linux" @@ -78,7 +78,7 @@ rich==13.7.1 # ("pip install -r requirements.txt" also installs this, but "pip install -e ." won't.) coverage==7.2.7;python_version<"3.8" -coverage>=7.5.4;python_version>="3.8" +coverage>=7.6.0;python_version>="3.8" pytest-cov==4.1.0;python_version<"3.8" pytest-cov>=5.0.0;python_version>="3.8" flake8==5.0.4;python_version<"3.9" diff --git a/setup.py b/setup.py index b8c75094689..0afedadac50 100755 --- a/setup.py +++ b/setup.py @@ -173,7 +173,7 @@ 'urllib3>=1.26.19,<2;python_version<"3.10"', 'urllib3>=1.26.19,<2.3.0;python_version>="3.10"', 'requests==2.31.0', - "pynose==1.5.1", + "pynose==1.5.2", 'sniffio==1.3.1', 'h11==0.14.0', 'outcome==1.3.0.post0', @@ -212,8 +212,8 @@ 'pygments==2.17.2;python_version<"3.8"', 'pygments==2.18.0;python_version>="3.8"', 'pyreadline3==3.4.1;platform_system=="Windows"', - "tabcompleter==1.3.0", - "pdbp==1.5.1", + "tabcompleter==1.3.3", + "pdbp==1.5.3", 'colorama==0.4.6', 'pyotp==2.9.0', 'python-xlib==0.33;platform_system=="Linux"', @@ -235,7 +235,7 @@ # Usage: coverage run -m pytest; coverage html; coverage report "coverage": [ 'coverage==7.2.7;python_version<"3.8"', - 'coverage>=7.5.4;python_version>="3.8"', + 'coverage>=7.6.0;python_version>="3.8"', 'pytest-cov==4.1.0;python_version<"3.8"', 'pytest-cov>=5.0.0;python_version>="3.8"', ], @@ -308,7 +308,7 @@ 'kaitaistruct==0.10', 'pyasn1==0.5.1;python_version<"3.8"', 'pyasn1==0.6.0;python_version>="3.8"', - 'zstandard==0.22.0', + 'zstandard==0.23.0', ], }, packages=[ From 1bd7c1bd558fa692276b4a650ab6f46f41f8e3ff Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Fri, 19 Jul 2024 16:46:02 -0400 Subject: [PATCH 3/3] Version 4.28.6 --- seleniumbase/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seleniumbase/__version__.py b/seleniumbase/__version__.py index 6268d11bdf8..9149958c85e 100755 --- a/seleniumbase/__version__.py +++ b/seleniumbase/__version__.py @@ -1,2 +1,2 @@ # seleniumbase package -__version__ = "4.28.5" +__version__ = "4.28.6"