6

Note I have already looked at the following sources:

easyprocess.EasyProcessCheckInstalledError: cmd=['Xvfb', '-help'] OSError=[Errno 2] No such file or directory

How do I run Selenium in Xvfb?

Which did not solve my problem.

I am using:

  • Python 2.7
  • selenium 3.0.2
  • xvfbwrapper 0.2.9
  • PyVirtualDisplay 0.2.1

Running on Mac OSX El Capitan (10.11.6 (15G1108))

I get the following error (which is the same one that is in the above link):

Traceback (most recent call last):
  File "/Users/user/Desktop/test.py", line 50, in <module>
    display = Display(visible=0, size=(800, 600))
  File "/Library/Python/2.7/site-packages/pyvirtualdisplay/display.py", line 34, in __init__
    self._obj = self.display_class(
  File "/Library/Python/2.7/site-packages/pyvirtualdisplay/display.py", line 52, in display_class
    cls.check_installed()
  File "/Library/Python/2.7/site-packages/pyvirtualdisplay/xvfb.py", line 38, in check_installed
    ubuntu_package=PACKAGE).check_installed()
  File "/Library/Python/2.7/site-packages/easyprocess/__init__.py", line 180, in check_installed
    raise EasyProcessCheckInstalledError(self)
EasyProcessCheckInstalledError: cmd=['Xvfb', '-help']
OSError=[Errno 2] No such file or directory
Program install error! 

I know I have Xvfb installed as well:

Xvfb -help
use: X [:<display>] [option]
-a #                   default pointer acceleration (factor)
-ac                    disable access control restrictions
-audit int             set audit trail level
-auth file             select authorization file
-br                    create root window with black background
+bs                    enable any backing store support
-bs                    disable any backing store support
-c                     turns off key-click
...
-pixdepths list-of-int support given pixmap depths
+/-render          turn on/off RENDER extension support(default on)
-linebias n            adjust thin line pixelization
-blackpixel n          pixel value for black
-whitepixel n          pixel value for white
-fbdir directory       put framebuffers in mmap'ed files in directory
-shmem                 put framebuffers in shared memory

If the pip install is looking for xvfb in a different directory, some guidance would be appreciated as to how to redirect where it's looking.

Here is my code:

from easyprocess import EasyProcess
from pyvirtualdisplay import Display
from selenium import webdriver

display = Display(visible=0, size=(800, 600))
display.start()

# now Firefox will run in a virtual display. 
# you will not see the browser.
browser = webdriver.Firefox()
browser.get('http://www.google.com')
print browser.title
browser.quit()

display.stop()

I've done countless pip installs and google searches and nothing has helped so far, the ultimate end goal is to have a headless automation that is capable of handling downloads, something PhantomJS is unable to do. Any help in that subject would be appreciated as well.

3
  • you can't use this on osx Commented Jan 11, 2017 at 20:38
  • @CoreyGoldberg What can I use? I defected to casperjs but if I want to use python how can I run it headless on OSX? Commented Jan 11, 2017 at 20:48
  • Chrome just released their headless version with version 59+. You can check this out. Commented May 26, 2017 at 7:15

1 Answer 1

2

I dont see why you cant use this with osx, I have done that in past. But I have a better solution. Why dont you use docker + VNC . install any browser of your choice and run everything in the background Advantage: 1. Everything runs in the background. 2. Monitor execution in the browser with VNC web view 3. launch as many container as you want for parallel execution.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.