On Thu, May 20, 2010 at 8:05 AM, KingMaker KingMaker
<sweetzubair / gmail.com>wrote:

> Hi Friends,
>
>         I try to check the Multiple Checkboxes in the page.
> first i read the value in the text file and assing it to the variable.
> but the problem is that at the time only one check box are selected.
>
> textfile values:
> selectedLocationOids=0000025354000000630d
> selectedLocationOids=000002527100000062bc
>
> ______________________________________________________________________________
> HTML Code:
>
> <input type="checkbox" value="0000025354000000630d"
> name="selectedLocationOids" id="selectedLocationOids"
> class="vmCheckbox">
>
> <input type="checkbox" value="000002527100000062bc"
> name="selectedLocationOids" id="selectedLocationOids"
> class="vmCheckbox">
>
> ______________________________________________________________________________
>
> RUBY Script:
> require 'watir'
> include Watir
> require 'logger'
>
> opts = {}
> File.open("c:/test/Flow1.txt") do |f|
>  f.each_line do |line|
>    opts[$1] = $2 if line =~ /^(.*)=(.*)$/
>  end
>  end
> @check_location = opts["selectedLocationOids"]
> @check_location1 = opts["selectedLocationOids"]
>
>
> ie.checkbox(:value,@check_location).set()
> ie.checkbox(:value,@check_location1).set()
> --
> Posted via http://www.ruby-forum.com/.
>
>

In addition to what Marcin said:
*Your html can't have two elements with the same ID (ID's must be unique,
like a social security number)
*Your inputs should end with /> instead of just > to close the tag.
*Since they are checkboxes, they should also have different names. The name
is what determines the name of the key that the server receives, so when you
have two inputs whose names are selectedLocationOids, then clicking both
causes one to be overwritten.

To illustrate, when I submit your form, my server receives:
Submitting with neither box checked
Parameters: {"commit"=>"Create",
"authenticity_token"=>"1vYLmUq7Yc52/Z8Gum2qxQz9i2YyXYL0+/4AEu434Wg="}

Submitting with the first box checked
Parameters: {"commit"=>"Create",
"selectedLocationOids"=>"0000025354000000630d",
"authenticity_token"=>"1vYLmUq7Yc52/Z8Gum2qxQz9i2YyXYL0+/4AEu434Wg="}

Submitting with the second box checked
Parameters: {"commit"=>"Create",
"selectedLocationOids"=>"000002527100000062bc",
"authenticity_token"=>"1vYLmUq7Yc52/Z8Gum2qxQz9i2YyXYL0+/4AEu434Wg="}

Submitting with both boxes checked
Parameters: {"commit"=>"Create",
"selectedLocationOids"=>"000002527100000062bc",
"authenticity_token"=>"1vYLmUq7Yc52/Z8Gum2qxQz9i2YyXYL0+/4AEu434Wg="}

You can see that that even with both boxes checked, only receive one value,
because they both have the same name. It might help you to read up on how
hash tables work (http://en.wikipedia.org/wiki/Hash_table)

* I'm on a Mac, so I can't check your example, but I'm not sure what "ie"
is. It looks like a variable ,but could be a method. If it is a method, I
don't see anything like it for Firefox, and their examples do not seem to
behave the way you have used it (http://watir.com/examples/) If it is a
variable, then where was it initialized? It looks like you need to say ie =
Browser.start("http://your-url.com")