元素是否在DOM中没有内部文本,如何获得该值?

发布于 2025-02-09 02:40:50 字数 427 浏览 1 评论 0原文

这是此类元素的示例

如何获得值99 < /代码>在测试过程中? 我正在使用剧作家,以及innertext()textContent()根本不起作用的东西。

await expect(page.locator(element)).toHaveText('99')  //OR
await expect(page.locator(element).innerText()).toBe('99')

这些方法应该从

This is an example of such element

How is it possible to get the value 99 during testing?
I'm using playwright and anything like innerText() or textContent() don't work at all.

await expect(page.locator(element)).toHaveText('99')  //OR
await expect(page.locator(element).innerText()).toBe('99')

It's fully logical that these methods should get the value from elements like that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

慢慢从新开始 2025-02-16 02:40:50

您必须检查为此的价值的存在。

await expect(page.locator(element)).toHaveValue('99')

You have to check the presence of value for this.

await expect(page.locator(element)).toHaveValue('99')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文