无法使用 testCafe 找到其中有伪元素 ::before 的锚标记

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

TestCafe :我有一个锚标记,其中有一个伪元素 ::before。如何选择仅当我将鼠标悬停在 ::before 元素上时出现在检查元素中的锚标记内的图像。这是锚标记:

<a class="nav-icon flag gh-desktop-only en-GB" role="button" data-toggle="collapse" aria-expanded="false" aria-controls="langDropdown" aria-label="Language Dropdown">::before</a>.

我已经尝试过这种方法,但它不起作用。它说元素在Dom中不可见:

const anchorTag = Selector('a.nav-icon.flag.gh-desktop-only.en-GB'); await t.click(anchorTag);

请指导我在这里缺少什么。

javascript tags anchor pseudo-element testcafe
1个回答
0
投票

我尝试用您的示例重现该问题,但没有成功。请注意,Testcafe 操作不能针对pseudo-elements。 您可以使用 ClientFunction 作为解决方法

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