3

I would like to check if '64' exists on the page which I have created.

const x = Selector('.FilterCockpit--header--count').withText('64');

The following test fails.

test('x', async t => {
    await t
    .expect((x).exists).ok()
    });

HTML code:

<div class="FilterCockpit--header--results">
          <span class="FilterCockpit--header--count">
              64
         </span>
         Results
 </div>

What I am doing wrong? Thank you in advance for your help.

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
Jakub Sip
  • 195
  • 1
  • 10

1 Answers1

5

I've executed your test case with the latest TestCafe of version 1.1.4 and it is passed:

enter image description here

Here are my complete test case and a test file based on your code snippets:

import { Selector} from 'testcafe';

fixture('fixture')
    .page('file:///Temp/56074194.html');

const x = Selector('.FilterCockpit--header--count').withText('64');

test('x', async t => {

    await t
        .expect((x).exists).ok()
});

56074194.html 

<div class="FilterCockpit--header--results">
          <span class="FilterCockpit--header--count">
              64
         </span>
         Results
 </div>

Perhaps, there are some circumstances that may break the test execution. If there are any additional steps I need to perform, please let me know.

See also: Check if an Element Exists

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47