0

I tried many times to click on a <a> tag, but phantomjs doesn't see it, even if I see it when I render the page.

I tried to use this trick, it won't work.

var evObj = document.createEvent('Events');

evObj.initEvent('click', true, false);

document.getElementById('TEST').dispatchEvent(evObj);
Mr Lister
  • 45,515
  • 15
  • 108
  • 150
  • 3
    Possible duplicate of [PhantomJS; click an element](http://stackoverflow.com/questions/15739263/phantomjs-click-an-element) – Zakaria Acharki Jan 14 '16 at 19:54
  • I think they are now called MouseEvent. ex: `var newEvent = new MouseEvent("click")` – AtheistP3ace Jan 14 '16 at 19:59
  • It doesn't work either.. :'( I also tried to click on a specific point giving x and y coordinates on the document.. no results.. – Federico Giorgio Salani Jan 15 '16 at 20:54
  • @FedericoGiorgioSalani Please show your full code ([edit] your question). I suspect that you're not running this in the page context. Additionally, it's not clear how you're verifying that some has happened. – Artjom B. Jan 17 '16 at 14:14

0 Answers0