2

There is a onclick function tied up with this tag. I need to trigger this onclick function, so I used

page.sendEvent('click', element.offsetLeft, element.offsetTop, 'left');

But it seems not working. How to make a click on tag? Thanks for any help!

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
John Mccandles
  • 1,181
  • 2
  • 16
  • 24
  • You haven't shown us your complete code. Are you sure that `element` contains your element? Perhaps you're executing `page.sendEvent()` inside of the page context which is not possible. – Artjom B. Sep 16 '15 at 10:00

1 Answers1

0

You can include jquery by doing

page.includeJs('http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js', callback_function);

More info: http://phantomjs.org/api/webpage/method/include-js.html

and then use jQuery and do from the callback function

page.evaluate(function(){
    $('#mylink').trigger('click');
});
Artjom B.
  • 61,146
  • 24
  • 125
  • 222
Mir Adnan
  • 844
  • 11
  • 24