nodejs phantom add clickイベント

424 ワード

page.evaluate( function() {

    // find element to send click to

    var element = document.querySelector( 'span.control.critical.closer' );



    // create a mouse click event

    var event = document.createEvent( 'MouseEvents' );

    event.initMouseEvent( 'click', true, true, window, 1, 0, 0 );



    // send click to element

    element.dispatchEvent( event );

});