gpt4 book ai didi

python - 如何修复 Mac 上与 Xvfb 和 selenium 相关的 'Program install error'?

转载 作者:太空宇宙 更新时间:2023-11-03 14:10:02 26 4
gpt4 key购买 nike

我正在尝试使用 Mac(MacOS 10.13.3)在 headless 环境中运行 selenium 测试。我基本上做了以下事情:

from pyvirtualdisplay impot Display
display = Display(visible=0, size=(13660, 7680))
display.start()

在调用 selenium webdriver (selenum 3.8.0) 之前。但是,我收到以下错误:

self = <EasyProcess cmd_param=['Xvfb', '-help'] cmd=['Xvfb', '-help'] oserror=[Errno ... directory return_code=None stdout="None" stderr="None" timeout_happened=False>

def check_installed(self):
"""Used for testing if program is installed.

Run command with arguments. Wait for command to complete.
If OSError raised, then raise :class:`EasyProcessCheckInstalledError`
with information about program installation

:param return_code: int, expected return code
:rtype: self

"""
try:
self.call()
except Exception:
> raise EasyProcessCheckInstalledError(self)
E EasyProcessCheckInstalledError: cmd=['Xvfb', '-help']
E OSError=[Errno 2] No such file or directory
E Program install error!

venv_pytest/lib/python2.7/site-packages/easyprocess/__init__.py:180: EasyProcessCheckInstalledError

因为它看起来像是 xvfb 的问题,所以我尝试安装它:

>pip install xvfb
Collecting xvfb
Could not find a version that satisfies the requirement xvfb (from versions: )
No matching distribution found for xvfb

我还尝试了以下方法:

>brew install xvfb
Error: No available formula with the name "xvfb"

我还能尝试什么?

附录:我不是在寻找其他东西。我希望在 Mac 上进行上述工作来开发测试。测试将在正常的 Linux 环境中运行(当然不是 Mac!!),该环境完美地适合与 xvfb...

最佳答案

Xvfb 几乎肯定不是您想要的。

macOS 桌面界面不基于 X11。 Xvfb实现虚拟X11显示;它只能用于运行 X11 应用程序 - 默认情况下,macOS 上不会安装这些应用程序。

macOS 不支持 headless 操作。如果您想在 macOS 上运行 Selenium 测试,您可能需要在桌面上运行它们。

关于python - 如何修复 Mac 上与 Xvfb 和 selenium 相关的 'Program install error'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48577341/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com