PhantomJS; click an element

前端 未结 11 847
借酒劲吻你
借酒劲吻你 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:11

    The easiest way is using jQuery.

    page.evaluate(function() {
      page.includeJs("your_jquery_file.js", function() {
        page.evaluate(function() {
          $('button[data-control-name="see_more"]').click();
        });
      });
    });
    

提交回复
热议问题