得到错误“nil:NilClass(No MethodError)”

时间:2013-01-21 20:51:27

标签: ruby mechanize mechanize-ruby

请找到代码的一部分:

button = Login_form.button_with(:name => 'Submit')
loggedin_page = Login_form.submit(button)


bizz_hierarchy_form=loggedin_page.form('login_showSplashForm')
button = bizz_hierarchy_form.button_with(:name => 'btnHome')  #error raised here
# buyer_page = bizz_hierarchy_form.submit(button)
# print buyer_page.title

错误

D:\Ruby script>ruby Test.rb
mechanize.rb:20:in `<main>': undefined method `button_with' for nil:NilClass (No
MethodError)

D:\Ruby script>

HTML

<td>
<input type="submit" name="btnHome" value="Homepage" class="btnBig"><input type="hidden" name="_synchToken_hom" value="1139cc8dd7d906f1"/>
</td>

请帮我解决错误。

1 个答案:

答案 0 :(得分:1)

看似form('login_showSplashForm')找不到任何内容,尝试使用form_withforms.first