9 ms·
Firefox 56 supports headless mode on Windows
- anotheryou 9y agoSo I can navigate by cardinal directions now (like scrolling south a bit)? Joke aside: can somone explain "headless" to me here?
- curiousgal 9y agoA headless browser is a web browser without a GUI. Extremely useful in web testing/scrapping.
- kozhevnikov 9y agoThe same reasons as Chrome headless [1] but with Gecko engine. [1] https://developers.google.com/web/updates/2017/04/headless-chrome https://developers.google.com/web/updates/2017/04/headless-c...
- majewsky 9y agoWhen you run the browser, but it doesn't actually display anything on screen. Uses include rendering a screenshot (e.g. a preview thumbnail) of some website on a server, or running automated UI tests that click around a web app and fill out forms to verify its functionality.
- jshelly 9y agoThank you for taking the time to explain. I had the same question.
- scardine 9y agoIs there a linux headless mode already? Selenium chrome driver headless is pretty much useless in linux because important methods like `send_keys` need X anyway for keyboard mappings or something like that.
- dao- 9y agohttps://bugzilla.mozilla.org/show_bug.cgi?id=1356681 https://bugzilla.mozilla.org/show_bug.cgi?id=1356681 Support headless flag on Linux, RESOLVED FIXED in Firefox 55
- deleted 9y ago[deleted]
- tyingq 9y agoThere is a bug filed against the chrome driver send_keys issue, and a workaround...one that requires recompiling though. https://bugs.chromium.org/p/chromedriver/issues/detail?id=1772 https://bugs.chromium.org/p/chromedriver/issues/detail?id=17...
- arwineap 9y agorecompiling does solve the issue though If you are blocked it may be worth a look
- RJIb8RBYxzAMX9u 9y agoGenuine noob question: could you not use Xvfb?
- zlagen 9y agoDo you need to use selenium to control Firefox in headless mode or does it have something lower level like Chrome's devtools protocol?
- codefined 9y agoYou can use use WebDriver/GeckoDriver[0], which is how Selenium actually runs, but most people like the abstraction layer. [0] https://github.com/mozilla/geckodriver https://github.com/mozilla/geckodriver
- masklinn 9y ago1. You can use the WebDriver protocol[0] without selenium 2. Firefox's WebDriver endpoint geckodriver[1] is a layer above Firefox/Gecko's native Marionette protocol[2] So you doubly don't need to use selenium, you can write your own WebDriver client (which should be cross-browser assuming the browsers either support WebDriver natively or have a WD layer of some sort installed) or you can use raw Marionette (either a hand-rolled client or an existing client) [0] https://w3c.github.io/webdriver/webdriver-spec.html#protocol https://w3c.github.io/webdriver/webdriver-spec.html#protocol [1] https://github.com/mozilla/geckodriver https://github.com/mozilla/geckodriver [2] https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionet...
- brendandahl 9y agoPatch author here: To add to the other comments, you could also use SlimerJS[1]. Though I don't know if I'd consider that lower level. We're open to supporting other ways of controlling FIrefox and have been gauging feedback on what to support. [1]https://slimerjs.org/ https://slimerjs.org/
- jalfresi 9y agoHow is it controlled when in headless mode? Still via Webdriver or does Firefox support Chrome Debugger Protocol?
- masklinn 9y ago> Still via Webdriver WebDriver or Marionette.
- arunitc 9y agoI was wondering if I could use this (using a plugin) or Chrome to generate PDF files on the web server. Most of the PDF generation software out there are quite expensive.
- boredpudding 9y agoMaybe it's possible with the print option Chrome offers. Regular Chrome can print to PDF files. Maybe headless Chrome supports that. Edit: It's possible. It's on the introduction page of Chrome Headless https://developers.google.com/web/updates/2017/04/headless-chrome https://developers.google.com/web/updates/2017/04/headless-c... Look at 'Create a PDF'
- robk 9y agoHere's a simple library to do that: https://github.com/LucianoGanga/simple-headless-chrome https://github.com/LucianoGanga/simple-headless-chrome
- mchiron 9y agoWe use wkhtmltopdf to do this server side. It as a few problems and quirks, but it work well enough for us.
- pilif 9y agoit has a lot of quirks, and, frankly, webkit is pretty bad at printing in general as it lacks a ton of printing specific features like re-printing table headers across page boundaries. There's also only very rudimentary support for page headers and footers. wkhtmktopdf is probably ok if you just need a quick single page invoice printout, but the moment you need more (in our case, we definitely do), I can highly recommend paying for https://www.princexml.com/ https://www.princexml.com/ which has support for a lot of printing specific features.
- veza 9y agowkhtmltopdf works quite well for us, even with modern web technologies. Here's an example fully rendered in React: https://s3.amazonaws.com/ud-reports/comps-report-86.pdf https://s3.amazonaws.com/ud-reports/comps-report-86.pdf And one with svg charts: https://s3.amazonaws.com/ud-reports/chart-report-89.pdf https://s3.amazonaws.com/ud-reports/chart-report-89.pdf With -webkit- prefixes you can use even flexbox, and and with js polyfills you'll have all you need. Of course if I would start a project now, I would use chrome headless, but I don't feel wkhtmltopdf is that bad.
- jscholes 9y agoAnyone know if this supports audio playback?
- padenot 9y agoFirefox audio developer here. I haven't heard from the folks doing this, and I would have been the person doing the code reviews so I suppose it's left untouched. Edit: looking at the code, it will work just fine, and that means I can even use it myself to run Firefox's unit and integration tests, I usually use xvfb on Linux.
- pmlnr 9y ago"headless" Poke me when there are no X11/Qt/GTK/whatever dependencies at all - that is headless. https://packages.debian.org/stretch/firefox-esr https://packages.debian.org/stretch/firefox-esr
- swiley 9y agoThis got down voted a lot but GTK is really a pretty painful dependency in many situations (especially gtk3) Not that Firefox itself is particularly lightweight.
- baldfat 9y agoIf your running this on a server sure great. On desktop that is next to pointless due to the need for those dependencies for everything besides cure apps.
- jmull 9y agoI think the goal is to have a browser that renders web pages and is fully interactive, but just doesn't render to screen and is interactive through an API rather than input devices. So it's going to need a UI rendering and interaction library.
- whysohard 9y agoWhat are the biggest challenges when implementing headless mode? I'm asking cause this feature took some time to be delivered both in Firefox and Chrome and I always assumed that it should be 'pretty' straightforward to implement. Is it that both engines were coupled with GUI libs?
- tehbeard 9y agoMy money would be on it being a low priority feature than being difficult to implement.
- reubenmorais 9y agoProbably just good old software engineering. Getting a 15-20 million SLOC codebase to work in an environment it wasn't designed to handle takes time.
- bzbarsky 9y agoThere are a bunch of things which are tied to native GUI libs in ways that make headless a little annoying to implement. Some examples, from memory and looking at the patches/dependencies in the Firefox bugs on this: 1) Theming of form controls to make them look like native widgets. 2) Clipboard. 3) Printing. 4) Fonts and font rendering. 5) General "now it's time to repaint" machinery. This is in no way an exhaustive list. In practice what you have to do for headless is create the relevant GUI bits anyway, but not actually show them on screen, then deal with whatever quirks your GUI library has when its bits are not shown.
- brendandahl 9y agoPatch author here. bzbarsky's comment covered most of it. It hasn't turned out to be that difficult. On linux, it was mostly playing whack-a-mole of avoiding calls in to gtk/x11 and then creating headless implementations of the platform specific code. One slight complication of headless has been wiring up the headless "widgets" (in Firefox, we refer to most of the platform specific code as widgets e.g. there's gtk widgets, cocoa widgets, windows widgets). Usually the widget type is defined statically at build time, but in the case of headless we wanted Firefox to either use the headless widgets or the platform specific widgets at runtime. Luckily, some of the work on multi-process Firefox work also added another type of widget and made it much easier to support multiple types of widgets. Overall, the hardest part has been trying to replicate all the events that would normally be triggered by the platform gui code. I've also found that these events and order can vary per platform which makes it hard to do in a non-platform specific way. We're still working out some issues here.
- robk 9y agoIt's not very clear how to actually use this in a test environment like Selenium etc. At least with headless Chrome there are libraries now to drive it via the remote debug protocol like https://github.com/LucianoGanga/simple-headless-chrome https://github.com/LucianoGanga/simple-headless-chrome This feels a little nicer than Selenium as it's one less layer of abstraction. EDIT: guess from other comments WebDriver is the right method to access.
- jordache 9y agofor automated testing in a non windowed env, this can be used.
- jwcrux 9y agoThe Chrome Devtools API is really useful. However, if you're wanting to use Selenium, a coworker of mine wrote this up to show how to use headless Chrome with Python + Selenium https://duo.com/blog/driving-headless-chrome-with-python https://duo.com/blog/driving-headless-chrome-with-python I would imagine the same approach could be used here with minimal changes.
- jgraham 9y agoWould people find it helpful if I add a `headless` capability to `moz:firefoxOptions` in geckodriver so that passing in `{capabilities: {alwaysMatch: {moz:firefoxOptions:{headless: true}}}}` when starting a session will start the browser in headless mode, if supported? This doesn't seem like something that's compelex enough to warrant a whole blogpost to explain how to get it working.
- jgraham 9y agoOh, apparently there's already a flag you can pass to the binary to enable headless mode, and geckodriver already supports setting those, so adding a separate option seems unnecessary. I thought it was just an environment variable.
- mintplant 9y ago
- ttoinou 9y agoDoes that mean we'll soon have an alternative to ElectronJS / NWJS based on Firefox ? (Positron :p ?)
- detaro 9y agoI don't see how headless mode would be related to that?
- Crespyl 9y agoWell, we did have XULRunner...
- owaislone 9y agoIt already exists: https://github.com/mozilla/positron https://github.com/mozilla/positron
- reitanqild 9y agoChecked. Discontinued. It used to be prism or something but that was discontinued years ago. The sometimes really make it hard for us fanboys (prism, Brendan and uncertainty about the future of extensions) :-|
- tmaly 9y agoAre there some examples available for this? I would love to replace some of my PhantomJS stuff
- heisenbit 9y agoFirefox 55 introduced major changes in the process model. My scrolling on the Mac is slow and not smooth. Others have reported the same. Maybe focusing on stabilizing this big change over one or two releases would be a good thing? Of course headless is also needed as the PhantomJS solution is not maintained anymore since April. See discussion here: https://news.ycombinator.com/item?id=14105489 https://news.ycombinator.com/item?id=14105489
- celerity 9y agoI just finished writing an article that explains how to connect WebDriver to Firefox running in the new headless mode on Windows if anybody's interested: https://intoli.com/blog/running-selenium-with-headless-firefox/ https://intoli.com/blog/running-selenium-with-headless-firef... It should be pretty similar on Linux, and probably macOS when it comes around.
- mykmelez 9y agoGreat article! I'm the product manager for the headless feature, and I'm unsure why `binary.add_command_line_options('-headless')` doesn't work for you, as the flag does work when invoking Firefox directly: > "c:\Program Files\Nightly\firefox.exe" -headless (It also works when Firefox is invoked from a Node.js script in a test suite for a Node.js program that drives Firefox.) Perhaps this is a Selenium issue?
- celerity 9y agoThanks! That was guess as well, since running the command you posted from cmd does work. I dug around selenium's source code a bit, but decided to take the pragmatic path and use the MOZ_HEADLESS environment variable instead.
- oneplane 9y agoBut can you really run windows headless? I thought even the Server Core and IoT versions wanted some sort of GPU even just to display a blue/blank screen.
- milcron 9y agoIoT Core has a headless mode. I don't think it can run Firefox though... UWP apps only.
- eberkund 9y agoIt is good to see some competition, I would hate to see automated tests being done purely in Chrome simply because it is the simplest browser to setup in headless mode.
- goferito 9y agoPlease don't forget about Linux
- CloudQA 9y agoGreat! This will help us run selenium tests much faster.