Skip to content

Fix PyAutoGUI targeting issue on Linux #3855

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

Merged
merged 3 commits into from
Jul 1, 2025
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
2 changes: 1 addition & 1 deletion mkdocs_build/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pathspec==0.12.1
Babel==2.17.0
paginate==0.5.7
mkdocs==1.6.1
mkdocs-material==9.6.14
mkdocs-material==9.6.15
mkdocs-exclude-search==0.6.6
mkdocs-simple-hooks==0.1.5
mkdocs-material-extensions==1.3.1
14 changes: 7 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ parse>=1.20.2
parse-type>=0.6.4
colorama>=0.4.6
pyyaml>=6.0.2
pygments>=2.19.1
pygments>=2.19.2
pyreadline3>=3.5.3;platform_system=="Windows"
tabcompleter>=1.4.0
pdbp>=1.7.0
idna==3.10
chardet==5.2.0
charset-normalizer>=3.4.2,<4
urllib3>=1.26.20,<2;python_version<"3.10"
urllib3>=1.26.20,<2.5.0;python_version>="3.10"
urllib3>=1.26.20,<2.6.0;python_version>="3.10"
requests==2.32.4
sniffio==1.3.1
h11==0.16.0
Expand All @@ -55,14 +55,14 @@ iniconfig==2.1.0
pluggy==1.5.0;python_version<"3.9"
pluggy==1.6.0;python_version>="3.9"
pytest==8.3.5;python_version<"3.9"
pytest==8.4.0;python_version>="3.9"
pytest==8.4.1;python_version>="3.9"
pytest-html==4.0.2
pytest-metadata==3.1.1
pytest-ordering==0.6
pytest-rerunfailures==14.0;python_version<"3.9"
pytest-rerunfailures==15.1;python_version>="3.9"
pytest-xdist==3.6.1;python_version<"3.9"
pytest-xdist==3.7.0;python_version>="3.9"
pytest-xdist==3.8.0;python_version>="3.9"
parameterized==0.9.0
behave==1.2.6
soupsieve==2.7
Expand All @@ -81,9 +81,9 @@ coverage>=7.9.1;python_version>="3.9"
pytest-cov>=5.0.0;python_version<"3.9"
pytest-cov>=6.2.1;python_version>="3.9"
flake8==5.0.4;python_version<"3.9"
flake8==7.2.0;python_version>="3.9"
flake8==7.3.0;python_version>="3.9"
mccabe==0.7.0
pyflakes==2.5.0;python_version<"3.9"
pyflakes==3.3.2;python_version>="3.9"
pyflakes==3.4.0;python_version>="3.9"
pycodestyle==2.9.1;python_version<"3.9"
pycodestyle==2.13.0;python_version>="3.9"
pycodestyle==2.14.0;python_version>="3.9"
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.39.5"
__version__ = "4.39.6"
9 changes: 9 additions & 0 deletions seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,13 +580,16 @@ def uc_open_with_cdp_mode(driver, url=None, **kwargs):
headless = False
headed = None
xvfb = None
xvfb_metrics = None
binary_location = None
if hasattr(sb_config, "headless"):
headless = sb_config.headless
if hasattr(sb_config, "headed"):
headed = sb_config.headed
if hasattr(sb_config, "xvfb"):
xvfb = sb_config.xvfb
if hasattr(sb_config, "xvfb_metrics"):
xvfb_metrics = sb_config.xvfb_metrics
if hasattr(sb_config, "binary_location"):
binary_location = sb_config.binary_location

Expand All @@ -599,6 +602,7 @@ def uc_open_with_cdp_mode(driver, url=None, **kwargs):
headless=headless,
headed=headed,
xvfb=xvfb,
xvfb_metrics=xvfb_metrics,
browser_executable_path=binary_location,
)
)
Expand Down Expand Up @@ -963,6 +967,11 @@ def __install_pyautogui_if_missing():
backend="xvfb",
use_xauth=True,
)
if "--debug-display" in sys.argv:
print(
"Starting VDisplay from browser_launcher: (%s, %s)"
% (xvfb_width, xvfb_height)
)
_xvfb_display.start()
sb_config._virtual_display = _xvfb_display
sb_config.headless_active = True
Expand Down
9 changes: 9 additions & 0 deletions seleniumbase/core/sb_cdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,10 @@ def __install_pyautogui_if_missing(self):
shared_utils.is_linux()
and (not sb_config.headed or sb_config.xvfb)
and not driver.config.headless
and (
not hasattr(sb_config, "_virtual_display")
or not sb_config._virtual_display
)
):
from sbvirtualdisplay import Display
xvfb_width = 1366
Expand Down Expand Up @@ -1466,6 +1470,11 @@ def __install_pyautogui_if_missing(self):
backend="xvfb",
use_xauth=True,
)
if "--debug-display" in sys.argv:
print(
"Starting VDisplay from sb_cdp: (%s, %s)"
% (xvfb_width, xvfb_height)
)
xvfb_display.start()

