考虑以下代码:
test("homepage has title and links to intro page", async ({ page }) => {
await page.goto("https://playwright.dev/");
const links = page.getByRole("link");
const count = await links.count();
console.log("count is " + count);
});
我从计数变量中知道该页面上有 31 个链接。但我不应该也能够通过调试器在调试器中获取此信息吗? 链接变量?我如何“浏览”links 变量以查看所有链接及其数量?
最佳答案
这是不可能的,因为 links
变量不包含该数据:计数 are queried when you call .count()
。唯一的方法是“浏览”链接到 evaluate the await links.count()
expression in the debugger并查看结果或跳过 links.count()
调用并查看 counts
变量的值。
关于typescript - 如何在调试器中查看 Locator 对象的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74722916/