Undefined method 'click' for nil:NilClass (Mechanize) [closed]

為{幸葍}努か 提交于 2019-12-02 07:51:13

The code you are using:

member.link_with(:text => 'Read biography')

does not find the link, because the link has some space and new lines characters in it. You need to use it like this:

member.link_with(:text => /Read biography/)

that code will find the link.

There are two calls to click:

member = link.click

and

bio_link = member.link_with(:text => 'Read biography').click

The first is called on iterator, that can not be nil, hence the problematic one is the second.

Try to put debug output, or set a breakpoint before # Get bio and examine what’s wrong with it. It is impossible to say why member.link_with(:text => 'Read biography') returns nil by the information you have provided.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!