I am trying to use jQuery and casperjs to click an element retrieved from the DOM.
casper.options.clientScripts = ["jquery-1.11.1.min.js"];
...
...
casper.then(function()
{
this.wait(2000,function()
{
this.evaluate(function()
{
var element = $('h4:contains("test")').prev().find('.delete');
$(element).css("background-color", "red");
$(element)[0].click();
});
});
)};
I have used
$(element).css("background-color", "red");
to see exactly what element jquery is selecting, (I have used capture() to see what is happening on the webpage) and it has selected the correct one. I have tried my code on Firefox's firebug dev tool and it works fine, but I cannot get the click function to work at all.
You can try multiple things.
Using the jquery
click
Using
onlick
Using
onlick
callDo a part of this using XPath with
casper.click