Last active
August 29, 2015 14:01
-
-
Save vitallium/5336e1febebeaffb54b7 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 page = require('webpage').create(); | |
| page.settings.userAgent = 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1976.2 Safari/537.36'; | |
| page.viewportSize = { | |
| width: 1024, | |
| height: 768 | |
| }; | |
| page.onConsoleMessage = function(msg) { | |
| console.log(msg); | |
| }; | |
| page.open('http://www.trivago.co.uk/', function(status) { | |
| if (status === 'success') { | |
| page.evaluate(function() { | |
| $('#js_go').click(); | |
| // wait a bit | |
| setTimeout(function() { | |
| $('.item_nav:first > li:first').click() | |
| }, 5000); | |
| }); | |
| setTimeout(function() { | |
| page.render('out.png'); | |
| phantom.exit(); | |
| }, 10000); | |
| } else { | |
| console.log('unable to load web page'); | |
| } | |
| }); |
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 casper = require('casper').create({ | |
| pageSettings: { | |
| userAgent: 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1976.2 Safari/537.36' | |
| }, | |
| viewportSize: { | |
| width: 1024, | |
| height: 768 | |
| }, | |
| waitTimeout: 10000 | |
| }); | |
| casper.start('http://www.trivago.co.uk', function() { | |
| this.click('#js_go'); | |
| this.wait(5000, function post() { | |
| this.evaluate(function() { | |
| $('.item_nav:first > li:first').click(); | |
| }); | |
| this.wait(3000, function() { | |
| this.capture('casper.png'); | |
| casper.exit(); | |
| }); | |
| }); | |
| }); | |
| casper.run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment