I am trying to do what looks like a very simple click event using CasperJS on the following URL:
Using the following selector ('div.add-to-cart-btn > button.btn-primary') I am able to use jQuery to 'find' the button that I wish to click, when I run the following code it prints the line to the CMD window so it is definitely able to find the button via the selector.
if (this.exists('div.add-to-cart-btn > button.btn-primary')) {
this.echo('FOUND div.add-to-cart-btn > button.btn-primary', 'INFO');
}
However when I use the following code it doesn't seem to be able to 'click' this button for some reason - I have noticed this button has an onclick event attached to it, do I need to anything different to run the onclick event (I presumed the following code would be sufficient) - using the capture() I can see that the button hasn't been clicked.
this.evaluate(function() {
$('div.add-to-cart-btn > button.btn-primary').click();
});
Here is the jsfiddle with the entire code
I am using CasperJS 1.1.0-Dev & PhantomJS 1.9 (on WAMP server)
Note - I have asked this previously but condensed my question this time to make it more concise.