Created
October 17, 2014 09:43
-
-
Save botanicus/bfc99961440d62a7762d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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