You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Java版Selenium中获取Role这类Computed Properties属性

深色模式下的开发者工具无障碍面板显示了无障碍树(选中节点不可见)、空的ARIA属性分组以及Computed Properties

被检查元素在网页的无障碍(Accessibility)板块下有一组可获取的属性:

Computed Properties

Name: ""
`aria-labelledby`: Not specified
`aria-label`: Not specified
`title`: Not specified
Role: generic

这些属性归属于Computed Properties类别,在DOM中不可见,是浏览器根据元素定义对其的解析结果。

已尝试以下方法但均未成功:

WebElement.getAttribute("Role")
WebElement.getCssValue("Role")
WebElement.findElement(By.cssSelector(".computed-property")

内容的提问来源于stack exchange,提问作者Siddhant

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 18:54:52