Skip to content

Instantly share code, notes, and snippets.

@botanicus
Created October 17, 2014 09:43
Show Gist options
  • Select an option

  • Save botanicus/bfc99961440d62a7762d to your computer and use it in GitHub Desktop.

Select an option

Save botanicus/bfc99961440d62a7762d to your computer and use it in GitHub Desktop.
var Nightmare = require('nightmare');
var exec = require('child_process').exec;
// Receive arguments from the console.
var arguments = process.argv.slice(2);
console.log("Searching: " + arguments);
new Nightmare()
.goto('http://yahoo.com')
.type('input[title="Search"]', arguments)
.click('.searchsubmit')
// Wait until the page loads, then take a screenshot.
.wait()
.screenshot('./scr.jpg')
.run(function (err, nightmare) {
if (err) return console.log(err);
console.log('Displaying results');
// Fork the process to show the screenshot in the IDE browser.
exec('/srv/cloudlabs/scripts/display.sh scr.jpg');
console.log('Done!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment