typescript - 如何在调试器中查看 Locator 对象的内容?

标签 typescript visual-studio-code vscode-debugger playwright

考虑以下代码:

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变量中有很多“属性”,但我不知道如何在那里找到有用的东西: enter image description here

最佳答案

这是不可能的,因为 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/

相关文章:

javascript - 我可以将 typescript 实用程序类型与 jsdoc 一起使用吗?

angular - 错误 Angular 13 : ngForOf not used by any directive. ..无法绑定(bind)到 'ngForOf'

c++ - Mac VSCode 调试器总是显示关于 ';' 和 ':' 的错误

node.js - Angular/Electron服务输出传递给变量,但返回未定义

typescript 交集类型和函数签名没有抛出预期的错误

visual-studio-code - Visual Studio Code 中是否有 'select between tags' 快捷方式?

angular - 未绑定(bind)断点 - VS Code | Chrome | Angular

linux - Visual Studio 代码调试器错误 : "Could not find the task ' gcc build active file'

javascript - 如何在 Typescript 中声明模块的全局变量?

typescript - Angular2 TypeError : linkParams. forEach 不是函数