Yeah this actually turns out to be the problem, which I had thought
before but had tried to solve incorrectly.

What I do now that works:

checkbox.fire_event("onclick")
checkbox.set

what I did before that did not work
checkbox.set
checkbox.click

or just
checkbox.click

Thanks,
Bryan Rasmussen

On Tue, Apr 12, 2011 at 7:16 PM, Chuck van der Linden <[email protected]> wrote:
> You may also need to consider the point that the thing is obviously
> got some javascript interacting with it, since it is wired up to
> respond to clicks..   Did you notice this part
>
> onclick="toggle_alt(this, 'PP-INTERNET-HOSTING-EN_CL1_ALT1', 'panel_PP-
> INTERNET-HOSTING-EN_CL1_ALT1')
>
> try seeing what happens if you .click  on it instead of using .set,
> or .click it after using .set
>
> Also try having a good look at the DOM with that thing both set and
> unset (doing that manually with the mouse) and see if perhaps the ID
> is changing or something?   I can't be sure what that javascript code
> is doing, but 'swap' in the name makes me suspect it's changing some
> aspect of the element (perhaps just it's alt text, but maybe it's ID
> also)
>
>
> On Apr 12, 6:31 am, Super Kevy <[email protected]> wrote:
>> Try checked?
>>
>> as puts ie.checkbox(:id,'myid').checked?
>>
>> On Apr 11, 4:11 am, bryan <[email protected]> wrote:
>>
>>
>>
>>
>>
>>
>>
>> > Hi,
>> > I asked this some days ago in a webdriver forum but haven't gotten any
>> > response.
>> > It's sort of a followup to my earlier question on how to set the value
>> > of an input element because I decided just to change the code to make
>> > it explicitly find the element as a checkbox.
>>
>> > I have the following code:
>>
>> > When /^I (un)?check "([^\"]*)"$/ do |negate, checkbox_label|
>> >   flag = ("un" != negate)
>> >   checkbox = $browser.checkbox(:id, checkbox_label)
>> >   puts checkbox.exists?
>> >  puts "checking checkbox"
>> >  puts checkbox.set?
>> >  if(flag)
>> >  puts "now what"
>> >   checkbox.set
>> >   puts checkbox.set?
>> >  else
>> >  puts "dont set id"
>> >   checkbox.clear
>> >  end
>> > end
>>
>> > The html that is being checked is
>>
>> > <input type="checkbox" title="Tilføj til din aftale"
>> > autocomplete="off" id="check_PP-INTERNET-HOSTING-EN_CL1_ALT1"
>> > onclick="toggle_alt(this, 'PP-INTERNET-HOSTING-EN_CL1_ALT1',
>> > 'panel_PP-
>> > INTERNET-HOSTING-EN_CL1_ALT1');">
>>
>> > And the output reads
>>
>> > true
>> > checking checkbox
>> > false
>> > now what
>> > false
>> >     And I check "check_PP-INTERNET-HOSTING-EN_CL7_ALT1"
>>
>> > so true checkbox exists,
>> > no error when I try to checkbox.set,
>> > but false for checkbox.set?
>>
>> > Any ideas what can be causing this, and any ways I can get around it.
>>
>> > Thanks,
>> > Bryan Rasmussen
>
> --
> Before posting, please read http://watir.com/support. In short: search before 
> you ask, be nice.
>
> [email protected]
> http://groups.google.com/group/watir-general
> [email protected]
>

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

[email protected]
http://groups.google.com/group/watir-general
[email protected]

Reply via email to