Sha256: 1746c89d4cfdbbf25a8e96b5287ca409c932cd0df7e3b94e83942dd314c34037

Contents?: true

Size: 704 Bytes

Versions: 43

Compression:

Stored size: 704 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
        Webrat::XML.xpath_search(@dom, Label.xpath_search)
      end

      def text(label_element)
        str = Webrat::XML.all_inner_text(label_element)
        str.gsub!("\n","")
        str.strip!
        str.squeeze!(" ")
        str
      end

    end

  end
end

Version data entries

43 entries across 43 versions & 19 rubygems

Version Path
aslakhellesoy-webrat-0.4.4.1 lib/webrat/core/locators/label_locator.rb
casebook-webrat-0.4.4.1 lib/webrat/core/locators/label_locator.rb
davidtrogers-webrat-0.4.4.2 lib/webrat/core/locators/label_locator.rb
dbrady-webrat-0.4.4.2 lib/webrat/core/locators/label_locator.rb
diabolo-webrat-0.4.4.1 lib/webrat/core/locators/label_locator.rb
diabolo-webrat-0.4.4.2 lib/webrat/core/locators/label_locator.rb
diabolo-webrat-0.4.4 lib/webrat/core/locators/label_locator.rb
dstrelau-webrat-0.5.1 lib/webrat/core/locators/label_locator.rb
emipair-webrat-0.0.1 lib/webrat/core/locators/label_locator.rb
futuresinc-webrat-0.4.4.100 lib/webrat/core/locators/label_locator.rb
futuresinc-webrat-0.4.4.99 lib/webrat/core/locators/label_locator.rb
garnierjm-webrat-0.4.5 lib/webrat/core/locators/label_locator.rb
hardbap-webrat-0.5.1 lib/webrat/core/locators/label_locator.rb
hardbap-webrat-0.5.2 lib/webrat/core/locators/label_locator.rb
jwilger-webrat-0.4.4.2 lib/webrat/core/locators/label_locator.rb
jwilger-webrat-0.4.4.3 lib/webrat/core/locators/label_locator.rb
jwilger-webrat-0.4.4.4 lib/webrat/core/locators/label_locator.rb
jwilger-webrat-0.4.4.5 lib/webrat/core/locators/label_locator.rb
ohammersmith-webrat-0.4.4.100 lib/webrat/core/locators/label_locator.rb
ohammersmith-webrat-0.4.4.98 lib/webrat/core/locators/label_locator.rb