Sha256: 09c5203b3ffe9005c37867fd2fff8a74ba2afc76b004053b0fc9a0d510ef5814

Contents?: true

Size: 728 Bytes

Versions: 44

Compression:

Stored size: 728 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/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

44 entries across 44 versions & 14 rubygems

Version Path
adva-0.3.2 test/webrat/lib/webrat/core/locators/label_locator.rb
adva-0.3.1 test/webrat/lib/webrat/core/locators/label_locator.rb
adva-0.3.0 test/webrat/lib/webrat/core/locators/label_locator.rb
adva-0.2.4 test/webrat/lib/webrat/core/locators/label_locator.rb
adva-0.2.3 test/webrat/lib/webrat/core/locators/label_locator.rb
adva-0.2.2 test/webrat/lib/webrat/core/locators/label_locator.rb
adva-0.2.1 test/webrat/lib/webrat/core/locators/label_locator.rb
adva-0.2.0 test/webrat/lib/webrat/core/locators/label_locator.rb
adva-0.1.4 test/webrat/lib/webrat/core/locators/label_locator.rb
adva-0.1.3 test/webrat/lib/webrat/core/locators/label_locator.rb
adva-0.1.2 test/webrat/lib/webrat/core/locators/label_locator.rb
adva-0.1.1 test/webrat/lib/webrat/core/locators/label_locator.rb
adva-0.1.0 test/webrat/lib/webrat/core/locators/label_locator.rb
adva-0.0.1 test/webrat/lib/webrat/core/locators/label_locator.rb
aslakhellesoy-webrat-0.3.2.1 lib/webrat/core/locators/label_locator.rb
aslakhellesoy-webrat-0.3.2.2 lib/webrat/core/locators/label_locator.rb
auxesis-webrat-0.4.1 lib/webrat/core/locators/label_locator.rb
benschwarz-webrat-0.3.2.1 lib/webrat/core/locators/label_locator.rb
brynary-webrat-0.3.2.1 lib/webrat/core/locators/label_locator.rb
brynary-webrat-0.3.2.2 lib/webrat/core/locators/label_locator.rb