Forum: Ruby watir question regarding 'span'

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cc704ce316e72af824ccd38cfa53104b?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"
Cc704ce316e72af824ccd38cfa53104b?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 ".
This topic is locked and can not be replied to.