{"id":29988,"date":"2024-01-01T16:34:34","date_gmt":"2024-01-01T11:04:34","guid":{"rendered":"http:\/\/www.pythonpool.com\/?p=29988"},"modified":"2024-01-01T16:37:42","modified_gmt":"2024-01-01T11:07:42","slug":"pyvirtualdisplay","status":"publish","type":"post","link":"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/","title":{"rendered":"PyVirtualDisplay: A Guide to Virtual Displays in Python"},"content":{"rendered":"\n<p>Pyvirtualdisplay is one of the most commonly used libraries to run headless tests for applications without a Graphical User Interface. Go through this article to learn more about this Python library. <\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #990303;color:#990303\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#What_is_headless_testing\" >What is headless testing?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#About_pyvirtualdisplay\" >About pyvirtualdisplay<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#Installing_pyvirtualdisplay\" >Installing pyvirtualdisplay<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#Features_of_pyvirtualdisplay\" >Features of pyvirtualdisplay<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#Locating_elements_with_pyvirtualdisplay\" >Locating elements with pyvirtualdisplay<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#pyvirtualdisplay_with_ubuntu\" >pyvirtualdisplay with ubuntu<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#Keystrokes_with_pyvirtualdisplay\" >Keystrokes with pyvirtualdisplay<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#pyvirtualdisplay_installation_on_Anaconda\" >pyvirtualdisplay installation on Anaconda<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#Working_with_Jupyter_Notebook_or_Spyder_IDE\" >Working with Jupyter Notebook or Spyder IDE<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#pyvirtualdisplay_selenium\" >pyvirtualdisplay selenium<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#pyvirtualdisplay_mac\" >pyvirtualdisplay mac<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#pyvirtualdisplay_xvfb\" >pyvirtualdisplay xvfb<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#pyvirtualdisplay_colab\" >pyvirtualdisplay colab<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#FAQs_on_Pyvirtualdisplay\" >FAQs on Pyvirtualdisplay<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#Trending_Now\" >Trending Now<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-what-is-headless-testing\"><span class=\"ez-toc-section\" id=\"What_is_headless_testing\"><\/span>What is headless testing?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This is a type of testing that exists without GUI, i.e., Graphical User Interface.  In this type of testing, no interaction is needed. It is faster than the old testing methods and is used to test the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Web applications  <\/li>\n\n\n\n<li>APIs<\/li>\n\n\n\n<li>Embedded systems<\/li>\n\n\n\n<li>Mobile Applications <\/li>\n<\/ul>\n\n\n\n<p>It has the following workflow:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The web application receives requests from the headless testing script. <\/li>\n\n\n\n<li>The web app redirects to a webpage.<\/li>\n\n\n\n<li>The test checks the script of the webpage and goes through its content.<\/li>\n<\/ul>\n\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-juliett monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-image\"><a href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-cant-compare-datetime-datetime-to-datetime-date\/\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_.webp 1200w \" alt=\"[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date\" \/><\/a><\/div><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Trending<\/span><span class=\"monsterinsights-inline-popular-posts-border\" ><\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-cant-compare-datetime-datetime-to-datetime-date\/\">[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-about-pyvirtualdisplay\"><span class=\"ez-toc-section\" id=\"About_pyvirtualdisplay\"><\/span>About pyvirtualdisplay <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>pyvirtualdisplay is a headless testing framework. Some frameworks don&#8217;t support Graphical User Interface. The pyvirtualdisplay library can help one run tests based on the Graphical User Interface. It basically makes a false terminal. This is also referred to as pseudo-terminal. This library works on the Xvfb X server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-installing-pyvirtualdisplay\"><span class=\"ez-toc-section\" id=\"Installing_pyvirtualdisplay\"><\/span>Installing pyvirtualdisplay <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Use the pip command to install the pyvirtualdisplay library. Import it and then use the display function to create a virtual display. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\npip install PyVirtualDisplay\nimport pyvirtualdisplay\ndisplay = pyvirtualdisplay.Display()\n<\/pre><\/div>\n\n\n<p>After running the tests and checking the working of your web application, you can close this with the help of stop() command.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\ndisplay.stop()\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-features-of-pyvirtualdisplay\"><span class=\"ez-toc-section\" id=\"Features_of_pyvirtualdisplay\"><\/span>Features of pyvirtualdisplay <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The pyvirtualdisplay library of Python is all about ease. It has the following features:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Feasibility <\/li>\n\n\n\n<li>Efficiency <\/li>\n\n\n\n<li>Portability<\/li>\n<\/ul>\n\n\n\n<p>This library is suitable for all platforms like Windows, Mac OS, and Linux. GUI-based <a href=\"http:\/\/www.pythonpool.com\/python-testing-framework\/\" target=\"_blank\" rel=\"noreferrer noopener\">testing frameworks<\/a>, like Selenium and PyQt, can work with pyvirtualdisplay and support its functions. It&#8217;s quite versatile and doesn&#8217;t need a large number of results.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-locating-elements-with-pyvirtualdisplay\"><span class=\"ez-toc-section\" id=\"Locating_elements_with_pyvirtualdisplay\"><\/span>Locating elements with pyvirtualdisplay <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>While testing of web apps is going on, you might need to check the ID, class, name, XPath, or other such elements. Thus, locating elements is necessary. There exist a few functions through which you can locate elements on a web application. These are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>evaluate()<\/li>\n\n\n\n<li>getElementsByName()<\/li>\n\n\n\n<li>getElementsByClassName()<\/li>\n\n\n\n<li>getElementById()<\/li>\n<\/ul>\n\n\n\n<p>An ID is a unique element on a webpage. So, you may use it to locate the element you want. In the same manner, you can check for elements with the same CSS class or name attribute. The evaluate() function is used with XPath. It tells about the location of the element inside the DOM tree. <\/p>\n\n\n\n<p>Let&#8217;s consider an example of the same. First, you need to import pyvirtualdisplay and selenium libraries. Next, you need to create a virtual display using the start() function and a webdriver instance. Provide the link to the webpage and locate the element using any of the above-mentioned functions. Use the click() function to interact and stop() at the end. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport pyvirtualdisplay\nimport selenium\n\ndef locate_and_click_element(url, element_id):\n    &quot;&quot;&quot;Locates and clicks on an element on a web page using pyvirtualdisplay and selenium.\n\n    Args:\n        url: The URL of the web page.\n        element_id: The ID of the element to locate and click.\n    &quot;&quot;&quot;\n\n    display = pyvirtualdisplay.Display()\n    display.start()\n\n    driver = selenium.webdriver.Chrome()\n    driver.get(url)\n\n    element = driver.find_element_by_id(element_id)\n    element.click()\n\n    display.stop()\n\nif __name__ == &quot;__main__&quot;:\n    url = &quot;https:\/\/www.example.com&quot;\n    element_id = &quot;my_element&quot;\n\n    locate_and_click_element(url, element_id)\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-pyvirtualdisplay-with-ubuntu\"><span class=\"ez-toc-section\" id=\"pyvirtualdisplay_with_ubuntu\"><\/span>pyvirtualdisplay with ubuntu <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you are an Ubuntu user and wish to work with the pyvirtualdisplay library, use the first command to update the packages. Then, install the pyvirtualdisplay library using the second command. The third command lets you check whether the library has been correctly installed or not.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nsudo apt update\nsudo apt install python3-pyvirtualdisplay\npython3 -m pip show pyvirtualdisplay\n<\/pre><\/div>\n\n\n<p>The rest of the usage is the same.  For example, if you are trying to create a simple web app and do its testing, you may check the given code:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport pyvirtualdisplay\n\ndisplay = pyvirtualdisplay.Display()\ndisplay.start()\n\nimport webbrowser\nwebbrowser.open(&quot;https:\/\/www.abc.com&quot;)\n\ndisplay.stop()\n<\/pre><\/div>\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-juliett monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-image\"><a href=\"https:\/\/www.pythonpool.com\/fixed-nameerror-name-unicode-is-not-defined\/\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined.webp 1200w \" alt=\"[Fixed] nameerror: name Unicode is not defined\" \/><\/a><\/div><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Trending<\/span><span class=\"monsterinsights-inline-popular-posts-border\" ><\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/fixed-nameerror-name-unicode-is-not-defined\/\">[Fixed] nameerror: name Unicode is not defined<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-keystrokes-with-pyvirtualdisplay\"><span class=\"ez-toc-section\" id=\"Keystrokes_with_pyvirtualdisplay\"><\/span>Keystrokes with pyvirtualdisplay <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Sometimes, you might want to use a web driver instance to test your web browser. This means that you can test your web browser with the help of a script without manually testing it.<\/p>\n\n\n\n<p>You can use pyvirtualdisplay and <a href=\"http:\/\/www.pythonpool.com\/selenium-python\/\" target=\"_blank\" rel=\"noreferrer noopener\">selenium<\/a> libraries to send keystrokes. Use the display() function to curate a virtual display, as explained earlier. After this, you need to make a web driver instance. This example shows Chrome driver instance creation. Specify the website and use the send_keys() function to send keystrokes. Lastly, the stop() function ends the virtual display. <\/p>\n\n\n\n<p>The given example uses a function send_keystrokes that accepts two parameters: URL and keystrokes. It creates a script that you may use to send keystrokes. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport pyvirtualdisplay\nimport selenium\n\ndef send_keystrokes(url, keystrokes):\n    &quot;&quot;&quot;Sends keystrokes to a web page using pyvirtualdisplay and selenium.\n\n    Args:\n        url: The URL of the web page.\n        keystrokes: The keystrokes to send.\n    &quot;&quot;&quot;\n\n    display = pyvirtualdisplay.Display()\n    display.start()\n\n    driver = selenium.webdriver.Chrome()\n    driver.get(url)\n\n    driver.send_keys(keystrokes)\n\n    display.stop()\n\nif __name__ == &quot;__main__&quot;:\n    url = &quot;https:\/\/www.abc.com&quot;\n    keystrokes = &quot;test.&quot;\n\n    send_keystrokes(url, keystrokes)\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-pyvirtualdisplay-installation-on-anaconda\"><span class=\"ez-toc-section\" id=\"pyvirtualdisplay_installation_on_Anaconda\"><\/span>pyvirtualdisplay installation on Anaconda <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you are an Anaconda user, you should first activate the environment. Post this, install the package, and using the third command, check whether this package has been installed successfully. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nsource activate &#x5B;environment_name]\nconda install pyvirtualdisplay\nconda list pyvirtualdisplay\n<\/pre><\/div>\n\n\n<p>The output will be in this format:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\npyvirtualdisplay   3.0-py39haa244fe_3\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-working-with-jupyter-notebook-or-spyder-ide\"><span class=\"ez-toc-section\" id=\"Working_with_Jupyter_Notebook_or_Spyder_IDE\"><\/span>Working with Jupyter Notebook or Spyder IDE  <span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Now, whether it&#8217;s a Jupyter Notebook or Spyder IDE, you can create the virtual display using this library easily. Check the sample code for help:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport pyvirtualdisplay\n\ndisplay = pyvirtualdisplay.Display()\ndisplay.start()\n\n# Run your  code here\n\ndisplay.stop()\n<\/pre><\/div>\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-golf monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Popular now<\/span><span class=\"monsterinsights-inline-popular-posts-border\" ><\/span><span class=\"monsterinsights-inline-popular-posts-border-2\" ><\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/solved-runtimeerror-cuda-error-invalid-device-ordinal\/\">[Solved] runtimeerror: cuda error: invalid device ordinal<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-pyvirtualdisplay-selenium\"><span class=\"ez-toc-section\" id=\"pyvirtualdisplay_selenium\"><\/span>pyvirtualdisplay selenium<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you are working with pyvirtualdisplay on selenium, you should create a backend for pyvirtualdisplay. Take the help of either xvfb or xephyr. Run the &#8216;sudo apt-get install xvfb xserver-xephyr&#8217; command in your terminal. <\/p>\n\n\n\n<p>Another thing to note is that your website may be dynamically built.  Thus, it might take some time for pyvirtualdisplay to load. In this scenario,  you can use the sleep function. time.sleep() works well. <\/p>\n\n\n\n<p>There&#8217;s an alternative to the sleep() function too. The browser.implicitly_wait(20) function adds a 20-second wait time automatically to the browser. You can adjust according to your requirements and the content on the webpage.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-pyvirtualdisplay-mac\"><span class=\"ez-toc-section\" id=\"pyvirtualdisplay_mac\"><\/span>pyvirtualdisplay mac<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In order to work on Mac with pyvirtualdisplay, you need to install XQuartz first. The brew install &#8211;cask xquartz command will let you run graphical applications on a remote server. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-pyvirtualdisplay-xvfb\"><span class=\"ez-toc-section\" id=\"pyvirtualdisplay_xvfb\"><\/span>pyvirtualdisplay xvfb<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The xvfb server doesn&#8217;t require a proper browser. If you wish to utilize the pyvirtualdisplay library on xvfb server,  you should first install it. The following commands can be used:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nsudo apt install xvfb \n# Ubuntu\/Debian\nsudo yum install xorg-x11-server-xvfb \n# Fedora\/Red Hat\n<\/pre><\/div>\n\n\n<p>Once this process is complete, you can create a virtual display with the help of pyvirtualdisplay.  <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfrom pyvirtualdisplay import Display\n\ndisplay = Display(visible=0, size=(1024, 768))\ndisplay.start()\n\n# Run your graphical application here\n\ndisplay.stop()\n<\/pre><\/div>\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-alpha monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Trending<\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-type-numpy-ndarray-doesnt-define-__round__-method\/\">[Fixed] typeerror: type numpy.ndarray doesn&#8217;t define __round__ method<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-pyvirtualdisplay-colab\"><span class=\"ez-toc-section\" id=\"pyvirtualdisplay_colab\"><\/span>pyvirtualdisplay colab<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>pyvirtualdisplay might be a bit slow on <a href=\"https:\/\/colab.google\/\" target=\"_blank\" rel=\"noreferrer noopener\">colab<\/a>. This is because colab can&#8217;t be properly used to create the virtual display. You can use matplotlib or any such library to analyze the work. However, as a basic step, you should consider the installation part.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n!pip install pyvirtualdisplay\n!apt update &amp;&amp; !apt install -y xvfb python-opengl ffmpeg\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-faqs-on-pyvirtualdisplay\"><span class=\"ez-toc-section\" id=\"FAQs_on_Pyvirtualdisplay\"><\/span>FAQs on Pyvirtualdisplay<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1699539304149\"><strong class=\"schema-faq-question\">How does pyvirtualdisplay work?<\/strong> <p class=\"schema-faq-answer\">It creates a false terminal first and then creates a virtual display with the help of the Xvfb X server.<\/p> <\/div> <\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><div>Conclusion <\/div><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This article explains the pyvirtualdisplay library of Python in detail.  Succinctly, it elaborates on the workings of this library and its functions. Also, it explains how the library works with the formation of scripts, in a colab environment, on Selenium, and on Mac. <\/p>\n\n\n<div class=\"monsterinsights-widget-popular-posts monsterinsights-widget-popular-posts-delta monsterinsights-popular-posts-styled monsterinsights-widget-popular-posts-columns-2\"><h2 class=\"monsterinsights-widget-popular-posts-widget-title\"><span class=\"ez-toc-section\" id=\"Trending_Now\"><\/span>Trending Now<span class=\"ez-toc-section-end\"><\/span><\/h2><ul class=\"monsterinsights-widget-popular-posts-list\"><li ><a href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-cant-compare-datetime-datetime-to-datetime-date\/\"><div class=\"monsterinsights-widget-popular-posts-image\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_.webp 1200w \" alt=\"[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date\" \/><\/div><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" >[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><span class=\"monsterinsights-widget-popular-posts-author\">by Namrata Gulati<\/span><span>&#9679;<\/span><span class=\"monsterinsights-widget-popular-posts-date\">January 11, 2024<\/span><\/div><\/div><\/a><\/li><li ><a href=\"https:\/\/www.pythonpool.com\/fixed-nameerror-name-unicode-is-not-defined\/\"><div class=\"monsterinsights-widget-popular-posts-image\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined.webp 1200w \" alt=\"[Fixed] nameerror: name Unicode is not defined\" \/><\/div><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" >[Fixed] nameerror: name Unicode is not defined<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><span class=\"monsterinsights-widget-popular-posts-author\">by Namrata Gulati<\/span><span>&#9679;<\/span><span class=\"monsterinsights-widget-popular-posts-date\">January 2, 2024<\/span><\/div><\/div><\/a><\/li><li ><a href=\"https:\/\/www.pythonpool.com\/solved-runtimeerror-cuda-error-invalid-device-ordinal\/\"><div class=\"monsterinsights-widget-popular-posts-image\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal.webp 1200w \" alt=\"[Solved] runtimeerror: cuda error: invalid device ordinal\" \/><\/div><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" >[Solved] runtimeerror: cuda error: invalid device ordinal<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><span class=\"monsterinsights-widget-popular-posts-author\">by Namrata Gulati<\/span><span>&#9679;<\/span><span class=\"monsterinsights-widget-popular-posts-date\">January 2, 2024<\/span><\/div><\/div><\/a><\/li><li ><a href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-type-numpy-ndarray-doesnt-define-__round__-method\/\"><div class=\"monsterinsights-widget-popular-posts-image\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method.webp 1200w \" alt=\"[Fixed] typeerror: type numpy.ndarray doesn&#8217;t define __round__ method\" \/><\/div><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" >[Fixed] typeerror: type numpy.ndarray doesn&#8217;t define __round__ method<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><span class=\"monsterinsights-widget-popular-posts-author\">by Namrata Gulati<\/span><span>&#9679;<\/span><span class=\"monsterinsights-widget-popular-posts-date\">January 2, 2024<\/span><\/div><\/div><\/a><\/li><\/ul><\/div><p><\/p>","protected":false},"excerpt":{"rendered":"<p>Pyvirtualdisplay is one of the most commonly used libraries to run headless tests for applications without a Graphical User Interface. Go through this article to &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"PyVirtualDisplay: A Guide to Virtual Displays in Python\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#more-29988\" aria-label=\"More on PyVirtualDisplay: A Guide to Virtual Displays in Python\">Read more<\/a><\/p>\n","protected":false},"author":38,"featured_media":31668,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4345],"tags":[],"class_list":["post-29988","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-module","infinite-scroll-item"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v25.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PyVirtualDisplay: A Guide to Virtual Displays in Python - Python Pool<\/title>\n<meta name=\"description\" content=\"pyvirtualdisplay is one of the commonly used libraries to run headless tests. Go through this blog to know more about this Python library.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PyVirtualDisplay: A Guide to Virtual Displays in Python\" \/>\n<meta property=\"og:description\" content=\"Pyvirtualdisplay is one of the most commonly used libraries to run headless tests for applications without a Graphical User Interface. Go through this\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-01T11:04:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-01T11:07:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/PyVirtualDisplay.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Namrata Gulati\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Namrata Gulati\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/\"},\"author\":{\"name\":\"Namrata Gulati\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/294338f378f0853e6af4ca4a5a907ea6\"},\"headline\":\"PyVirtualDisplay: A Guide to Virtual Displays in Python\",\"datePublished\":\"2024-01-01T11:04:34+00:00\",\"dateModified\":\"2024-01-01T11:07:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/\"},\"wordCount\":1023,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/PyVirtualDisplay.webp\",\"articleSection\":[\"Module\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#respond\"]}]},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/\",\"url\":\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/\",\"name\":\"PyVirtualDisplay: A Guide to Virtual Displays in Python - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/PyVirtualDisplay.webp\",\"datePublished\":\"2024-01-01T11:04:34+00:00\",\"dateModified\":\"2024-01-01T11:07:42+00:00\",\"description\":\"pyvirtualdisplay is one of the commonly used libraries to run headless tests. Go through this blog to know more about this Python library.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#faq-question-1699539304149\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/PyVirtualDisplay.webp\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/PyVirtualDisplay.webp\",\"width\":1200,\"height\":628,\"caption\":\"PyVirtualDisplay\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PyVirtualDisplay: A Guide to Virtual Displays in Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pythonpool.com\/#website\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"name\":\"Python Pool\",\"description\":\"Your One-Stop Python Learning Destination\",\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pythonpool.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pythonpool.com\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/294338f378f0853e6af4ca4a5a907ea6\",\"name\":\"Namrata Gulati\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/19c5e6bfbc6202d4017b79f726b2ad5e520491d67ff428a87c071afef23ecd89?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/19c5e6bfbc6202d4017b79f726b2ad5e520491d67ff428a87c071afef23ecd89?s=96&d=wavatar&r=g\",\"caption\":\"Namrata Gulati\"}},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#faq-question-1699539304149\",\"position\":1,\"url\":\"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#faq-question-1699539304149\",\"name\":\"How does pyvirtualdisplay work?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"It creates a false terminal first and then creates a virtual display with the help of the Xvfb X server.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"PyVirtualDisplay: A Guide to Virtual Displays in Python - Python Pool","description":"pyvirtualdisplay is one of the commonly used libraries to run headless tests. Go through this blog to know more about this Python library.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/","og_locale":"en_US","og_type":"article","og_title":"PyVirtualDisplay: A Guide to Virtual Displays in Python","og_description":"Pyvirtualdisplay is one of the most commonly used libraries to run headless tests for applications without a Graphical User Interface. Go through this","og_url":"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/","og_site_name":"Python Pool","article_published_time":"2024-01-01T11:04:34+00:00","article_modified_time":"2024-01-01T11:07:42+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/PyVirtualDisplay.webp","type":"image\/webp"}],"author":"Namrata Gulati","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Namrata Gulati","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#article","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/"},"author":{"name":"Namrata Gulati","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/294338f378f0853e6af4ca4a5a907ea6"},"headline":"PyVirtualDisplay: A Guide to Virtual Displays in Python","datePublished":"2024-01-01T11:04:34+00:00","dateModified":"2024-01-01T11:07:42+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/"},"wordCount":1023,"commentCount":0,"publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/PyVirtualDisplay.webp","articleSection":["Module"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#respond"]}]},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/","url":"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/","name":"PyVirtualDisplay: A Guide to Virtual Displays in Python - Python Pool","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#primaryimage"},"image":{"@id":"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/PyVirtualDisplay.webp","datePublished":"2024-01-01T11:04:34+00:00","dateModified":"2024-01-01T11:07:42+00:00","description":"pyvirtualdisplay is one of the commonly used libraries to run headless tests. Go through this blog to know more about this Python library.","breadcrumb":{"@id":"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#faq-question-1699539304149"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pythonpool.com\/pyvirtualdisplay\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#primaryimage","url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/PyVirtualDisplay.webp","contentUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/PyVirtualDisplay.webp","width":1200,"height":628,"caption":"PyVirtualDisplay"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"PyVirtualDisplay: A Guide to Virtual Displays in Python"}]},{"@type":"WebSite","@id":"https:\/\/www.pythonpool.com\/#website","url":"https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/pythonpool","https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/294338f378f0853e6af4ca4a5a907ea6","name":"Namrata Gulati","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/19c5e6bfbc6202d4017b79f726b2ad5e520491d67ff428a87c071afef23ecd89?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/19c5e6bfbc6202d4017b79f726b2ad5e520491d67ff428a87c071afef23ecd89?s=96&d=wavatar&r=g","caption":"Namrata Gulati"}},{"@type":"Question","@id":"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#faq-question-1699539304149","position":1,"url":"https:\/\/www.pythonpool.com\/pyvirtualdisplay\/#faq-question-1699539304149","name":"How does pyvirtualdisplay work?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"It creates a false terminal first and then creates a virtual display with the help of the Xvfb X server.","inLanguage":"en-US"},"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/29988","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=29988"}],"version-history":[{"count":123,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/29988\/revisions"}],"predecessor-version":[{"id":31674,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/29988\/revisions\/31674"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/31668"}],"wp:attachment":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=29988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=29988"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=29988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}