Arup Rakshit
Arup Rakshit

Reputation: 118271

Getting the error "nil:NilClass (No MethodError)"

Please find the part of a code:

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

Error

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>

Please help me to resolve the error.

Upvotes: 0

Views: 58

Answers (1)

zed_0xff
zed_0xff

Reputation: 33217

looks like form('login_showSplashForm') finds nothing, try to use form_with or maybe forms.first

Upvotes: 1

Related Questions