{"id":18944985,"url":"https://github.com/cgoldberg/xvfbwrapper","last_synced_at":"2025-05-14T03:07:39.124Z","repository":{"id":5407882,"uuid":"6598202","full_name":"cgoldberg/xvfbwrapper","owner":"cgoldberg","description":"Manage headless displays with Xvfb (X virtual framebuffer)","archived":false,"fork":false,"pushed_at":"2025-03-30T23:06:37.000Z","size":178,"stargazers_count":301,"open_issues_count":2,"forks_count":52,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-14T18:10:07.656Z","etag":null,"topics":["display","headless","headless-testing","headless-tests","headless-ui","linux","python","python3","x-window-system","x-windows","x11","xvfb"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/xvfbwrapper","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cgoldberg.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-11-08T15:18:08.000Z","updated_at":"2025-04-14T12:48:46.000Z","dependencies_parsed_at":"2022-09-11T12:22:14.748Z","dependency_job_id":null,"html_url":"https://github.com/cgoldberg/xvfbwrapper","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgoldberg%2Fxvfbwrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgoldberg%2Fxvfbwrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgoldberg%2Fxvfbwrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgoldberg%2Fxvfbwrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cgoldberg","download_url":"https://codeload.github.com/cgoldberg/xvfbwrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248933340,"owners_count":21185460,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["display","headless","headless-testing","headless-tests","headless-ui","linux","python","python3","x-window-system","x-windows","x11","xvfb"],"created_at":"2024-11-08T13:00:34.819Z","updated_at":"2025-04-14T18:10:13.972Z","avatar_url":"https://github.com/cgoldberg.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"===============\n    xvfbwrapper\n===============\n\n\n**Manage headless displays with Xvfb (X virtual framebuffer)**\n\n----\n\n---------\n    Info:\n---------\n\n- Development: https://github.com/cgoldberg/xvfbwrapper\n- Releases: https://pypi.org/project/xvfbwrapper\n- Author: `Corey Goldberg \u003chttps://github.com/cgoldberg\u003e`_ - 2012-2025\n- License: MIT\n\n----\n\n----------------------\n    About xvfbwrapper:\n----------------------\n\n`xvfbwrapper` is a python module for controlling virtual displays with Xvfb.\n\n----\n\n------------------\n    What is Xvfb?:\n------------------\n\n`Xvfb` (X virtual framebuffer) is a display server implementing the X11 display server protocol.\nIt runs in memory and does not require a physical display or input devices. Only a network layer is necessary.\n\n`Xvfb` is useful for running acceptance tests on headless servers.\n\n----\n\n----------------------------------\n    Install xvfbwrapper from PyPI:\n----------------------------------\n\n.. code:: bash\n\n    pip install xvfbwrapper\n\n----\n\n------------------------\n    System Requirements:\n------------------------\n\n* Python 3.8+\n* X Window System\n* Xvfb (`sudo apt-get install xvfb`, `yum install xorg-x11-server-Xvfb`, etc)\n* File locking with `fcntl` \n\n----\n\n-------------\n    Examples:\n-------------\n\n****************\n    Basic Usage:\n****************\n\n.. code:: python\n\n    from xvfbwrapper import Xvfb\n\n    vdisplay = Xvfb()\n    vdisplay.start()\n\n    try:\n        # launch stuff inside virtual display here.\n    finally:\n        # always either wrap your usage of Xvfb() with try / finally,\n        # or alternatively use Xvfb as a context manager.\n        # If you don't, you'll probably end up with a bunch of junk in /tmp\n        vdisplay.stop()\n\n----\n\n*********************************************\n    Basic Usage, specifying display geometry:\n*********************************************\n\n.. code:: python\n\n    from xvfbwrapper import Xvfb\n\n    vdisplay = Xvfb(width=1280, height=740)\n    vdisplay.start()\n\n    try:\n        # launch stuff inside virtual display here.\n    finally:\n        vdisplay.stop()\n\n----\n\n*******************************************\n    Basic Usage, specifying display number:\n*******************************************\n\n.. code:: python\n\n    from xvfbwrapper import Xvfb\n\n    vdisplay = Xvfb(display=23)\n    vdisplay.start()\n    # Xvfb is started with display :23\n    # see vdisplay.new_display\n\n----\n\n*******************************\n    Usage as a Context Manager:\n*******************************\n\n.. code:: python\n\n    from xvfbwrapper import Xvfb\n\n    with Xvfb() as xvfb:\n        # launch stuff inside virtual display here.\n        # Xvfb will stop when this block completes\n\n----\n\n********************************************************\n    Usage in Testing: Headless Selenium WebDriver Tests:\n********************************************************\n\nThis test class uses *selenium webdriver* and *xvfbwrapper* to run tests\non Chrome with a headless display.\n\n.. code:: python\n\n    import unittest\n\n    from selenium import webdriver\n    from xvfbwrapper import Xvfb\n\n\n    class TestPages(unittest.TestCase):\n\n        def setUp(self):\n            self.xvfb = Xvfb(width=1280, height=720)\n            self.addCleanup(self.xvfb.stop)\n            self.xvfb.start()\n            self.browser = webdriver.Chrome()\n            self.addCleanup(self.browser.quit)\n\n        def testUbuntuHomepage(self):\n            self.browser.get('https://www.ubuntu.com')\n            self.assertIn('Ubuntu', self.browser.title)\n\n        def testGoogleHomepage(self):\n            self.browser.get('https://www.google.com')\n            self.assertIn('Google', self.browser.title)\n\n\n    if __name__ == '__main__':\n        unittest.main()\n\n* virtual display is launched\n* Chrome launches inside virtual display (headless)\n* browser is not shown while tests are run\n* conditions are asserted in each test case\n* browser quits during cleanup\n* virtual display stops during cleanup\n\n*Look Ma', no browser!*\n\n(You can also take screenshots inside the virtual display to help diagnose test failures)\n\n----\n\n***************************************\n    Usage with multi-threaded execution\n***************************************\n\nTo run several xvfb servers at the same time, you can use the environ keyword\nwhen starting the Xvfb instances. This provides isolation between threads. Be\nsure to use the environment dictionary you initialize Xvfb with in your\nsubsequent system calls. Also, if you wish to inherit your current environment\nyou must use the copy method of os.environ and not simply assign a new\nvariable to os.environ:\n\n.. code:: python\n\n    from xvfbwrapper import Xvfb\n    import subprocess as sp\n    import os\n\n    isolated_environment = os.environ.copy()\n    xvfb = Xvfb(environ=isolated_environment)\n    xvfb.start()\n    sp.run(\n        \"xterm \u0026 sleep 1; kill %1 \",\n        shell=True,\n        env=isolated_environment,\n    )\n    xvfb.stop()\n\n----\n\n----------------------------------------------------\n    xvfbwrapper Development: running the unit tests:\n----------------------------------------------------\n\nTo create a virtual env and install required testing libraries:\n\n.. code:: bash\n\n    $ python -m venv venv\n    $ source ./venv/bin/activate\n    (venv)$ pip install -r requirements_test.txt\n\nTo run all tests, linting, and type checking across all\nsupported/installed Python environments:\n\n.. code:: bash\n\n    (venv)$ tox\n\nTo run all tests in the default Python environment:\n\n.. code:: bash\n\n    (venv)$ pytest\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcgoldberg%2Fxvfbwrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcgoldberg%2Fxvfbwrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcgoldberg%2Fxvfbwrapper/lists"}