Forum: Ruby watir question regarding 'span'

5dfc843f9ecf6fb64b52a35bdce43910?d=identicon&s=25 Raja gopalan (arc)
on 2014-08-06 15:13
hi,

<span class="ui-btn-text"> Get Instant Quote </span>

Is there anyway Can I write code locate the element using the text
" Get Instant Quote "?

I can write a code like

b.span(:class,'ui-btn-text').click

But this :class attribute is common to every other elements, So is there
any way to locate the span using the text '  Get Instant Quote '?

Any help?
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2014-08-07 00:09
Did you try "text"?

irb(main):003:0> b.span(text: 'Get Instant Quote')
=> #<Watir::Span:0x487ee79c located=false selector={:text=>"Get Instant
Quote", :tag_name=>"span"}>
irb(main):004:0> b.span(text: 'Get Instant
Quote').attribute_value('class')
=> "ui-btn-text"
5dfc843f9ecf6fb64b52a35bdce43910?d=identicon&s=25 Raja gopalan (arc)
on 2014-08-07 07:49
hi, This works fine for me, thanks, yesterday I tried using the same way
but it hasn't worked, may I might have added some space like " Get
Instant Quote ".
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.