Java 如何使用Selenium查找HTML标记中是否存在没有值的属性?

Java 如何使用Selenium查找HTML标记中是否存在没有值的属性?,java,html,selenium,attributes,Java,Html,Selenium,Attributes,例:无线电检查 <input id="rdo" type="radio" name="nrdo" value="1" checked> 只需检查attributer值是否不为null 函数hasAttr(el,attr){ 返回el.getAttribute(attr)!==null } log(hasAttr(rdo,'checked')) log(hasAttr(rdo2,'checked')) 使用Jquery属性 element.getAttribute(attrib

例:无线电检查

<input id="rdo" type="radio" name="nrdo" value="1" checked>

只需检查attributer值是否不为null

函数hasAttr(el,attr){
返回el.getAttribute(attr)!==null
}
log(hasAttr(rdo,'checked'))
log(hasAttr(rdo2,'checked'))

使用Jquery属性

element.getAttribute(attributeName)为两者返回null 1.无价值属性
2.属性不存在

你能考虑和我们分享你的工作吗?谢谢,请不要(错误地)使用注释部分来发布代码,而不是将您的问题发布到那个里。
<input id="rdo" type="radio" name="nrdo" value="1"> 
$.each($( ":input" ),function(i,o){
 alert($(this).attr("value")==undefined);
})