chris
chris

Reputation: 119

Click action doesn't have the option timeout

The click action is taking time to click on hierarchy nodes, I decreased the selector timeout to lesser time and then it clicks the nodes more quickly than before, however, I don't want to decrease the selector timeout as it will affect all the other actions. Why doesn't click action has the timeout option? or is there any way I can customize the timeout for that click action only?

Upvotes: 1

Views: 166

Answers (2)

aleks-pro
aleks-pro

Reputation: 1669

You can create 'quick' Selectors by specifying a small timeout and use them to click on obscured elements only. This will not affect other actions. Take a look at the example:

import { Selector } from 'testcafe';

fixture `New Fixture`
    .page `https://fd4f9.csb.app/`;

const createQuickSelector   = selector => Selector(selector, { timeout: 5 });
const anchorRegularSelector = Selector('a');
const anchorQuickSelector   = createQuickSelector(anchorRegularSelector);

test('New Test', async t => {
    await t
        .click(anchorQuickSelector);
});

Upvotes: 1

Alex Kamaev
Alex Kamaev

Reputation: 6318

If the click action takes some time, usually this means that TestCafe cannot find a target element. Please ensure that your target element is visible and has width and height more than zero. It is also possible that your target element is obscured by some other element, but it's difficult to say precisely.

If you still have some issue with the 'click' action, please provide a sample to demonstrate the described problem.

Upvotes: 2

Related Questions