I am currently using TestCafe to run tests in two separate fixtures and classes for different app pages. I have noticed that when I use the "ClientFunction" to access the "window.document" object in these tests, the values can vary depending on the execution order.
For example, in 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
});
In 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
});
When I run these tests with
npm run testcafe -- firefox:headless mytest*.js
in a certain order, I see inconsistent results in the console output.
...
800
...
1200
However, if I reverse the order, I get:
...
1200
...
1200
It seems like the document body is reaching a maximum value and not resetting properly.
Is there a way to reset these values correctly using ClientFunction or any other method?