Chris Harris
2007-Feb-15 01:56 UTC
[Mechanize-users] How to select randomly named checkbox
I am trying to select a checkbox that is randomly named depending on the ID assigned to it by the webpage. [9713816764515361h] is the random bit. #<WWW::Mechanize::CheckBox:0x7a2b3c0 @checked=false, @name="communityContentFields[9713816764515361h].postToArea_checkbox", @value="true"> What code should I use to check the box? Thanks Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mechanize-users/attachments/20070214/51732bbb/attachment.html
Aaron Patterson
2007-Feb-15 03:45 UTC
[Mechanize-users] How to select randomly named checkbox
On Wed, Feb 14, 2007 at 05:56:34PM -0800, Chris Harris wrote:> I am trying to select a checkbox that is randomly named depending on the ID assigned to it by the webpage. > > [9713816764515361h] is the random bit. > > #<WWW::Mechanize::CheckBox:0x7a2b3c0 > @checked=false, > @name="communityContentFields[9713816764515361h].postToArea_checkbox", > @value="true"> > > What code should I use to check the box?You can find the checkbox with a regex. For example, if you have a form object named ''form'': form.checkboxes.find { |f| f.name =~ /communityContentFields/ # Or a more specific regex }.checked = true -- Aaron Patterson http://tenderlovemaking.com/