From: Rochit Sen Date: 2013-03-24T02:47:16+09:00 Subject: Re: Need to parse a list of checkboxes - ruby mechanize Rochit Sen wrote in post #1102943: > Hi All, > > I have a ruby mechanize form that has a list of some 45 checkboxes. Now > i want to parse that list and then check each checkbox. Any idea how? As > i donot want to write a line of code for each checkbox, i would want to > parse the checkboxes list. > I can get the name of a checkbox using the following code: > > chkName = checkboxForm.checkbox.name > > Now how would i parse the whole list to store the names in an array. > Once i get those in the array i can use the following code in a for loop > to compare the name in the mechanize checkbox_with(:name => > 'checkbox_name').check > > Please let me know what other better approach we can use. > > regards. Hi All, Was able to resolve it by spending some more thought on it :)). Did the following: ------ #Store all the checkbox names in a names array and compare the checkbox name to check it allChkBoxes = checkboxForm.checkboxes chkNames = [] allChkBoxes.each do |chkBx| chkNames = chkBx.name checkboxForm.checkbox_with(:name => "#{chkNames}").check end ------ -- Posted via http://www.ruby-forum.com/.