Click on - operation

Click on a specific element or position on the web page.


Clicking on an element

To perform this operation in the Suitest Test editor use the Click On line:

Clicking on the logo image
Clicking on the logo image

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 right corner of the web page.

In Test Editor:

Clicking on position [100, 200]
Clicking on position [100, 200]

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:

Click on the scroll button 5 times every 100 ms
Click on the scroll button 5 times every 100 ms

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.

In Test Editor:

Click on "Next" until the 5th page is reached
Click on "Next" until the 5th page is reached

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:

Click on "Next" only if we are on the first page of search results
Click on "Next" only if we are on the first page of search results

In JavaScript API:

const page = suitest.element('currentPageNum');
if (await page.matches(suitest.PROP.BG_COLOR, '#F00')) {
    await suitest.element('nextBtn').click();
}