Module: Locator

Extended by:
Locator, Decoding
Included in:
Locator
Defined in:
lib/locator.rb,
lib/locator/dom.rb,
lib/locator/xpath.rb,
lib/locator/result.rb,
lib/locator/boolean.rb,
lib/locator/element.rb,
lib/locator/matcher.rb,
lib/locator/version.rb,
lib/locator/decoding.rb,
lib/locator/assertions.rb,
lib/locator/dom/htmlunit.rb,
lib/locator/dom/nokogiri.rb,
lib/locator/element/area.rb,
lib/locator/element/file.rb,
lib/locator/element/form.rb,
lib/locator/element/link.rb,
lib/locator/element/field.rb,
lib/locator/element/input.rb,
lib/locator/element/label.rb,
lib/locator/element/button.rb,
lib/locator/element/select.rb,
lib/locator/element/content.rb,
lib/locator/matcher/have_tag.rb,
lib/locator/dom/htmlunit/page.rb,
lib/locator/dom/nokogiri/page.rb,
lib/locator/element/check_box.rb,
lib/locator/element/text_area.rb,
lib/locator/dom/htmlunit/element.rb,
lib/locator/dom/nokogiri/element.rb,
lib/locator/element/form_element.rb,
lib/locator/element/hidden_field.rb,
lib/locator/element/radio_button.rb,
lib/locator/element/elements_list.rb,
lib/locator/element/select_option.rb,
lib/locator/matcher/have_css_class.rb,
lib/locator/element/labeled_element.rb

Defined Under Namespace

Modules: Assertions, Boolean, Decoding, Dom, Matcher Classes: Element, ElementNotFound, Result, Xpath

Constant Summary collapse

VERSION =
"0.0.8"

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Decoding

decode, decode_attributes, decode_entities=, decode_entities?

Class Method Details

.[](type) ⇒ Object



22
23
24
# File 'lib/locator.rb', line 22

def [](type)
  locators[type.to_sym] || raise("unknown locator type: #{type}")
end

.build(type) ⇒ Object



26
27
28
29
# File 'lib/locator.rb', line 26

def build(type)
  locator = locators[type.to_sym] if type
  locator ? locator.new : Locator::Element.new(type)
end

Instance Method Details

#all(dom, *args) ⇒ Object



49
50
51
# File 'lib/locator.rb', line 49

def all(dom, *args)
  lookup(:all, dom, *args)
end

#locate(dom, *args, &block) ⇒ Object



53
54
55
# File 'lib/locator.rb', line 53

def locate(dom, *args, &block)
  lookup(:locate, dom, *args, &block)
end

#scopesObject



40
41
42
# File 'lib/locator.rb', line 40

def scopes
  @scopes ||= []
end

#within(*args) {|scopes.last| ... } ⇒ Object

Yields:



57
58
59
60
61
# File 'lib/locator.rb', line 57

def within(*args)
  dom = dom?(args.first) ? args.shift : scopes.pop
  scopes << resolve_scope(dom, args)
  yield(scopes.last)
end

#xpath(*args) ⇒ Object



44
45
46
47
# File 'lib/locator.rb', line 44

def xpath(*args)
  type = args.shift if args.first.is_a?(Symbol)
  Locator[type].new.xpath(*args)
end