作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
一旦我设法获得了我感兴趣的 NOKOGIRI 对象(在我的例子中是一个复选框),我该如何“检查”它?我有以下内容
category.parent.children.children.check
返回这个充满 nokogiri 对象的数组:
[#<Nokogiri::XML::Text:0x3fde5a78a26c "\r\n\t\t\t">, #<Nokogiri::XML::Element:0x3fde5a78a154 name="input" attributes=[#<Nokogiri::XML::Attr:0x3fde5a78a0a0 name="type" value="checkbox">, #<Nokogiri::XML::Attr:0x3fde5a78a064 name="name" value="epr_iid_selection[9]">, #<Nokogiri::XML::Attr:0x3fde5a78a014 name="value" value="652988">]>, #<Nokogiri::XML::Text:0x3fde4e0cd1b0 "\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t">, #<Nokogiri::XML::Text:0x3fde4e0cd0fc "Simple Messieurs Senior">, #<Nokogiri::XML::Text:0x3fde4e0ccfd0 "SM ">, #<Nokogiri::XML::Text:0x3fde4e0cce2c "Senior">]
在这个数组中,我只对第二个元素感兴趣,它是一个我需要“检查”的复选框:
#<Nokogiri::XML::Element:0x3fde55a0a028 name="input" attributes=[#<Nokogiri::XML::Attr:0x3fde5a751f70 name="type" value="checkbox">, #<Nokogiri::XML::Attr:0x3fde5a751f48 name="name" value="epr_iid_selection[9]">, #<Nokogiri::XML::Attr:0x3fde5a751ef8 name="value" value="652988">]>
我该怎么做?
最佳答案
通常,您想要选中表单中的复选框。
form.checkbox_with(:name => 'box').check
有关更多信息,请参阅相关文档:http://mechanize.rubyforge.org/GUIDE_rdoc.html
希望这对您有所帮助。
关于ruby-on-rails - 使用 Mechanize 检查复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30917049/
我是一名优秀的程序员,十分优秀!