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?
Asked
Active
Viewed 132 times
1
-
1The click action has the [speed](https://devexpress.github.io/testcafe/documentation/test-api/actions/action-options.html#click-action-options) option. Could you please clarify your requirement for such an option? What behavior do you wish to achieve by using this option? – Dmitry Ostashev Oct 08 '19 at 13:31
-
The click action is taking time to click on each node until I decrease the selector timeout (And I kept it a second), which I kept as 5s for all actions. I don't understand why the action is waiting for 5 seconds to click on the nodes when it is able to find the elements before that and can be able to click on it! – chris Oct 08 '19 at 18:11
2 Answers
2
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.

Alex Kamaev
- 6,198
- 1
- 14
- 29
-
if the TestCafe is not able to find the element or the element is obscured by another element, then how is it able to click on that element in a second when I keep the selector timeout to 1 second and it should rather fail for not able to find that elemeht ? – chris Oct 09 '19 at 17:18
-
1If the element is obscured by another element, TestCafe clicks it nevertheless after timeout occurs. This behavior may not be very obvious, but it prevents accidental fails caused by animation freezes and improves the test's stability. – Alexey Lindberg Oct 10 '19 at 16:57
-
ok, so what's the solution for that?, these are nodes and the different child nodes show up after clicking on the parent node. – chris Oct 10 '19 at 17:31
-
ok, so what's the solution for that? these are nodes and the different child nodes show up after clicking on each parent nodes. – chris Oct 10 '19 at 20:27
1
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);
});
-
ok, it actually doesn't have any quick selectors. The elements are nodes from a tree structure and I have to click the parent node to get the child nodes (and shows the child nodes after clicking on the parent nodes), then click again on each child node to get their child nodes ( and shows these child nodes only after clicking on the thier parent nodes or the first child nodes) – chris Oct 14 '19 at 19:57
-
1
-
1I was able to solve it, added the timeout as options in the selectors and it worked - this.nodeChild = Selector(`.parent123`,{ timeout: 1000, }).find(`.node-group`).find(`.node.children`); – chris Oct 17 '19 at 17:35
-
-
Thanks Chris! Your comment helped me, I'm having the exact same issue. it's on a modal, and there is no indication it's hidden. Cypress doesn't think it's hidden. It is also in a pretty deep node though, I'm not sure if maybe I can reference more of the chain to get it to go faster. Not sure why testcafe would think it's hidden. Sadly I can't give Alex any access or I would to see if they can figure out a why it waits for the time out to click. – Daniel Oct 29 '21 at 23:16