PhantomJS; click an element

前端 未结 11 834
借酒劲吻你
借酒劲吻你 2020-11-21 23:53

How do I click an element in PhantomJS?

page.evaluate(function() {
    document.getElementById(\'idButtonSpan\').click();  
});

This gives

11条回答
  •  北海茫月
    2020-11-22 00:06

    With 1.9.2 this worked for me, click handlers were triggered:

    var a = page.evaluate(function() {
        return document.querySelector('a.open');
    });
    
    page.sendEvent('click', a.offsetLeft, a.offsetTop);
    

提交回复
热议问题