剧作家Java:剧作家无法单击隐藏的属性的元素

发布于 2025-02-04 01:30:18 字数 254 浏览 5 评论 0原文

我尝试了许多定位器,但看起来像是隐藏的,所以剧作家无法单击任何解决方法,请帮助

“

I tried many locators but looks like its hidden so playwright fails to click any workaround please help

Blockquote

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

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

发布评论

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

评论(3

暖风昔人 2025-02-11 01:30:18

这是一种肮脏的方法。

Locator locator = page.locator("YOUR LOCATOR HERE");
locator.evaluate("node => node.classList.remove('classToRemove');");
//I cannot stress enough that this is a last resort as it can be a bit flakey

//or you could try this which might be a better option for your
Locator locator = page.locator("YOUR LOCATOR HERE");
locator.evaluate("node => node.click();");

Its a bit of a dirty way to do it but you can change the CSS if there is something there that makes it hidden e.g. a class or an attribute, or try and force the click using the DOM which is probably a better way to do it.

Locator locator = page.locator("YOUR LOCATOR HERE");
locator.evaluate("node => node.classList.remove('classToRemove');");
//I cannot stress enough that this is a last resort as it can be a bit flakey

//or you could try this which might be a better option for your
Locator locator = page.locator("YOUR LOCATOR HERE");
locator.evaluate("node => node.click();");
子栖 2025-02-11 01:30:18

也许使用武力选项的点击方法可以帮助您:

page.locator("some_selector").click( {force: true} );

Maybe using force option of click method will help you:

page.locator("some_selector").click( {force: true} );
做个ˇ局外人 2025-02-11 01:30:18

尝试 dispatchevent

不论元素的可见性状态,单击被派遣。这等同于调用element.Click()

await element.dispatchEvent('click');

try dispatchEvent

Regardless of the visibility state of the element, click is dispatched. This is equivalent to calling element.click().

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