When comparing xvfb vs NW.js (w/xvfb), the Slant community recommends NW.js (w/xvfb) for most people. In the question“What are the best headless browsers for testing?” NW.js (w/xvfb) is ranked 3rd while xvfb is ranked 8th. The most important reason people chose NW.js (w/xvfb) is:
The integration of Node with the DOM in NW.js opens up a number of new options in how your headless testing workflow can be facilitated. The distinct separation of JavaScript contexts, the introduction of a separate node context, and the ability to cross communicate, offers a lot of power and flexibility.
Specs
Ranked in these QuestionsQuestion Ranking
Pros
Pro You can launch REAL browser using xvfb
Just test in real-world browser - xvfb makes it possible to launch them without the real screen.
Pro Node integration
The integration of Node with the DOM in NW.js opens up a number of new options in how your headless testing workflow can be facilitated.
The distinct separation of JavaScript contexts, the introduction of a separate node context, and the ability to cross communicate, offers a lot of power and flexibility.
Pro NaCl support/integration
Access to the Native Client offers up more options in implementing your testing workflow.
Cons
Con xvfb is no browser
Con Problem with ports
If you are running multiple instances on some browser and you use xvfb to run instances on agents on Bamboo or Jenkins you will potentially have a problem with using ports.
The first instance you are starting takes on a port on the agent and then the second instance that would be run doesn't have a port to go to.
You can partially solve the problem by dynamically assigning the next available port to the new instance that comes to be executed.
This only works if we assume that all the instances start in different time intervals, but what you cannot know is which instance is going to get a port first if they start at the same time, then the instances will crash, those that started at the same time.
Con xvfb Requirement (for now)
Headless is on the NW.js roadmap, but for now xvfb is necessary to get going. The community has done the work and you can find the details here.