kesla / node-headless Goto Github PK
View Code? Open in Web Editor NEWHeadless is a Node.js wrapper for Xvfb, the virtual framebuffer
License: Other
Headless is a Node.js wrapper for Xvfb, the virtual framebuffer
License: Other
I'm currently using a hack to launch xvfb with a window manager and then the node app that requires this with;
xvfb-run -n 99 command
How should I accomplish the same with your package?
Hi,
I am using headless
and am new to node, how can i get the spawned information from returned childprocess
like display resolution, size etc just to make sure it gives the desirable result and also for debugging purposes.
Hey guys,
This is a great package! I'm currently seeing an error in the electron-eval project, which depends on this. StackOverflow seems to think that this can be solved by adding some CLI args to Xvfb, although I'm not sure which ones exactly. Could I make a PR that allows the user to specify custom CLI args for Xvfb? Does anyone have an opinion on the interface?
I have to nightmare script inside xvfb.
xvfb-run node cnn.js
cnn.js has....
var Nightmare = require('../nightmare');
var vo = require('vo');
vo(run)(function(err, result) {
if (err) throw err;
});
function *run() {
var nightmare = Nightmare();
var title = yield nightmare
.goto('http://cnn.com')
.evaluate(function() {
return document.title;
});
console.log(title);
yield nightmare.end();
}
is there a way to write the whole code inside X Virtual Frame Buffer, so that we can execute in normal way
node cnn.js
instead of xvfb-run node cnn.js
Pardon my ignorance. I can't figure out how to actually connect to the spawned server. I've been previously using (without nodejs) xvfb-run -a some-binary
โ how would I translate that to this library?
I've tried the following
var headless = require('headless'),
var exec = require('child_process').exec;
headless(function(err, childProcess, servernum) {
exec('xvfb-run -n '+ servernum + ' some-binary', error, stdout, stderr) {
console.log('stdout:', stdout);
console.log('stderr:', stderr);
// kill the xvfb server - is this the correct place to do this?
childProcess.kill();
});
});
But this only emits "error: Xvfb failed to start"
, as if servernum were invalid.
Would it be possible to run this with Selenium as a headless browser?? As shown here http://elementalselenium.com/tips/38-headless, except in nodejs??
I added a stdio option (#22) that shows that the failures are as below. I actually got the same error on my laptop, and I was able to fix it manually by following the instructions from the first comment in this issue for the Ruby version of headless.
> [email protected] test /Users/travis/build/paulkernfeld/node-headless
> node test/test.js
_XSERVTransmkdir: ERROR: euid != 0,directory /tmp/.X11-unix will not be created.
_XSERVTransSocketUNIXCreateListener: mkdir(/tmp/.X11-unix) failed, errno = 2
_XSERVTransMakeAllCOTSServerListeners: failed to create listener for local
(EE)
Fatal server error:
(EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE)
/Users/travis/build/paulkernfeld/node-headless/test/test.js:5
throw new Error('Timeout 2 seconds. You don\'t have xvfb installed or someth
^
Error: Timeout 2 seconds. You don't have xvfb installed or something else is seriously wrong.
at options.display.width [as _onTimeout] (/Users/travis/build/paulkernfeld/node-headless/test/test.js:5:9)
at Timer.listOnTimeout [as ontimeout] (timers.js:121:15)
npm ERR! Test failed. See above for more details.
Hi,
how to use it with nightmarejs ?
Should i do :
headless(options, (err, childProcess, servernum) =>{
// childProcess is a ChildProcess, as returned from child_process.spawn()
console.log('Xvfb running on server number', servernum);
console.log('Xvfb pid', childProcess.pid);
console.log('err should be null', err);
const nightmare = new Nightmare({
//show: true,
webPreferences: {
partition: 'nopersist'
}
});
console.log('nightmare started')
nightmare.goto('http://www.google.fr')
// ..... other instruction....
});
Nightmare seems to start but nothing happen after...
Thanks !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.