问题
My tests are working and running as expected with PyVirtualDisplay==0.2.1
, but I have a problem with the latest version of this package (for example, PyVirtualDisplay==0.2.5
).
My code snippet:
...
def _set_up(self):
# Creation of instance of the browser.
self.display = Display(visible=0, size=(config.WIDTH, config.HEIGHT))
self.display.start()
desired = self.get_desired_capabilities(config.BROWSER)
self.driver = webdriver.Remote(command_executor=config.ACTIVE_NODE,
desired_capabilities=desired)
# Maximize window size.
self.driver.set_window_size(config.WIDTH, config.HEIGHT)
...
Error message:
Error Traceback (most recent call last): File "/usr/local/Cellar/python/3.7.6/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/case.py", line 59, in testPartExecutor yield File "/usr/local/Cellar/python/3.7.6/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/case.py", line 624, in run self.setUp() File "/Users/ratmirasanov/Documents/testing/welcome_widget/test_welcome_widget.py", line 24, in setUp self._set_up() File "/Users/ratmirasanov/Documents/testing/utilities.py", line 41, in _set_up self.display.start() File "/Users/ratmirasanov/Documents/testing/venv/lib/python3.7/site-packages/pyvirtualdisplay/abstractdisplay.py", line 171, in start raise XStartTimeoutError(msg % d) pyvirtualdisplay.abstractdisplay.XStartTimeoutError: Failed to start X on display ":1001" (xdpyinfo check failed).
I did not find any working solution to fix this problem. Any help will be appreciated. Thanks.
UPD: The PyVirtualDisplay==0.2.5
package is working as expected on Ubuntu 18.04.3 LTS.
Where is located the xdpyindo
program: /usr/bin/xdpyinfo
.
The problem is on my Mac (macOS Catalina 10.15.2) with XQuartz (https://www.xquartz.org/index.html) installed (xdpyindo
program is located in /opt/X11/bin/xdpyinfo
folder).
回答1:
My tests are working and running as expected with PyVirtualDisplay==0.2.1
Your display is taking longer than 10 secs to start. This constraint didn't exist in old versions of PyVirtualDisplay.
Explanation:
Starting with version 0.2.2
, PyVirtualDisplay relies on the xdpyinfo
program to determine if an X server is running with a given timeout. It only tries to start the display for 10 seconds and then raises a XStartTimeoutError
.
https://github.com/ponty/PyVirtualDisplay/commit/3b11cf1e1381921c047ba18f4c5d929847f23b84
回答2:
As a workaround 'xdpyinfo' program can be removed on Mac.
Here is a discussion inside the created issue on the project's repository on GitHub: https://github.com/ponty/PyVirtualDisplay/issues/42
Hope it helps someone.
来源:https://stackoverflow.com/questions/59530551/i-have-the-problem-with-pyvirtualdisplay-0-2-5-package-for-running-tests-with-u