This code does not work:
var page = require('webpage').create();
page.open('http://www.ebay.com/', function() {
console.log('Page loaded');
page.includeJs('http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js', function() {
console.log('jQuery included');
page.render('C:/beforeclick.jpeg');
console.log('Render 1');
page.evaluate(function() {
$('.btn-prim').click();
});
page.render('C:/afterclick.jpeg');
console.log('Render 2');
});
});
In fact $('.btn-prim').click() does not work, beforeclick.jpeg and afterclick.jpeg are the same. In browser console $('.btn-prim').click() works fine. Ebay here just for example, it does not work on other sites too. Please help me to solve the problem, I am novice in JavaScript.