Question

I am trying to execute my Selenium Scripts through cron headlessly using Xvfb. The code of shell script looks something like this

export PATH=$PATH
Xvfb :10 -ac &
gnome-terminal -e export DISPLAY=:10 &
gnome-terminal -e firefox &
gnome-terminal -e export DISPLAY=:10 &
gnome-terminal -e firefox &
cd wait/test/
sh deploy.sh

But I am getting an eror something like this :

Failed to parse arguments: Cannot open display: 
Failed to parse arguments: Cannot open display: 
Failed to parse arguments: Cannot open display: 
Failed to parse arguments: Cannot open display: 
[dix] Could not init font path element /usr/share/fonts/X11/cyrillic, removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/100dpi/:unscaled, removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/75dpi/:unscaled, removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/100dpi, removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/75dpi, removing from list!
[dix] Could not init font path element /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType, removing from list!
Traceback (most recent call last):
  File "runner.py", line 7, in <module>
    from test import root
  File "/home/user/Tests/redirect/wait/test/ScrapyCrawl/test.py", line 47, in <module>
    class root (unittest.TestCase):
  File "/home/user/Tests/redirect/wait/test/ScrapyCrawl/test.py", line 49, in root
    driver = webdriver.Firefox ()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 59, in __init__
    self.binary, timeout),
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
    self.binary.launch_browser(self.profile)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 61, in launch_browser
    self._wait_until_connectable()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 100, in _wait_until_connectable
    self._get_firefox_output())
selenium.common.exceptions.WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: no display specified\n' 

Any help would be appreciated. Thanks.

Was it helpful?

Solution

I used pyvirtualdisplay to solve this problem. It is a a Python wrapper for Xvfb and Xephyr. More info can be found here : pyvirtualdisplay

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top