Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSX support? #31

Closed
yhslai opened this issue Sep 5, 2012 · 20 comments
Closed

OSX support? #31

yhslai opened this issue Sep 5, 2012 · 20 comments

Comments

@yhslai
Copy link

yhslai commented Sep 5, 2012

On ubuntu you can install xvfb by apt-get install. On OSX, the xvfb is inclued in XQuartz. Though I have installed XQuartz, the headless gem still doesn't work:

Headless::Exception: Xvfb not found on your system

How to tell Headless where is my xvfb?

@leonid-shevtsov
Copy link
Owner

Make sure that xvfb is available in PATH. Headless just calls which xvfb to locate the executable.

Still, this isn't really "OSX support", since xvfb will only work with X applications, which are a very small subset of (ususally non-native) OS X applications.

@kmb89144
Copy link

I followed your guide, and am using headless in object mode, however whenever I launch chrome, it's not actually running headless. I've verified that xvfb is installed (path is /usr/X11/bin/xvfb). I'm using OS X (version 10.7.4).

headless = Headless.new
headless.start
driver = Selenium::WebDriver.for :chrome
driver.navigate.to 'http://www.google.com'

Thanks!

@introvert
Copy link

I have the same problem on OS X Lion (10.8.2). I installed XQuartz and I have xvfb on my hd. When I run the demo code the browser doesn't run headless.
I get no error.

Any idea?

@leonid-shevtsov
Copy link
Owner

I'm sorry, but Headless would only work with applications using the X Server on OSX. Practically any native OSX application uses Quartz, the OSX graphics subsystem, and not X. That includes Chrome and Firefox on OSX.

The X Windowing System is the primary graphics subsystem for Linux, thus most, if not all, graphical Linux apps use the X Server and can be ran "headlessly" with Headless. That includes Chrome and Firefox on Linux.

On OSX the X Server is only included for compatibility (that's why it's not even packaged with 10.8). For example, Wine apps on OSX use the X Server, and some utilities from Linux land do.

If there is a way to run Quartz applications headlessly, then I know nothing about it and supporting Quartz is not a goal of Headless.

Read up here:

http://en.wikipedia.org/wiki/X_server
http://en.wikipedia.org/wiki/Quartz_(graphics_layer)

@introvert
Copy link

Thanks for explanation.
Is there any way to run Firefox headlessly on OS X?

@leonid-shevtsov
Copy link
Owner

If you want to avoid the window popping up when you are running tests, maybe pinning it to a separate Space will help. Or starting it in the background (open --hide /Applications/Firefox.app/Contents/MacOS/firefox)

@introvert
Copy link

Leonid, thanks for this.
Do you maybe know how its possible to launch firefox in the background / in silent mode with Watir?
It doesn't appear that it supports passing arguments to the browser..

@ultrageek
Copy link

PhantomJS runs headlessly on Mac OS X using an agnostic WebKit-based browser. I believe it uses Xvfb to accomplish this? It's been a while, so I'm not 100% sure of the details.

I understand someone has a capybara/phantomjs gem. Not sure if there's a hybrid solution in there for Headless

@tispratik
Copy link

Should we put it in the readme, that headless gem does not support mac osx? As, its confusing people and searching all over to find an answer.

@leonid-shevtsov
Copy link
Owner

But it is right there in the 5th paragraph of the readme. In bold. :)

@tispratik
Copy link

Oh ok, its probably not direct. Headless will not hide :). We can probably say it directly, "headless" is not for mac osx in the very first paragraph.

@leehambley
Copy link

Could it possibly be made not to require XVfb on OSX? it's a bit annoying to have to install a 1.5Gb package, in order to not use it. I'm sure the answer is "Don't use headless on OSX", but building an implementation that swaps out Headless for NotHeadless based on RUBY_PLATFORM seems like something that might be more widely useful than just at my client's place?

@leonid-shevtsov
Copy link
Owner

@leehambley could you elaborate on the problem you're having? If you're not using Headless, why do you need to install Xvfb?

The 1.5G package can't be avoided, because Xvfb is just a small slice of the entire X Server layer, all of which is required for the apps to work.

@leehambley
Copy link

We use headless in the test helper for the city server, so its always
loaded, and in all setup and teardown blocks.

Ideally headless would switch on RUBY_PLATFORM and just do nothing on osx
(ie not even check for xvfb)

On Sep 12, 2013 10:03 AM, "Leonid Shevtsov" [email protected]
wrote:

@leehambley could you elaborate on the problem you're having? If you're
not using Headless, why do you need to install Xvfb?

The 1.5G package can't be avoided, because Xvfb is just a small slice of
the entire X Server layer, all of which is required for the apps to work.


Reply to this email directly or view it on GitHub.

@leonid-shevtsov
Copy link
Owner

OK, I'll think about it.

@ABorovenskyi
Copy link

@daluu
Copy link

daluu commented Jan 17, 2016

FYI, for those pointing out xvfb issue for FF and Chrome on Mac (for Selenium, etc.), you may need to find an x11 build/version of FF (and/or Chrome, but for Mac?), not the standard OS binary/install. This old article is one reference: http://afitnerd.com/2011/09/06/headless-browser-testing-on-mac/

@charleshuang80
Copy link

Using Mac OS X El Capitan. I had installed the latest XQuartz 2.7.9, and when running my tests kept getting Xvfb is frozen (Headless::Exception). I looked all over for fixes to no avail (and this issue page kept popping up in my searches), and just couldn't get xvfb to run. Finally, I came across this post https://discussions.apple.com/thread/7590534?start=0&tstart=0. So I uninstalled XQuartz 2.7.9 (https://xquartz.macosforge.org/trac/wiki/X11-UsersFAQ#UninstallSnowLeopardorLater), and installed XQuartz 2.7.8, and running my tests ran without any errors from headless.

ShockwaveNN added a commit to ONLYOFFICE-QA/onlyoffice_webdriver_wrapper that referenced this issue Nov 20, 2016
Check if platform is not mac
Cannot use headless on mac see:
leonid-shevtsov/headless#31 (comment)

Drop support of low resolution display, srew them.
@molfar
Copy link

molfar commented Jun 20, 2017

is there any fallback for mac os? Just to skip xvfb requirement, without no code change

@0xGuybrush
Copy link

FYI, for those pointing out xvfb issue for FF and Chrome on Mac (for Selenium, etc.), you may need to find an x11 build/version of FF (and/or Chrome, but for Mac?), not the standard OS binary/install. This old article is one reference: http://afitnerd.com/2011/09/06/headless-browser-testing-on-mac/

For reference, this is now at http://old.afitnerd.com/2011/09/06/headless-browser-testing-on-mac/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests