Class: AePageObjects::Collection
- Inherits:
-
Element
show all
- Defined in:
- lib/ae_page_objects/elements/collection.rb
Constant Summary
Node::Methods::METHODS_TO_DELEGATE_TO_NODE
Class Attribute Summary collapse
Attributes inherited from Element
#parent
Instance Method Summary
collapse
Methods inherited from Element
#__full_name__, #__name__, #document, #full_name, #initialize, #name, new, #to_s, #using_default_locator?
Methods included from Dsl
#collection, #element, #form_for, #inherited
#ensure_class_for_param!
#current_url, #current_url_without_params, #new_subclass
#node, #stale?
#initialize
#current_url, #current_url_without_params, #document, #initialize, #node
Class Attribute Details
.item_class ⇒ Object
Returns the value of attribute item_class.
4
5
6
|
# File 'lib/ae_page_objects/elements/collection.rb', line 4
def item_class
@item_class
end
|
Instance Method Details
#[](index, &block) ⇒ Object
26
27
28
|
# File 'lib/ae_page_objects/elements/collection.rb', line 26
def [](index, &block)
at(index, &block)
end
|
#add_more(&block) ⇒ Object
54
55
56
57
|
# File 'lib/ae_page_objects/elements/collection.rb', line 54
def add_more(&block)
append
last(&block)
end
|
#all ⇒ Object
36
37
38
39
40
|
# File 'lib/ae_page_objects/elements/collection.rb', line 36
def all
[].tap do |all|
self.each { |item| all << item }
end
end
|
#at(index, &block) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/ae_page_objects/elements/collection.rb', line 18
def at(index, &block)
if index >= size || index < 0
nil
else
self.item_class.new(self, :name => index, :locator => [:xpath, "#{row_xpath}[#{index + 1}]"], &block)
end
end
|
#each(&block) ⇒ Object
30
31
32
33
34
|
# File 'lib/ae_page_objects/elements/collection.rb', line 30
def each(&block)
(0..(size - 1)).each do |index|
yield at(index)
end
end
|
#first(&block) ⇒ Object
46
47
48
|
# File 'lib/ae_page_objects/elements/collection.rb', line 46
def first(&block)
self.at(0, &block)
end
|
#item_class ⇒ Object
14
15
16
|
# File 'lib/ae_page_objects/elements/collection.rb', line 14
def item_class
self.class.item_class
end
|
#last(&block) ⇒ Object
50
51
52
|
# File 'lib/ae_page_objects/elements/collection.rb', line 50
def last(&block)
self.at(size - 1, &block)
end
|
#row_xpath ⇒ Object
59
60
61
|
# File 'lib/ae_page_objects/elements/collection.rb', line 59
def row_xpath
@row_xpath || ".//*[contains(@class, 'item-list')]//*[contains(@class,'row') and not(contains(@style,'display'))]"
end
|
#size ⇒ Object
42
43
44
|
# File 'lib/ae_page_objects/elements/collection.rb', line 42
def size
node.all(:xpath, row_xpath).size
end
|