You've kind of nailed it with the irb session. That's a really brittle regex and best avoided, now I understand the IE7/8 thing, how and where the DOM attributes show up really doesn't matter for browsers, coding it this way would be a code smell. This should work:
ie.radio(:name => 'anniversaryDate', :value => '10-01-2008').set However, I'm curious as to why you're setting anniversary_date and parsing the html, which seems to be the larger problem. It's hard to understand without the context of the script, but you should be able to store your variable away, and use it to set the radio button instead of scraping html. Let me know if that makes sense, ping me if it doesn't. I still want to stop down there sometime and see what you guys are doing. :) Charley Baker Lead Developer, Watir, http://watir.com On Fri, Sep 3, 2010 at 1:34 PM, Lisa Crispin <[email protected]> wrote: > I had a script fail when running it on IE8, it's several years old and works > fine on IE7. It's setting a radio button: > ie.radio(:name, 'anniversaryDate', anniversary_date).set > The value of anniversary_date is a date like '10-01-2008' (at least, in > IE7), it's set by using regex to parse the html > anniv_regex = /id=anniversaryDate(\d+).*?value="?(.+?)"? name=/ > > In IE7 the html looks like this: > <input type="radio" value="10-01-1992" name="anniversaryDate" > id="anniversaryDate1"> > > In IE8 the html looks like this: > <input name="anniversaryDate" id="anniversaryDate1" type="radio" > value="10-01-1992"/> > > In IE7, the value of anniversary_date ends up as: 10-01-2010 > In IE8, the value of anniversary_date ends up as: 10-01-2010 type=radio > > And I get an error "Watir::Exception::UnknownObjectException: Unable to > locate element, using :name, "anniversaryDate" > C:/Ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/element.rb:56:in > `assert_exists' > C:/Ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/element.rb:288:in > `enabled?' > C:/Ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/element.rb:60:in > `assert_enabled' > > C:/Ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/input_elements.rb:538:in > `set'" > > But in IRB if I type ie.radio(:name, 'anniversaryDate', '10-01-2010').set it > works fine - so it's not that it can't find the name, the value is wrong. > > So one problem is a weird IE8 thing, I don't know what to do about that. But > the other problem is, the error message is misleading. I wasted some time > thinking something was wrong with the name. > > Thanks > Lisa > > -- > Lisa Crispin > Co-author with Janet Gregory, _Agile Testing: A Practical Guide for Testers > and Agile Teams_ (Addison-Wesley 2009) > Contributor to _Beautiful Testing_ (O'Reilly 2009) > http://lisacrispin.com > @lisacrispin on Twitter > > -- > 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: [email protected] > To unsubscribe: [email protected] > -- 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: [email protected] To unsubscribe: [email protected]
