javascriptdom-eventsphantomjsmouseeventcasperjs

Where is Casper.js' sendEvent defined?


I'm trying to figure out how exactly is Casper.js using underlying Phantom.js to move the mouse.

I found that casper.page.sendEvent() is responsible but where is sendEvent defined and how does it interact with PhantomJS?


Solution

  • Since CasperJS is built on top of PhantomJS, you can use any PhantomJS function inside a CasperJS script through the casper.page object.

    One such function is page.sendEvent which enables you to trigger native user events in PhantomJS.

    The documentation says the following for mouse move:

    For 'mousemove', however, there is no button pressed (i.e. it is not dragging).

    If you still want to see how it is implemented, you can find it here.