Sha256: c586f417afe9442658ddd8b593fb2c483d9cea75064cba08ee1c8b6cbe5f8863

Contents?: true

Size: 816 Bytes

Versions: 41

Compression:

Stored size: 816 Bytes

Contents

require "webrat/core/locators/locator"

module Webrat
  module Locators
    
    class AreaLocator < Locator # :nodoc:
      
      def locate
        Area.load(@session, area_element)
      end
  
      def area_element
        area_elements.detect do |area_element|
          Webrat::XML.attribute(area_element, "title") =~ matcher ||
          Webrat::XML.attribute(area_element, "id") =~ matcher
        end
      end
  
      def matcher
        /#{Regexp.escape(@value.to_s)}/i
      end
  
      def area_elements
        Webrat::XML.xpath_search(@dom, Area.xpath_search)
      end
  
      def error_message
        "Could not find area with name #{@value}"
      end
      
    end
    
    def find_area(id_or_title) #:nodoc:
      AreaLocator.new(@session, dom, id_or_title).locate!
    end
    
  end
end

Version data entries

41 entries across 41 versions & 14 rubygems

Version Path
adva-0.2.4 test/webrat/lib/webrat/core/locators/area_locator.rb
adva-0.2.3 test/webrat/lib/webrat/core/locators/area_locator.rb
adva-0.2.2 test/webrat/lib/webrat/core/locators/area_locator.rb
adva-0.2.1 test/webrat/lib/webrat/core/locators/area_locator.rb
adva-0.2.0 test/webrat/lib/webrat/core/locators/area_locator.rb
adva-0.1.4 test/webrat/lib/webrat/core/locators/area_locator.rb
adva-0.1.3 test/webrat/lib/webrat/core/locators/area_locator.rb
adva-0.1.2 test/webrat/lib/webrat/core/locators/area_locator.rb
adva-0.1.1 test/webrat/lib/webrat/core/locators/area_locator.rb
adva-0.1.0 test/webrat/lib/webrat/core/locators/area_locator.rb
adva-0.0.1 test/webrat/lib/webrat/core/locators/area_locator.rb
aslakhellesoy-webrat-0.3.2.1 lib/webrat/core/locators/area_locator.rb
aslakhellesoy-webrat-0.3.2.2 lib/webrat/core/locators/area_locator.rb
auxesis-webrat-0.4.1 lib/webrat/core/locators/area_locator.rb
benschwarz-webrat-0.3.2.1 lib/webrat/core/locators/area_locator.rb
brynary-webrat-0.3.2.1 lib/webrat/core/locators/area_locator.rb
brynary-webrat-0.3.2.2 lib/webrat/core/locators/area_locator.rb
brynary-webrat-0.4.0 lib/webrat/core/locators/area_locator.rb
diabolo-webrat-0.4.2 lib/webrat/core/locators/area_locator.rb
flazz-webrat-0.3.2.1 lib/webrat/core/locators/area_locator.rb