views:

181

answers:

1

This was added to the page later with jQuery:

<input name="pdfRadio" id="pdfRadioNo0" value="0" type="radio">

This code:

radio_id = "pdfRadioNo0"
ie.radio(:id, radio_id).set()

does not set it but returns an error message:

Watir::Exception::UnknownObjectException: Unable to locate element, using {:id=>"pdfRadioNo0"}

Does watir also find radio butons that were added later?

This is windows 32bit XP SP 3 , IE 7, watir 1.6.5, ruby 1.8.6

+2  A: 

I found out it is a timing issue.

I was trying to access the element in watir before it was created.

This code now works:

radio_id = "pdfRadioNo0"
Watir::Waiter.wait_until{ie.radio(:id, radio_id).exists?} 
ie.radio(:id, radio_id).set()

I found the solution in this thread:

http://groups.google.com/group/watir-general/browse_thread/thread/2dce70e313027d05

Karl, could you please mark your answer as correct, so that the question no longer looks like it was unanswered?
Bret Pettichord
Sorry, I don't know why this happened. Sometimes there is a forced delay. Thank you for reminding - karlthorwald - aka