check() 与 setChecked(true) 剧作家

问题描述 投票:0回答:1

我试图了解 locator.checklocator.setChecked 设置为

true
时有什么区别。

我检查了文档,看起来它们基本上是相同的。

我检查了它们的功能,看起来它们的功能是一样的。

有什么不同吗?也许有不同的目的?

javascript typescript checkbox playwright
1个回答
0
投票

定位器.检查

enter image description here

定位器.setCheck

enter image description here

因此,根据文档判断,如果元素在操作过程中的任何时刻与 DOM 分离,

locator.check
将会抛出异常,而
locator.setCheck
将在这种情况下重试。

© www.soinside.com 2019 - 2024. All rights reserved.