Chapter 3. Handling Events and Callbacks

A browser adapts based on user-driven events—these can be mouse or key events. A browser reacts by doing something when these events are received. Events are not only generated by the user as there are also events that are triggered and received by the application, such as an incoming message alert, a request to pick up a file, or incoming data packets over the network. PhantomJS has several webpage callbacks that we can listen to in order to perform additional processing when these events are received.

Listening to page events

Unlike a real browser, where we can see the page events happening visually, in PhantomJS, we cannot see anything. For example, on a real browser, we can see the status bar of the browser ...

Get Getting Started with PhantomJS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.