繁体   English   中英

即使属性具有特定值,元素属性值也为null

[英]Element attribute value is null even if the attribute has specific value

以下是我们网站中弹出窗口的html部分

<div id="DeliveryDateModal" class="modal fade in" role="dialog" data-backdrop="static" data-keyboard="false" style="display: block; padding-right: 17px;" aria-hidden="false">

如果显示弹出窗口,则aria-hidden属性aria-hidden值为true ,否则为false

当我尝试使用Selenium Webdriver读取属性值时

String value driver.findElement(By.id("DeliveryDateModal")).getAttribute("aria-hidden");

字符串“ value ”始终为null 为什么即使属性具有特定值也为null

尝试使用Java脚本。

String script = "return document.getElementById('DeliveryDateModal').getAttribute('aria-hidden');";
String value = ((JavascriptExecutor) driver).executeScript(script).toString();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM