How to reset the scrollHeight values on DOM elements retrieved using ClientFunction

I have TestCafe running in two separate test classes, in two separate fixtures, in two separate tests, testing two different app pages.

I notice when I interrogate the window.document object through the ClientFunction in these tests, depending on the running order, I get differing values.

e.g.
mytest1.js

import { Selector, ClientFunction } from 'testcafe';

  fixture `Homepage`
    .page `http://mypage.com`;

  test('Test 1', async t => {

    const getBodyHeight = ClientFunction(() => window.document.body.scrollHeight);
    console.log(await getBodyHeight()) // 800px

  });

mytest2.js

import { Selector, ClientFunction } from 'testcafe';

  fixture `Dashboard`
    .page `http://mypage.com/dashboard`;

  test('Test 2', async t => {

    const getBodyHeight = ClientFunction(() => window.document.body.scrollHeight);
    console.log(await getBodyHeight()) // 1200px

    });

If I run these using npm run testcafe -- firefox:headless mytest*.js and the order is smaller height to larger height, the console will log:

...
800
...
1200

However if I run these the opposite way (larger height to smaller height), I get:

...
1200
...
1200

It is as if the document.body is stretched to a max value and doesn’t return.

Is there a way using the ClientFunction(..) or possibly some other means to reset these values correctly?

81 thoughts on “How to reset the scrollHeight values on DOM elements retrieved using ClientFunction”

  1. What i do not understood is in truth how you are now not really a
    lot more smartly-favored than you may be now. You are so intelligent.
    You know therefore considerably in relation to this subject,
    made me personally believe it from so many varied angles.
    Its like men and women aren’t fascinated except it is one thing to accomplish with Lady gaga!

    Your own stuffs outstanding. At all times care
    for it up! http://hydroxychloroquined.online/

    Reply
  2. Pingback: ivermectin de 6
  3. Pingback: ivermectin dosage

Leave a Comment