See commented line, then below On Jul 3, 11:33 pm, Shlomit Gazit <shlomitpatr...@gmail.com> wrote: > Joe, > > For example I was trying: > > $ie.radios.each do | radio | > if($ie.radio(:id,"ID_OTHER_OPTION_BUTTON")) ### This does the same > thing every time > puts("yes") > > else > puts("NO") > end > end > > The output was 15 yes instead of 1. >
The thing being evaluated in your if statement is doing the same thing every time, it's basicly returning an object, which not being zero is going to be seen as true. Functionally you are saying "if there is a radio button on the page with an ID value of xxxx then put yes Since nothing about that check changes, then each loop through it's going to report the same result.. (e.g. it's doing just what you told it to) Instead the If line should be written to use the value being set with each iteration, so that it will check each radio button in turn. You set tht to be called 'radio' so.. if radio.id == "ID_OTHER_OPTION_BUTTON" That's going to work because the code will loop through once for each radio button, and each time, that particular instace of the radio button is assigned to the variable 'radio', so it will have different contents each time, and you can check to see if the ID value is the one you want. Joedio's last posting is basically the same as above, but perhaps this provides a little more guidence so you see where you went wrong. -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. You received this message because you are subscribed to http://groups.google.com/group/watir-general To post: watir-general@googlegroups.com To unsubscribe: watir-general+unsubscr...@googlegroups.com