4

Even tho` I have read the documentation that TC provides, I'm still not sure about what is the difference between:

await t.expect(element.visible).ok();

and

await t.expect(element.exists).ok();

I have a hunch that somehow visible includes the exists check, but on the other side, and element could exist, but just not in the visible area...

Thank you in advance

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
Eugen
  • 785
  • 6
  • 22

2 Answers2

6

.exists only checks that element is in the DOM. It does not check for visibility.

If you want to check for visibility you have two ways:

await t.expect(element.with({visibilityCheck: true}).exists).ok();
await t.expect(element.visible).ok();
hdorgeval
  • 3,000
  • 8
  • 17
  • 1
    yes, this is what I'm also presuming. Therefore, in a small amount of scenarios (when i only want to check an element is inside the DOM) I can use exists, but instead, I could use visible for most of them, because somehow visible incorporated exists :) – Eugen Mar 29 '19 at 09:41
  • It's not the same since in case of exists and count the selector is resolved immediately, while in case of visible it waits the whole selector timeout. Additionally you cannot overwrite it for exists and count. Source: https://testcafe.io/documentation/402829/guides/basic-guides/element-selectors#selector-timeout – Lukasz Jun 02 '23 at 09:42
0

Give a look here: https://github.com/DevExpress/testcafe/issues/5368#issuecomment-668448192 and here https://testcafe.io/documentation/402829/guides/basic-guides/select-page-elements#selector-timeout

because there are differences in exist and visible execution, that will create you issues.

fman
  • 175
  • 2
  • 4