Testing 将当前URL写入TestCafe中的控制台
我有一个变量“currentPage”,我想将它设置为运行页面上的当前URL。 但是为了确保URL是正确的,我想把它打印到控制台上。无论我尝试什么,我总是得到“未定义”、“对象”。。。 另一方面,如果我使用“await t.expect(…)”方法并使其失败,那么我会看到想要的URLTesting 将当前URL写入TestCafe中的控制台,testing,console,automated-tests,e2e-testing,testcafe,Testing,Console,Automated Tests,E2e Testing,Testcafe,我有一个变量“currentPage”,我想将它设置为运行页面上的当前URL。 但是为了确保URL是正确的,我想把它打印到控制台上。无论我尝试什么,我总是得到“未定义”、“对象”。。。 另一方面,如果我使用“await t.expect(…)”方法并使其失败,那么我会看到想要的URL const getURL = ClientFunction(() => window.location.href); console.log(getURL) //does not work console.l
const getURL = ClientFunction(() => window.location.href);
console.log(getURL) //does not work
console.log(getURL()) //does not work
我可以将其写入控制台输出吗?
如果是这样的话,我想也可以做类似的事情
“currentPage=getURL()”但我得到:
current page function __$$clientFunction$$() {
调用ClientFunction之前,您错过了
wait
关键字。请参阅。
我建议你用以下方式写:
const url = await getURL();
console.log(url);
const getURL=wait ClientFunction(()=>window.location.href)();
console.log(getURL)//将起作用
如果您在test cafe中出错,请仔细检查您正在等待的内容。作为一个在过去几个月里经常使用它的人。这是我最常见的错误