Class: AePageObjects::Collection
- Inherits:
-
Element
show all
- Defined in:
- lib/ae_page_objects/elements/collection.rb
Instance Attribute Summary
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?
#node, #stale?
#initialize
#document, #initialize, #node
Instance Method Details
#[](index, &block) ⇒ Object
14
15
16
|
# File 'lib/ae_page_objects/elements/collection.rb', line 14
def [](index, &block)
at(index, &block)
end
|
#add_more(&block) ⇒ Object
42
43
44
45
|
# File 'lib/ae_page_objects/elements/collection.rb', line 42
def add_more(&block)
append
last(&block)
end
|
#all ⇒ Object
24
25
26
27
28
|
# File 'lib/ae_page_objects/elements/collection.rb', line 24
def all
[].tap do |all|
self.each { |item| all << item }
end
end
|
#at(index, &block) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/ae_page_objects/elements/collection.rb', line 6
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
18
19
20
21
22
|
# File 'lib/ae_page_objects/elements/collection.rb', line 18
def each(&block)
(0..(size - 1)).each do |index|
yield at(index)
end
end
|
#first(&block) ⇒ Object
34
35
36
|
# File 'lib/ae_page_objects/elements/collection.rb', line 34
def first(&block)
self.at(0, &block)
end
|
#last(&block) ⇒ Object
38
39
40
|
# File 'lib/ae_page_objects/elements/collection.rb', line 38
def last(&block)
self.at(size - 1, &block)
end
|
#row_xpath ⇒ Object
47
48
49
|
# File 'lib/ae_page_objects/elements/collection.rb', line 47
def row_xpath
@row_xpath || ".//*[contains(@class, 'item-list')]//*[contains(@class,'row') and not(contains(@style,'display'))]"
end
|
#size ⇒ Object
30
31
32
|
# File 'lib/ae_page_objects/elements/collection.rb', line 30
def size
node.all(:xpath, row_xpath).size
end
|