我如何从网络元素中获取文本并在控制台中打印(例如)
How i can get text from web element and print in console (for example)
我在从网页元素中获取文本时遇到问题。
我正在使用 TestCafe e2e 框架并希望将文本 Web 元素的内容打印到控制台。你能提供一些代码吗?
const getInnerText = ClientFunction(() => homePage.kzLink.innerText);
console.log(getInnerText());
我得到了什么:
ReExecutablePromise { _then: [], _fn: [Function], _taskPromise: null }
要执行客户端函数,请使用 await 关键字和依赖项调用它。
const getInnerText = ClientFunction(() => homePage.kzLink.innerText, {
dependencies: { homePage.kzLink }
});
test('My Test', async t => {
const text = await getInnerText();
console.log(text);
});
我在从网页元素中获取文本时遇到问题。 我正在使用 TestCafe e2e 框架并希望将文本 Web 元素的内容打印到控制台。你能提供一些代码吗?
const getInnerText = ClientFunction(() => homePage.kzLink.innerText);
console.log(getInnerText());
我得到了什么:
ReExecutablePromise { _then: [], _fn: [Function], _taskPromise: null }
要执行客户端函数,请使用 await 关键字和依赖项调用它。
const getInnerText = ClientFunction(() => homePage.kzLink.innerText, {
dependencies: { homePage.kzLink }
});
test('My Test', async t => {
const text = await getInnerText();
console.log(text);
});