gpt4 book ai didi

ruby-on-rails - 使用 Mechanize 检查复选框

转载 作者:行者123 更新时间:2023-12-04 06:20:52 31 4
gpt4 key购买 nike

一旦我设法获得了我感兴趣的 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/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com