开发者

Mechanize: Search all Forms

开发者 https://www.devze.com 2023-03-20 17:22 出处:网络
It appears that both of these give me access to the first FORM element in a document: page.form page.forms.first

It appears that both of these give me access to the first FORM element in a document:

page.form
page.forms.first

How can I search for a particula开发者_开发知识库r checkbox like

page.form.checkbox_with(:name=>"yep")

if I don't know which FORM it is inside?


Do you want all the forms with that checkbox, or only the first one?

For the first one, do

form = page.forms.detect { |f| f.checkbox_with(:name => "yep" ) }

For all, do

forms = page.forms.select { |f| f.checkbox_with(:name => "yep" ) }
0

精彩评论

暂无评论...
验证码 换一张
取 消