Skip to content

I.click() ​

Click on an element or at a position using the left mouse button.

Usage ​

js
// click an element at its center
I.click(element: string)

// click with an offset from an element's top-left corner
I.click(element: string, x:number, y: number)

// click at a position relative from the top-left of the viewport
I.click(x: number, y: number)

Parameters ​

ParameterTypeDescription
elementstringThe element to click on — by text, CSS, or XPath selector
xnumberHorizontal offset in pixels from the left edge of the element or viewport
ynumberVertical offset in pixels from the top edge of the element or viewport

Examples ​

Click by text ​

js
I.click("Login");

This targets an element that best matches the text "Login" (case-insensitive), based on:

  • the text content of the element,
  • associated <label> elements,
  • descriptive attributes such as aria-label, title, alt-text
  • adjacent text

Click by CSS ​

js
I.click("#zoom-in-btn");

This targets an element that matches the CSS selector #zoom-in-btn exactly.

If there are multiple matches, UI-licious will target the element nearest to elements with the most recent interactions.

Click by XPath ​

js
I.click("//*[@data-test-id='close-button']");

This targets an element that matches the XPath selector //*[@data-test-id='close-button'] exactly.

If there are multiple matches, UI-licious will target the element nearest to elements with the most recent interactions.

Click using element offset ​

js
I.click("First Name", 100, 10);

This clicks at an offset from the "First Name" element with an offset of 100px to the right and 10px down from the top-left corner of the element.

Click using viewport offset ​

js
I.click(500, 300); // clicks 500px right and 300px down from the top-left corner of the screen

This clicks at 500px right and 300px down from the top-left corner of the viewport (the visible portion of the page).