[英]set checkbox using watir
<div class="icheckbox_minimal" style="position: relative;">
<input class="checkbox" type="checkbox" value="1" name="order[terms]"
id="order_terms" style="position: absolute; top: -20%; left: -20%;
display: block; width: 140%; height: 140%; margin: 0px; padding: 0px;
background: rgb(255, 255, 255); border: 0px; opacity: 0;">
<ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%;
display: block; width: 140%; height: 140%; margin: 0px; padding: 0px;
background: rgb(255, 255, 255); border: 0px; opacity: 0;">
</ins>
</div>
How can I set the checkbox for this element? 如何设置此元素的复选框?
I tried the following 我尝试了以下
browser.checkbox(:class => "iCheck-helper").when_present.set
browser.div(:class => "icheckbox_minimal").fire_event :click
you can click on ins tag to set the check box value as given below. 您可以单击ins标记来设置复选框值,如下所示。
if !browser.checkbox(id: 'order_terms').set? then
puts "not set"
browser.element(class: 'iCheck-helper').click
end
puts browser.checkbox(id: 'order_terms').set?
Try this 尝试这个
browser.checkbox(id: "order_terms").set
When you locate an element, that element has to be checkbox when you use the method checkbox but you are passing the locator of div to checkbox method. 当您找到一个元素时,当您使用方法checkbox时,该元素必须是checkbox,但是您将div的定位符传递给checkbox方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.