simulate-mouse-event

The simulate-mouse-event snippet triggers arbitrary mouse events on elements matched by a CSS or XPath selector by calling dispatchEvent for a selector.

The following table lists MouseEvent and PointerEvent events for this snippet:

MouseEventsPointerEvents

auxclick

pointerover

click

pointerenter

dblclick

pointerdown

mousedown

pointermove

mouseenter

pointerup

mouseleave

pointercancel

mousemove

pointerout

mouseout

pointerleave

mouseover

gotpointercapture

mouseup

lostpointercapture

Parameters

eyeo uses a custom, optional parameter syntax similar to the syntax used in specificClicker.

Mandatory parameter

NameDescriptionMandatory

selectors

The CSS/XPath selector that an HTML element must match for the event to be triggered. A maximum of seven (7) selectors are supported.

Yes

Optional parameters

Optional parameters are added to the selectors with a $ sign. You can combine multiple parameters for a single selector by separating them with a comma. If you don't specify a parameter is, the default value will be assumed for that selector.

NameDescriptionDefaultMandatory

$trigger

If this flag is not set, only the chosen event for the last selector will be triggered.

The $trigger flag can be used for the other selectors to ensure sure the event triggers for them, as well. You can omit the last selector, as $trigger is always true for the last selector.

false

No

$delay

This determines how much time the snippet should wait before simulating the event.

Default is 500 ms. If you don't want a delay, you must explicitly state $delay=0.

500

No

$continue

If set, the event will be triggered after each delay period ends.

For example, if the selected event is click and the delay is 500 ms, then the click event will be triggered every 500 ms instead of just once.

false

No

$event

Determines which event should be simulated for the selector.

click

No

Filter examples

The following table lists examples that use the simulate-mouse-event snippet:

FilterResult

simulate-mouse-event 'some-css-selector'

Simulates a click event for the elements that match the selector after 500 ms.

simulate-mouse-event 'css-selector1' 'css-selector2'

Simulates a click event for css-selector2 only if css-selector1 is present in the page. Does not click css-selector1.

simulate-mouse-event 'css-selector1$trigger' 'css-selector2'

Simulates a click event for both of the selectors if both of them are present in the page. The $trigger parameter for css-selector2 can be omitted, as it is the last parameter.

simulate-mouse-event 'xpath(some-xpath-selector)$delay=0'

Simulates a click event for the elements that are matched with the xpath selector with no delay.

simulate-mouse-event 'some-css-selector$continue,delay=100'

Simulates a click event every 100 ms.

simulate-mouse-event 'some-css-selector$continue,delay=100, event=mouseover'

Simulates a mouseover (hover) event over all elements matching the selector every 100 ms.

Last updated