6

In a testcafe test how can I click on an element that is clearly clickable (with t.debug() I'm able to click on the element) and visible without using ClientFunction, or t.eval -- these "workarounds" recommended in testcafe's github issues do not work.

Some additional considerations:

  • the code I'm testing is Angular 1.7.
  • the Selector is verified as correct (and I tried various types of selectors)
  • testcafe version 1.8.4
  • I've tried various t.wait times before and after selection and click
  • I've tried changing the element type (<button> to <div>, etc)
Mate Mrše
  • 7,997
  • 10
  • 40
  • 77
sjt003
  • 2,407
  • 5
  • 24
  • 39
  • I've also downgraded to 1.7.0 (some gh issues have suggested selector problems started in 1.7.1), but this did not help. – sjt003 Apr 20 '20 at 22:34
  • Could you please provide us an url of your page and your test code to check it? Or maybe could you create a simple example that reproduces the problem? – vrintle Apr 22 '20 at 02:17
  • no. I'm not posting my code which is proprietary. There are plenty of testcafe issues from 1.7.1 to 1.8.2 that deal with selectors and clicking. – sjt003 Apr 22 '20 at 19:10
  • any angular 1.7 buttons will suffice: both form submit buttons and buttons with an ng-click action attached – sjt003 Apr 22 '20 at 19:11
  • 2
    Since you can't post your code, can you post an example? i.e. what the element looks like, and the testcafe actions you've tried. It'll help provide a more comprehensive picture, since we can't see the actual code – Rob C Apr 23 '20 at 17:25

2 Answers2

5

Try waiting for the element to be visible before clicking

await element.with({ visibilityCheck: true }).with({timeout: 10000});
VysakhMohan
  • 567
  • 3
  • 9
1

Here are some typical problems with unclickable elements, I know the link is for Selenium issues, but some solutions can be used regardless of the technology used.

If you already tried with various waiting to be visible/clickable solutions, the next thing that you might want to check is if you have multiple elements with the same id, one of them being invisible, so TestCafe is unable to uniquely identify the right element. In that case, you will need to improve the locator.

Another thing to consider is that the element might be out of the viewport (when not debugging). In that case, try changing the window size (or maximizing it) or moving to element.

Mate Mrše
  • 7,997
  • 10
  • 40
  • 77