1

I am trying to se a Mac (MacOS 10.13.3) to run selenium tests in an headless environment. I am doing basically the following:

from pyvirtualdisplay impot Display
display = Display(visible=0, size=(13660, 7680))
display.start()

before invoking the selenium webdriver (selenum 3.8.0). However, I get the following error:

self = <EasyProcess cmd_param=['Xvfb', '-help'] cmd=['Xvfb', '-help'] oserror=[Errno ... directory return_code=None stdout="None" stderr="None" timeout_happened=False>

    def check_installed(self):
        """Used for testing if program is installed.

            Run command with arguments. Wait for command to complete.
            If OSError raised, then raise :class:`EasyProcessCheckInstalledError`
            with information about program installation

            :param return_code: int, expected return code
            :rtype: self

            """
        try:
            self.call()
        except Exception:
>           raise EasyProcessCheckInstalledError(self)
E           EasyProcessCheckInstalledError: cmd=['Xvfb', '-help']
E           OSError=[Errno 2] No such file or directory
E           Program install error!

venv_pytest/lib/python2.7/site-packages/easyprocess/__init__.py:180: EasyProcessCheckInstalledError

Because it looks like an issue with xvfb I tried to install it:

>pip install xvfb
Collecting xvfb
  Could not find a version that satisfies the requirement xvfb (from versions: )
No matching distribution found for xvfb

I also tried the following:

>brew install xvfb
Error: No available formula with the name "xvfb" 

What else can I try?

Addendum: I am not loking for something else. I am looking to make the above work on a Mac to develop the tests. The tests will run in a sane Linux environment (of course not Mac!!) which is perfectly settled to work with xvfb...

aL_eX
  • 1,453
  • 2
  • 15
  • 30
Alex
  • 41,580
  • 88
  • 260
  • 469
  • Try this https://medium.com/@anotherplanet/how-to-use-headless-chrome-on-apple-osx-d9f7f3a54983 OR https://objectpartners.com/2017/04/13/how-to-install-and-use-headless-chrome-on-osx/?utm_source=hashnode.com – Hiten Feb 02 '18 at 07:26
  • Oh sorry. I cannot try something else. I want to make the above code work. With that `xvfb`. Except maybe its not possible on a Mac at all ... – Alex Feb 02 '18 at 07:28

1 Answers1

3

Xvfb is almost certainly not what you want here.

The macOS desktop interface is not based on X11. Xvfb implements a virtual X11 display; it can only be used to run X11 applications -- none of which are installed by default on macOS.

macOS does not support headless operation. If you want to run Selenium tests on macOS, you will likely need to run them on your desktop.

  • It means I am not able to develop tests and check them headless on a Mac. Is that correct? – Alex Feb 02 '18 at 07:39