Simulating mouse clicks
Web pages are built with interlocking links, and getting to another page can be done by following that link. In a normal browser, this is done by clicking with your mouse button. In PhantomJS there are two ways to do this: one is by using PhantomJS sendEvent
functions (PhantomJS event triggering); the other is by using DOM event triggering.
PhantomJS event triggering
The WebPage API supports sending events to the page. This can be mouse events or keyboard events. We will discuss more events as we progress, but for now we will tackle how to simulate clicking on page elements and links using PhantomJS event triggering.
PhantomJS Mouse Event Triggering API | |
---|---|
| |
|
|
|
This is the X coordinate where we trigger the event |
|
This is the Y coordinate where we trigger the event |
|
This states which mouse button to trigger; by default... |