如何在 Selenium 中单击锚标记内具有 ROLE 属性的元素?

Bha*_*hah 7 selenium-webdriver

如何在 Selenium WebDriver 中使用 java 单击锚标记内具有属性 role="button" 的元素?前任:

<a href="#" class="xyz" role="button">
   <span class="ABC">close</span>
</a>
Run Code Online (Sandbox Code Playgroud)

我只想单击此关闭按钮,但不使用跨度文本。

Vin*_*nay 10

使用 xpath 或 css 选择器

X路径-//a[@role = 'button']

CSS-a[role = 'button']