I.click / I.doubleclick
Click or double click on an element.
When the click triggers a page load:
If the click triggers a page load, the test will wait until the page load is complete. Note that the time taken to execute the command includes the page load time.
When the click triggers a page load in a new tab:
If the click opens a page in a new tab, the browser will automatically be switched to the new tab.
| || ||Keyword to identify the element to click. |
This is case-insensitive.
# Click on element with text
Click on an element seen as "Log In".
# Click on images / icons using
Image / icon can be clicked on using the
title attribute set on the element.
We'd strongly recommend setting both, because
title gives your element a helpful tooltip for visual users, and
aria-label makes your application friendly to people who use accessibility tools.
Here, we will use this plus button with the tooltip "Add" for illustration:
You can click on the button using its tooltip like this:
# Click on element using CSS / XPATH
Click on an element with the CSS class
Use hard selectors like CSS / XPATH sparingly because it makes your tests fragile and harder to read and maintain.