Sha256: 11bb302360a610dadc251d935b0a201e5f6367336bd5cc2882c871e667da4676

Contents?: true

Size: 668 Bytes

Versions: 30

Compression:

Stored size: 668 Bytes

Contents

require "webrat/core_extensions/detect_mapped"
require "webrat/core/locators/locator"

module Webrat
  module Locators

    class LabelLocator < Locator # :nodoc:

      def locate
        Label.load(@session, label_element)
      end

      def label_element
        label_elements.detect do |label_element|
          text(label_element) =~ /^\W*#{Regexp.escape(@value.to_s)}(\b|\Z)/i
        end
      end

      def label_elements
        @dom.xpath(*Label.xpath_search)
      end

      def text(label_element)
        str = label_element.inner_text
        str.gsub!("\n","")
        str.strip!
        str.squeeze!(" ")
        str
      end

    end

  end
end

Version data entries

30 entries across 30 versions & 15 rubygems

Version Path
diabolo-webrat-0.5.1 lib/webrat/core/locators/label_locator.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/webrat-0.7.3/lib/webrat/core/locators/label_locator.rb
indirect-webrat-0.7.5 lib/webrat/core/locators/label_locator.rb
indirect-webrat-0.7.4 lib/webrat/core/locators/label_locator.rb
webrat-0.7.3 lib/webrat/core/locators/label_locator.rb
jbd-webrat-0.7.2.rails3 lib/webrat/core/locators/label_locator.rb
webrat-0.7.2 lib/webrat/core/locators/label_locator.rb
webrat-0.7.2.beta.2 lib/webrat/core/locators/label_locator.rb
mutle-webrat-0.7.2.beta.1 lib/webrat/core/locators/label_locator.rb
thoughtbot-webrat-0.7.2.pre lib/webrat/core/locators/label_locator.rb
webrat-0.7.2.beta.1 lib/webrat/core/locators/label_locator.rb
honkster-webrat-0.7.1.2 lib/webrat/core/locators/label_locator.rb
honkster-webrat-0.7.1.1 lib/webrat/core/locators/label_locator.rb
revo-webrat-0.7.0.1 lib/webrat/core/locators/label_locator.rb
webrat-0.7.1 lib/webrat/core/locators/label_locator.rb
davidtrogers-webrat-0.7.0 lib/webrat/core/locators/label_locator.rb
revo-webrat-0.7.0 lib/webrat/core/locators/label_locator.rb
revo-webrat-0.7.1.pre lib/webrat/core/locators/label_locator.rb
webrat-0.7.0 lib/webrat/core/locators/label_locator.rb
honkster-webrat-0.6.0.10 lib/webrat/core/locators/label_locator.rb