Write current URL to console in TestCafe

Viewed 8183

I have a variable "currentPage" which I want to set to the current URL on the running page. But to see that the URL is correct I want to print it to the console. What ever I try I keep getting "not defined", "object", ... If I on the other hand use the "await t.expect(...)" method and make it fail then I see the wanted URL.

const getURL = ClientFunction(() => window.location.href);
console.log(getURL) //does not work
console.log(getURL()) //does not work

Can I write it to console output? If so then I guess it should also be possible to do something like "currentPage = getURL()" but I get:

current page function __$$clientFunction$$() {
2 Answers

const getURL = await ClientFunction(() => window.location.href)();
console.log(getURL) //will work

Just make getURL() self invocation function. IMHO

Related