Block reference / Web interaction
Trigger event
Fire a DOM event such as change, mouseover or keydown on an element.
Only in
WarpX Browser
Trigger event sends one browser event to an element, with the options you set. Use it when a page reacts to an event no other block produces: a change after a value was set, a keydown on Escape to close a popup, a blur that starts validation. For ordinary clicks and typing, the dedicated blocks are closer to what a person does.
Settings
- Element Selector
The element to fire the event on. The default is
html, the whole page. Write a CSS selector or an XPath: a value that starts with/,(,@orid(is read as XPath. The target button lets you click the element in the profile's browser, inside iframes and shadow roots too, and the double tick checks that the selector finds something.Examplebody- Multiple
Fires the event on every match, not just the first.
ExampleUnchecked- Mark elementwhen the selector is CSS, not XPath
Tags each element the block acts on, and skips tagged elements the next time this block runs, so a loop moves on to the next match. Only offered for a CSS selector.
ExampleUnchecked- Wait for selector
Keeps looking for the element until it appears or the timeout runs out. Off, the block looks once.
ExampleUnchecked- Selector timeout (ms)when Wait for selector is on
How long to keep looking, in milliseconds. The default is
5000.Example5000- Select event
The event to fire: mouse events (Click, Double Click, Mousedown, Mouseover and others), Focus, Blur, Input, Change, touch events, Keydown, Keyup, Submit or Wheel. Picking one sets Bubbles and Cancelable back to on and shows that event's own options.
ExampleKeydown- Bubbles
Lets the event travel up to the element's parents, where pages often listen for it.
ExampleChecked- Cancelable
Lets the page's listeners cancel the event.
ExampleChecked- altKeywhen a mouse, touch or keyboard event is chosen
Marks the event as fired with Alt held down. With Debug mode on, Alt is really held during a mouse or keyboard event.
ExampleUnchecked- ctrlKeywhen a mouse, touch or keyboard event is chosen
Marks the event as fired with Ctrl held down. With Debug mode on, Ctrl is really held during a mouse or keyboard event.
ExampleUnchecked- metaKeywhen a mouse, touch or keyboard event is chosen
Marks the event as fired with the Windows or Command key held down. With Debug mode on, that key is really held during a mouse or keyboard event.
ExampleUnchecked- shiftKeywhen a mouse, touch or keyboard event is chosen
Marks the event as fired with Shift held down. With Debug mode on, Shift is really held during a mouse or keyboard event.
ExampleUnchecked- Buttonwhen a mouse event is chosen
Left click, Middle click or Right click. With Debug mode on, it is the button that is really pressed.
ExampleLeft click- clientXwhen a mouse event is chosen
Horizontal position of the pointer in the visible part of the page, in pixels.
clientYnext to it is the vertical position.Example240- clientYwhen a mouse event is chosen
Vertical position of the pointer in the visible part of the page, in pixels.
Example180- movementXwhen a mouse event is chosen
Pointer movement since the last mouse event, across and (with
movementY) down, in pixels.Example0- movementYwhen a mouse event is chosen
Pointer movement since the last mouse event, downwards, in pixels.
Example0- offsetXwhen a mouse event is chosen
Pointer position from the left edge of the element, in pixels.
Example0- offsetYwhen a mouse event is chosen
Pointer position from the top edge of the element, in pixels.
Example0- pageXwhen a mouse event is chosen
Pointer position from the left edge of the whole page, scrolled part included, in pixels.
Example0- pageYwhen a mouse event is chosen
Pointer position from the top of the whole page, scrolled part included, in pixels.
Example0- screenXwhen a mouse event is chosen
Pointer position from the left edge of the screen, in pixels.
Example0- screenYwhen a mouse event is chosen
Pointer position from the top of the screen, in pixels.
Example0- keywhen Keydown or Keyup is chosen
The key the event reports, such as
Escape,Enterora. Typing a known key name fills in code and keyCode for you.ExampleEscape- codewhen Keydown or Keyup is chosen
The physical key, such as
KeyAorEscape.ExampleEscape- keyCodewhen Keydown or Keyup is chosen
The old numeric key code some pages still read, such as
27for Escape or13for Enter.Example27- Repeatwhen Keydown or Keyup is chosen
Marks the event as coming from a key held down.
ExampleUnchecked- deltaXwhen Wheel is chosen
Sideways scroll amount the wheel event reports.
Example0- deltaYwhen Wheel is chosen
Vertical scroll amount the wheel event reports. Positive is down. The page's listeners see it; the browser does not scroll because of it.
Example400- deltaZwhen Wheel is chosen
Depth scroll amount, which almost no page reads.
Example0- Datawhen Input is chosen
The text the input event says was entered. It does not change the field's value.
Examplea- Input typewhen Input is chosen
The kind of edit the input event reports, such as
insertTextordeleteContentBackward.ExampleinsertText- Delay time (ms)
How long to wait after the block finishes, in milliseconds. Write a range such as
1000,3000to pick a random wait in it each run.Example500
Every block also has the shared block settings — a description, Disable block and what to do on an error, and Finding elements explains selectors in more depth. Fields that take text accept data from earlier blocks.
What it hands on
Writes nothing to the table or variables. It leaves by its single output once the event has been fired. If no element matches, it fails with an element-not-found error; with Wait for selector on, it first waits up to Selector timeout (ms) for the element. A mouse or keyboard event sent with Debug mode fails with a message that names the selector.
Example: Close a newsletter popup that listens for Escape
- Start
- Open URL
- Delay
- Trigger event
- Add Open URL after Start with
https://news.example.com. - Add Delay with
3000, so the popup has time to appear. - Add Trigger event and set Element Selector to
body. - In Select event choose Keydown, and leave Bubbles and Cancelable ticked.
- Type
Escapein key. code and keyCode fill in asEscapeand27. - Run the workflow. The page's own Escape handler closes the popup.
Good to know
- Without Debug mode, events are created by script in the page. The page's listeners run, but the browser does not act on most of them itself: a Keydown types no character and does not move the focus, and a Wheel does not scroll.
- Focus, Blur and Submit call the element's own method instead of sending an event. Submit on a form sends it without running the page's submit handlers, such as script validation.
- For an element that appears late, name it in Element Selector, such as
.newsletter-modal, and tick Wait for selector instead of adding a fixed Delay: the run waits for the element, then fires the event on it. - Turn on Debug mode in the block's settings to send mouse and keyboard events as real input from the browser itself, trusted as a person's is. A mouse event lands at the centre of the element, which is scrolled into view first: Click and Double Click click there, Mousedown and Mouseup move there and press or release the button, Mousemove, Mouseenter and Mouseover bring the pointer there, and Mouseleave and Mouseout bring it there and then move it away. Keydown and Keyup press or release key on the element, which gets the focus first.
- With Debug mode, the browser makes the event itself, so the position fields (clientX, pageX and the rest), code, keyCode, Repeat, Bubbles and Cancelable are not used. Wait for selector, Selector timeout (ms) and Multiple work as without it: every match gets the event, in page order. Other events, such as Focus, Input, Wheel or the touch events, are still created by script, with Debug mode on or off.
- Events are not paced like a person's actions, and Human Emulation is not offered on this block. For clicks and hovering, Click element and Hover element have it.
See also
- Click element — Click an element on the page, with human-like mouse movement by default.
- Press key — Send a key, or a string of keys, to an element or to whatever has focus.
- Hover element — Move the pointer over an element, to open a menu or show a tooltip.
- Forms — Fill a text field, choose a dropdown option, or tick a checkbox or radio button.