Click on - operation¶
- Browsers
- LG webOS
This operation performs a click on a specific element or position on the web page.
Clicking on an element¶
This operation is not supported in Safari browsers older than version 13.1 due to an issue inside official Safari's WebDriver. For a workaround please look into our Troubleshooting section
To perform this operation in the Suitest Test editor use the Click On line:
To perform this operation in the Suitest JavaScript API use
the Click command in conjunction with the
element
subject:
await suitest.element('logoImg').click();
The element is clicked on in the center of its bounding box. If the element is obscured by other elements the Click on command may not work as expected.
Clicking on a position on the screen¶
To click on a specific position, specify the coordinates in pixels relative to the top left corner of the web page.
In Test editor:
In JavaScript API use the position
command:
await suitest.position(100, 200).click();
Clicking multiple times on the same target¶
You can send repeated clicks to the same target with a particular frequency. For instance you can perform double clicks, or check if the web app can gracefully handle frequent clicks.
In Test editor:
In JavaScript API use repeat
and interval
:
const button = suitest.element('scrollBtn');
await button.click().repeat(5).interval(100);
The frequency parameter is expected to be between 0.01 seconds and 3600 seconds.
Keep clicking until a condition is met¶
You can combine the Click on operation with an Assertion and instruct Suitest to keep clicking on the target until a specific condition is met.
Please note that the condition is being evaluated before each run (including the first one). Therefore the application has to be already running before the first evaluation.
In Test editor:
In JavaScript API use until
:
const button = suitest.element('nextBtn');
await button.click().until(suitest.location().contains('#5')).repeat(10);
Click on a target only if a condition is met¶
You can combine the Click on operation with an Assertion and instruct Suitest to run this operation only if the condition is satisfied.
In Test editor:
In JavaScript API:
const page = suitest.element('currentPageNum');
if (await page.matches(suitest.PROP.BG_COLOR, '#F00')) {
await suitest.element('nextBtn').click();
}
Clicking on relative position¶
- LG webOS
Relative position is meant in context of current cursor position. If the cursor is out of the reach, then middle of the screen is used as the base.
// click 100 px down from the current cursor position
await suitest.relativePosition(0,-100).click();