我无法从documentation工作中获取checkbox
选择器。知道为什么吗? $('checkbox').size()
始终为零。
HTML页面
<html>
<head>
<title>Geb</title>
</head>
<body>
<input type="checkbox" name="pet" value="dogs" checked="true" />
</body>
</html>
Groovy代码
Browser.drive {
go "file:///home/zoran/page.html"
println $('checkbox').size() // is always zero
}
答案 0 :(得分:1)
要使用jQuery选择器选择页面上的所有复选框,您需要使用:
$('input[type=checkbox]').size()
答案 1 :(得分:0)
选择所有复选框使用jquery选择器作为
$('input:checkbox').size()
答案 2 :(得分:0)
只需为您的复选框提供ID
<input type="checkbox" id="chkPet" name="pet" value="dogs" checked="true" />
然后
$("#chkPet")