I want to check the existence of a window object
Error: ClientFunction cannot return DOM elements. Use Selector functions for this purpose
The object should be returned, since it is a valid object.
Note that replacing getNavDispatch with getWindowLocation in the test does not result in the error. They are both valid properties of window
If I add await t.debug() at the top of the test then open a console:

nike.com/orders
Your complete test code (or attach your test files):
const getNavDispatch = ClientFunction(() => window.NikeDotcomNav);
const getWindowLocation = ClientFunction(() => window.location);
fixture`Login`
.httpAuth({
username: process.env.BASIC_AUTH_USER,
password: process.env.BASIC_AUTH_PASS,
})
.page(`${page.settings.baseUrl}/orders/`)
.beforeEach(async () => {
await waitForReact();
});
test('user can log in', async t => {
// Login via guest lookup page.
const disp = await getNavDispatch();
console.log('NikeDotcomNav', disp);
...
Your complete test report:
✖ user can log in
1) ClientFunction cannot return DOM elements. Use Selector functions for this purpose.
Browser: Chrome 73.0.3683 / Mac OS X 10.13.6
NODE_ENV=development testcafe -s screenshots --skip-js-errors chrome ./tests/*.test.js -F LoginIf anyone is curious the fix for this was to JSON.stringify the object I wanted to get back. Ran into a few problems with that (circular structure). The root of the problem is related to object marshalling across processes -- I didn't need the full object, I just needed to check for its existence.
Still, the error message I got has nothing to do with that. It could be improved.
I've found that the NikeDotcomNav contains at least one DOM element. Check the window.NikeDotcomNav.vanilla.objects[1].el property.

However, I understand that the error message is very unclear and DOM elements can be missed easily when you try to retrieve an object with a very complex structure. I think we should display the name of the property that causes the error and names of its parent properties as well. I've created a feature suggestion about it: https://github.com/DevExpress/testcafe/issues/3640.
Excellent, thanks
This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.
Most helpful comment
Excellent, thanks