我尝试使用机械化(Ruby)访问表单。 在我的表格上,我有一个Radiobuttons的gorup。 所以我想检查其中的一个。Nokogiri错误:未定义的方法`radiobutton_with' - 为什么?
我写道:
target_form = (page/:form).find{ |elem| elem['id'] == 'formid'}
target_form.radiobutton_with(:name => "radiobuttonname")[2].check
在此行中我想用2 但在这条线的值来检查单选按钮,我得到一个错误:
: undefined method `radiobutton_with' for #<Nokogiri::XML::Element:0x9b86ea> (NoMethodError)
根据文档,你的表单应该是'Mechanize :: Form'类,而不是'Nokogiri :: XML :: Element'。你是如何得到'target_form'的? – 2010-03-18 11:06:20
target_form: target_form =(page /:form).find {| elem | elem ['id'] =='formid'} – Newbie 2010-03-18 11:20:46
您应该使用'Mechanize :: Page#form_with'方法来获取表单。顺便说一句,我不确定你的页面是不是“Mechanize :: Page”。 – 2010-03-18 11:51:20