def __get_configured_pyautogui(self, pyautogui_copy):
Expand Down
6 changes: 6 additions & 0 deletions seleniumbase/fixtures/base_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -14164,7 +14164,13 @@ def __activate_virtual_display(self):
backend="xvfb",
use_xauth=True,
)
if "--debug-display" in sys.argv:
print(
"Starting VDisplay from base_case: (%s, %s)"
% (self._xvfb_width, self._xvfb_height)
)
self._xvfb_display.start()
sb_config._virtual_display = self._xvfb_display
if "DISPLAY" not in os.environ.keys():
print(
"\nX11 display failed! Will use regular xvfb!"
Expand Down
14 changes: 13 additions & 1 deletion seleniumbase/undetected/cdp_driver/cdp_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ def __activate_virtual_display_as_needed(
headless, headed, xvfb, xvfb_metrics
):
"""This is only needed on Linux."""
if IS_LINUX and (not headed or xvfb):
if (
IS_LINUX
and (not headed or xvfb)
and (
not hasattr(sb_config, "_virtual_display")
or not sb_config._virtual_display
)
):
from sbvirtualdisplay import Display
pip_find_lock = fasteners.InterProcessLock(
constants.PipInstall.FINDLOCK
Expand Down Expand Up @@ -87,6 +94,11 @@ def __activate_virtual_display_as_needed(
backend="xvfb",
use_xauth=True,
)
if "--debug-display" in sys.argv:
print(
"Starting VDisplay from cdp_util: (%s, %s)"
% (_xvfb_width, _xvfb_height)
)
_xvfb_display.start()
if "DISPLAY" not in os.environ.keys():
print(
Expand Down
18 changes: 9 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
print("You are currently using Python %s\n" % current_ver)
sys.exit()
print("\n*** Checking code health with flake8:\n")
os.system("python -m pip install 'flake8==7.2.0'")
os.system("python -m pip install 'flake8==7.3.0'")
flake8_status = os.system("flake8 --exclude=recordings,temp")
if flake8_status != 0:
print("\nERROR! Fix flake8 issues before publishing to PyPI!\n")
Expand Down Expand Up @@ -174,15 +174,15 @@
'parse-type>=0.6.4',
'colorama>=0.4.6',
'pyyaml>=6.0.2',
'pygments>=2.19.1',
'pygments>=2.19.2',
'pyreadline3>=3.5.3;platform_system=="Windows"',
"tabcompleter>=1.4.0",
"pdbp>=1.7.0",
"idna==3.10",
'chardet==5.2.0',
'charset-normalizer>=3.4.2,<4',
'urllib3>=1.26.20,<2;python_version<"3.10"',
'urllib3>=1.26.20,<2.5.0;python_version>="3.10"',
'urllib3>=1.26.20,<2.6.0;python_version>="3.10"',
'requests==2.32.4',
'sniffio==1.3.1',
'h11==0.16.0',
Expand All @@ -203,14 +203,14 @@
'pluggy==1.5.0;python_version<"3.9"',
'pluggy==1.6.0;python_version>="3.9"',
'pytest==8.3.5;python_version<"3.9"',
'pytest==8.4.0;python_version>="3.9"',
'pytest==8.4.1;python_version>="3.9"',
"pytest-html==4.0.2", # Newer ones had issues
'pytest-metadata==3.1.1',
"pytest-ordering==0.6",
'pytest-rerunfailures==14.0;python_version<"3.9"',
'pytest-rerunfailures==15.1;python_version>="3.9"',
'pytest-xdist==3.6.1;python_version<"3.9"',
'pytest-xdist==3.7.0;python_version>="3.9"',
'pytest-xdist==3.8.0;python_version>="3.9"',
'parameterized==0.9.0',
"behave==1.2.6",
'soupsieve==2.7',
Expand Down Expand Up @@ -242,12 +242,12 @@
# Usage: flake8
"flake8": [
'flake8==5.0.4;python_version<"3.9"',
'flake8==7.2.0;python_version>="3.9"',
'flake8==7.3.0;python_version>="3.9"',
"mccabe==0.7.0",
'pyflakes==2.5.0;python_version<"3.9"',
'pyflakes==3.3.2;python_version>="3.9"',
'pyflakes==3.4.0;python_version>="3.9"',
'pycodestyle==2.9.1;python_version<"3.9"',
'pycodestyle==2.13.0;python_version>="3.9"',
'pycodestyle==2.14.0;python_version>="3.9"',
],
# pip install -e .[ipdb]
# (Not needed for debugging anymore. SeleniumBase now includes "pdbp".)
Expand Down Expand Up @@ -275,7 +275,7 @@
# (An optional library for image-processing.)
"pillow": [
'Pillow>=10.4.0;python_version<"3.9"',
'Pillow>=11.2.1;python_version>="3.9"',
'Pillow>=11.3.0;python_version>="3.9"',
],
# pip install -e .[pip-system-certs]
# (If you see [SSL: CERTIFICATE_VERIFY_FAILED], then get this.)
Expand Down