Testcafe can see button but not click on it
Asked Answered
P

2

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)
Parthena answered 17/4, 2020 at 15:1 Comment(5)
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.Parthena
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?Vitriolize
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.Parthena
any angular 1.7 buttons will suffice: both form submit buttons and buttons with an ng-click action attachedParthena
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 codeDamp
U
5

Try waiting for the element to be visible before clicking

await element.with({ visibilityCheck: true }).with({timeout: 10000});
Undressed answered 20/4, 2020 at 3:58 Comment(2)
can't sorry, proprietary.Parthena
@Parthena you don't have to post the actual code, but you can create a Minimal, Reproducible Example regarding this issue.Felt
H
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.

Hannelorehanner answered 28/4, 2020 at 11:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.