0

I'm controlling an IE page using watir.

I have this command:-

browser.frame(:id,"ultraposuidialoghtm0").div(:class," content").button(:id,"ok").click

However the ultraposuidialoghtm0 part increments, so I get ultraposuidialoghtm1 etc.

How do I label my id as ultraposuidialoghtm*?

2 Answers 2

1

It looks like it supports regular expressions in method calls. Maybe it's worth trying something like:

browser
  .frame(:id, /ultraposuidialoghtm[0-9]*/)
  .div(:class," content")
  .button(:id, "ok")
  .click

I can't really test it at the moment, but it might be wort checking!

Good luck!

0
0

If id values are being used in accordance with the html spec, then they are unique within a page or frame. In that case you can use

browser
  .frame(:id, /ultraposuidialoghtm[0-9]*/)
  .button(:id, "ok").click

Using regular expressions can be slow however, so if the number and order of frames on the page is known, or if the frame is contained by some other easy to find container element, then you might want to locate by index, or just the first frame inside the container.

browser.div(:class => 'frame holder').frame.button(:id => 'ok').click

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.