page-object 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +10 -0
  3. data/features/button.feature +13 -3
  4. data/features/html/indexed_property.html +3 -0
  5. data/features/html/static_elements.html +2 -0
  6. data/features/indexed_property.feature +20 -1
  7. data/features/section.feature +132 -0
  8. data/features/step_definitions/accessor_steps.rb +4 -0
  9. data/features/step_definitions/button_steps.rb +5 -0
  10. data/features/step_definitions/indexed_property_steps.rb +36 -2
  11. data/features/step_definitions/section_steps.rb +268 -0
  12. data/lib/page-object.rb +19 -7
  13. data/lib/page-object/accessors.rb +48 -0
  14. data/lib/page-object/elements/element.rb +4 -4
  15. data/lib/page-object/indexed_properties.rb +7 -3
  16. data/lib/page-object/loads_platform.rb +24 -5
  17. data/lib/page-object/platforms/selenium_webdriver.rb +14 -2
  18. data/lib/page-object/platforms/selenium_webdriver/button.rb +3 -3
  19. data/lib/page-object/platforms/selenium_webdriver/element.rb +1 -1
  20. data/lib/page-object/platforms/selenium_webdriver/page_object.rb +50 -0
  21. data/lib/page-object/platforms/watir_webdriver.rb +15 -3
  22. data/lib/page-object/platforms/watir_webdriver/element.rb +1 -1
  23. data/lib/page-object/platforms/watir_webdriver/page_object.rb +30 -0
  24. data/lib/page-object/sections.rb +29 -0
  25. data/lib/page-object/version.rb +1 -1
  26. data/page-object.gemspec +3 -3
  27. data/spec/page-object/elements/button_spec.rb +14 -0
  28. data/spec/page-object/elements/selenium_element_spec.rb +5 -0
  29. data/spec/page-object/elements/watir_element_spec.rb +4 -0
  30. data/spec/page-object/loads_platform_spec.rb +3 -3
  31. data/spec/page-object/page-object_spec.rb +1 -0
  32. data/spec/page-object/page_section_spec.rb +73 -0
  33. data/spec/spec_helper.rb +3 -1
  34. metadata +15 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10f43de4180ab498bb6929df07232deeee0ab0fb
4
- data.tar.gz: fd5f9cb5d67e7af41c90a645e32e33a6babf2a2a
3
+ metadata.gz: 5e87a5991df66aba958bfa1d69bd5defb8f5dbfc
4
+ data.tar.gz: 2fccd9a610ae80b2c9762a0f9bdc2827b55ac5e7
5
5
  SHA512:
6
- metadata.gz: 76cbc1ff4202177c001c56f574395cb7c233eca802acb1c7e448c709536c5af68cea6cb77be1bdbbf327ead2cc67f920de58da9513e218cf773b5ade4fd14fe5
7
- data.tar.gz: eeca209c3157f4d49d6458952546f5130127c342f38d1515fb3c95e4bfaf81479c3147e8fb9ad0255d13ed98bb3e083bed1dc3b38890cf02a262305f49f98e44
6
+ metadata.gz: f7c67f99e80f010e75da294dcd4894454d0d4a30ffdb9b9396e48c2c440abaa41a853491f1f7de0c184e9486ddeb7580d7efca54477c8e221acc8395f2648e11
7
+ data.tar.gz: ae0f71731920795dd10e2eb77c7702bc6fc64bca0c4c9ef52a9a3da459399a2ec67d95c79fc371f625b313b29d9b72296e9d8e86335822faf452901ca324b210
data/ChangeLog CHANGED
@@ -1,3 +1,13 @@
1
+ === Version 1.1.0
2
+ * Enhancements
3
+ * Performance enhancements when initializing elements (Thanks Dane Andersen)
4
+ * Enabled button elements to return text when using selenium-webdriver.
5
+ * Added support for :index identifier in indexed properties.
6
+ * Added page_section and page_sections accessor methods which can specify a page object of elements on another page object.
7
+ * Fixes
8
+ * Fixed issue causing exceptions when comparing equality of element to non-element objects.
9
+ * Fixed issue that causes indexed properties to return the same value for any index.
10
+
1
11
  === Version 1.0.3 / 2014-12-9
2
12
  * Enhancements
3
13
  * Added support for the bold tag (Thanks sedx)
@@ -9,11 +9,11 @@ Feature: Button
9
9
  Scenario: Clicking a button (type=submit)
10
10
  When I click the button
11
11
  Then I should be on the success page
12
-
12
+
13
13
  Scenario: Clicking a button (type=image)
14
14
  When I click the button with type image
15
15
  Then I should be on the success page
16
-
16
+
17
17
  Scenario: Clicking an image button by src
18
18
  When I click the image button using src
19
19
  Then I should be on the success page
@@ -62,6 +62,16 @@ Feature: Button
62
62
  | search_by |
63
63
  | text |
64
64
 
65
+ @dane
66
+ Scenario Outline: Getting the text from a button
67
+ When I get the text for a button that is a "<tag>"
68
+ Then the text should be "This button is a <tag>"
69
+
70
+ Scenarios:
71
+ | tag |
72
+ | button |
73
+ | input |
74
+
65
75
  Scenario Outline: Locating button using multiple parameters
66
76
  When I search for the button by "<param1>" and "<param2>"
67
77
  Then I should be able to click the button
@@ -70,7 +80,7 @@ Feature: Button
70
80
  | param1 | param2 |
71
81
  | class | index |
72
82
  | name | index |
73
-
83
+
74
84
  Scenario Outline: Locating real button using multiple parameters
75
85
  When I search for the button by "<param1>" and "<param2>"
76
86
  Then I should be able to click the real button
@@ -12,6 +12,7 @@
12
12
  <td><textarea id="table[123].area" rows="2" cols="20"></textarea></td>
13
13
  <td><input id="table[123].button" type="submit" value="Click 123"/></td>
14
14
  <td><div id="table[123].content">123!</div></td>
15
+ <td><div id="table[123].bad_name">BAD ELEMENT NAME</div></td>
15
16
  </tr>
16
17
  <tr>
17
18
  <td><input type="text" id="table[foo].text" name="tableName[foo].text" size="20"/></td>
@@ -20,6 +21,7 @@
20
21
  <td><textarea id="table[foo].area" rows="2" cols="20"></textarea></td>
21
22
  <td><input id="table[foo].button" type="submit" value="Click foo"/></td>
22
23
  <td><div id="table[foo].content">foo!</div></td>
24
+ <td><div id="table[foo].bad_name">BAD ELEMENT NAME</div></td>
23
25
  </tr>
24
26
  <tr>
25
27
  <td><input type="text" id="table[12test].text" name="tableName[12test].text" size="20"/></td>
@@ -28,6 +30,7 @@
28
30
  <td><textarea id="table[12test].area" rows="2" cols="20"></textarea></td>
29
31
  <td><input id="table[12test].button" type="submit" value="Click 12test"/></td>
30
32
  <td><div id="table[12test].content">12test!</div></td>
33
+ <td><div id=""table[12test].bad_name>BAD ELEMENT NAME</div></td>
31
34
  </tr>
32
35
  </table>
33
36
 
@@ -199,6 +199,8 @@
199
199
  <img src="images/img_pulpit.jpg" alt="The Pulpit Rock" width="304" height="228">
200
200
  </figure>
201
201
  This text have <b id="b_id" class="b_class" name="b_name">some text in bold</b>
202
+ <button id="button_button">This button is a button</button>
203
+ <input id="input_button" type="button" value="This button is a input" />
202
204
  </body>
203
205
  </html>
204
206
 
@@ -71,6 +71,16 @@ Feature: Indexed Property
71
71
  | 123 |
72
72
  | 12test |
73
73
 
74
+ Scenario Outline: Locating indexed text fields by index in a table on the page
75
+ When I search for the elements for index "<index>"
76
+ And I select the table's indexed radio button
77
+ Then The table's indexed radio button should be selected
78
+
79
+ Scenarios:
80
+ | index |
81
+ | 0 |
82
+ | 1 |
83
+
74
84
  Scenario Outline: Locating indexed text fields outside a table on the Page
75
85
  When I search for the elements for index "<index>"
76
86
  And I type "I found it" into the regular indexed text field by id
@@ -95,4 +105,13 @@ Feature: Indexed Property
95
105
  Scenario: Index on first indexed property and different on second
96
106
  When I search for an element with text by an index on an indexed property
97
107
  And I search using an index which is on another indexed property
98
- Then I should see the content of the element on the second indexed property
108
+ Then I should see the content of the element on the second indexed property
109
+
110
+ Scenario: Different indexes on stored indexed property
111
+ When I search for an element with text by an index on an indexed property
112
+ And I search for a different element with text by index on the indexed property
113
+ Then I should see the contents of both elements
114
+
115
+ Scenario: Can't redefine ruby methods
116
+ When I use a name that collides with a ruby method on an indexed property
117
+ Then the original method remains
@@ -0,0 +1,132 @@
1
+ Feature: Sections
2
+
3
+ Background:
4
+ Given I am on the section elements page
5
+
6
+ Scenario: Getting the text from a section
7
+ When I get the text from the section
8
+ Then the text should include "page-object rocks!"
9
+
10
+ Scenario: Cannot find elements not in the section
11
+ When I access an element that is outside of the section
12
+ Then I should see that it doesn't exist in the section
13
+
14
+ Scenario: Finding a link within a section
15
+ When I search for a link located in a section
16
+ Then I should be able to click the section link
17
+
18
+ Scenario: Finding a button within a section
19
+ When I search for a button located in a section
20
+ Then I should be able to click the section button
21
+
22
+ Scenario: Finding a text field within a section
23
+ When I search for a text field located in a section
24
+ Then I should be able to type "123abc" in the section text field
25
+
26
+ Scenario: Finding a hidden field within a section
27
+ When I search for a hidden field located in a section
28
+ Then I should be able to see that the section hidden field contains "LeanDog"
29
+
30
+ Scenario: Finding a text area within a section
31
+ When I search for a text area located in a section
32
+ Then I should be able to type "abcdefg" in the section text area
33
+
34
+ Scenario: Finding a select list within a section
35
+ When I search for a select list located in a section
36
+ Then I should be able to select "Test 2" in the section select list
37
+
38
+ Scenario: Finding a file field within a section
39
+ When I search for a file field located in a section
40
+ Then I should be able to set the section file field
41
+
42
+ Scenario: Finding a checkbox within a section
43
+ When I search for a checkbox located in a section
44
+ Then I should be able to check the section checkbox
45
+
46
+ Scenario: Finding a radio button witin a section
47
+ When I search for a radio button located in a section
48
+ Then I should be able to select the section radio button
49
+
50
+ Scenario: Finding a div within a section
51
+ When I search for a div located in a section
52
+ Then I should see the text "page-object rocks!" in the section div
53
+
54
+ Scenario: Finding a span within a section
55
+ When I search for a span located in a section
56
+ Then I should see the text "My alert" in the section span
57
+
58
+ Scenario: Finding a table within a section
59
+ When I search for a table located in a section
60
+ Then the data for row "1" of the section table should be "Data1" and "Data2"
61
+
62
+ Scenario: Finding a table cell within a section
63
+ When I search the second table cell located in a table in a section
64
+ Then the section table cell should contain "Data2"
65
+
66
+ Scenario: Finding an image within a section
67
+ When I search for an image located in a section
68
+ Then the section image should be "106" pixels wide
69
+ And the section image should be "106" pixels tall
70
+
71
+ Scenario: Finding a form within a section
72
+ When I search for a form located in a section
73
+ Then I should be able to submit the section form
74
+
75
+ Scenario: Finding an ordered list within a section
76
+ When I search for an ordered list located in a section
77
+ Then the first section list items text should be "Number One"
78
+
79
+ Scenario: Finding an unordered list within a section
80
+ When I search for an unordered list located in a section
81
+ Then the first section list items text should be "Item One"
82
+
83
+ Scenario: Finding a list item section in an ordered list within a section
84
+ When I search for a list item section in an ordered list in a section
85
+ Then I should see the section list items text should be "Number One"
86
+
87
+ Scenario: Finding a h1 within a section
88
+ When I search for a h1 located in a section
89
+ Then I should see the section h1s text should be "h1's are cool"
90
+
91
+ Scenario: Finding a h2 within a section
92
+ When I search for a h2 located in a section
93
+ Then I should see the section h2s text should be "h2's are cool"
94
+
95
+ Scenario: Finding a h3 within a section
96
+ When I search for a h3 located in a section
97
+ Then I should see the section h3s text should be "h3's are cool"
98
+
99
+ Scenario: Finding a h4 within a section
100
+ When I search for a h4 located in a section
101
+ Then I should see the section h4s text should be "h4's are cool"
102
+
103
+ Scenario: Finding a h5 within a section
104
+ When I search for a h5 located in a section
105
+ Then I should see the section h5s text should be "h5's are cool"
106
+
107
+ Scenario: Finding a h6 within a section
108
+ When I search for a h6 located in a section
109
+ Then I should see the section h6s text should be "h6's are cool"
110
+
111
+ Scenario: Finding a paragraph within a section
112
+ When I search for a paragraph located in a section
113
+ Then I should see the section paragraphs text should be "This is a paragraph."
114
+
115
+ Scenario: Indexed property in section
116
+ Given I search for a link in an indexed property located in a section
117
+ Then I should see the text "Success" in the section indexed link
118
+
119
+ Scenario: Selecting multiple sections
120
+ When I select multiple sections
121
+ Then I should have a section collection containing the sections
122
+ And I can access any index of that collection of sections
123
+
124
+ Scenario: Searching section collection
125
+ Given I select multiple sections
126
+ When I search by a specific value of the section
127
+ Then I will find the first section with that value
128
+
129
+ Scenario: Filtering section collection
130
+ Given I select multiple sections
131
+ When I filter by a specific value of the sections
132
+ Then I will find all sections with that value
@@ -6,6 +6,10 @@ Then /^the text should be "([^\"]*)"$/ do |expected_text|
6
6
  @text.should == expected_text
7
7
  end
8
8
 
9
+ Then /^the text should include "([^\"]*)"$/ do |expected_text|
10
+ expect(@text).to include expected_text
11
+ end
12
+
9
13
  Then /^I should be on the success page$/ do
10
14
  @page.text.should include 'Success'
11
15
  @page.title.should == 'Success'
@@ -41,3 +41,8 @@ end
41
41
  Then /^I should see that the button exists$/ do
42
42
  @page.button_id?.should == true
43
43
  end
44
+
45
+
46
+ When(/^I get the text for a button that is a "([^"]*)"$/) do |tagname|
47
+ @text = @page.button_element(:id => "#{tagname}_button").text
48
+ end
@@ -7,7 +7,11 @@ class IndexedPropertyPage
7
7
  [:checkbox, :check, {:id => 'table[%s].check'}],
8
8
  [:text_area, :area, {:id => 'table[%s].area'}],
9
9
  [:button, :button, {:id => 'table[%s].button'}],
10
- [:div, :content, {:id => 'table[%s].content'}]]
10
+ [:div, :content, {:id => 'table[%s].content'}],
11
+ [:div, :nil?, {:id => 'table[%s].bad_name'}],
12
+ ]
13
+
14
+ indexed_property :index_table, [[:radio_button, :radio, {:index => '%d'}]]
11
15
 
12
16
  indexed_property :nottable, [[:text_field, :text_nottable, {:id => 'nottable[%s].text'}]]
13
17
 
@@ -125,5 +129,35 @@ Then(/^I should see the content of the element on the second indexed property$/)
125
129
  end
126
130
 
127
131
  When(/^I search for an element with text by an index on an indexed property$/) do
128
- expect(page.table['123'].content).to eq '123!'
132
+ @indexed_property = page.table
133
+ @contents = [@indexed_property['123'].content]
134
+ expect(@contents[0]).to eq '123!'
135
+ end
136
+
137
+ And(/^I search for a different element with text by index on the indexed property$/) do
138
+ @contents << @indexed_property['12test'].content
139
+ end
140
+
141
+ Then(/^I should see the contents of both elements$/) do
142
+ expect(@contents).to eq ['123!','12test!']
143
+ end
144
+
145
+ When(/^I use a name that collides with a ruby method on an indexed property$/) do
146
+ #noop element is already defined on indexed property
147
+ end
148
+
149
+ Then(/^the original method remains$/) do
150
+ expect(page.table['foo'].nil?).to be false
151
+ end
152
+
153
+ When(/^I search for the elements with index (.*)$/) do |index|
154
+ @index = index.to_i
155
+ end
156
+
157
+ And(/^I select the table's indexed radio button$/) do
158
+ page.index_table[@index].select_radio
159
+ end
160
+
161
+ Then(/^The table's indexed radio button should be selected$/) do
162
+ expect(page.index_table[@index]).to be_radio_selected
129
163
  end
@@ -0,0 +1,268 @@
1
+ class Container
2
+ include PageObject
3
+
4
+ link(:section_link)
5
+ button(:section_button)
6
+ text_field(:section_text_field)
7
+ hidden_field(:section_hidden_field)
8
+ text_area(:section_text_area)
9
+ select_list(:section_select_list)
10
+ checkbox(:section_checkbox)
11
+ radio_button(:section_radio_button)
12
+ div(:section_div)
13
+ span(:section_span)
14
+ table(:section_table)
15
+ cell(:section_cell) { |page| page.section_table_element.cell_element(:index => 1) }
16
+ image(:section_image)
17
+ form(:section_form)
18
+ ordered_list(:section_ordered_list)
19
+ unordered_list(:section_unordered_list)
20
+ list_item(:section_list_item) { |page| page.section_ordered_list_element.list_item_element }
21
+ h1(:section_h1)
22
+ h2(:section_h2)
23
+ h3(:section_h3)
24
+ h4(:section_h4)
25
+ h5(:section_h5)
26
+ h6(:section_h6)
27
+ paragraph(:section_paragraph)
28
+ file_field(:section_file_field)
29
+
30
+ indexed_property(:indexed_list,[[:link,:indexed_link,href: '%s.html']])
31
+
32
+ unordered_list(:outside_section, :id => 'outer')
33
+ end
34
+
35
+ class InputSection
36
+ include PageObject
37
+
38
+ def value
39
+ root.value
40
+ end
41
+ end
42
+
43
+ class SectionElementsPage
44
+ include PageObject
45
+
46
+ page_section(:container, Container, :id => 'div_id')
47
+ page_sections(:page_inputs, InputSection, :tag_name => 'input')
48
+ end
49
+
50
+ When(/^I get the text from the section$/) do
51
+ @text = @page.container.text
52
+ end
53
+
54
+ Given /^I am on the section elements page$/ do
55
+ @page = SectionElementsPage.new(@browser)
56
+ @page.navigate_to(UrlHelper.nested_elements)
57
+ end
58
+
59
+ When /^I search for a link located in a section$/ do
60
+ @link = @page.container.section_link_element
61
+ end
62
+
63
+ Then /^I should be able to click the section link$/ do
64
+ @link.click
65
+ end
66
+
67
+ When /^I search for a button located in a section$/ do
68
+ @button = @page.container.section_button_element
69
+ end
70
+
71
+ Then /^I should be able to click the section button$/ do
72
+ @button.click
73
+ end
74
+
75
+ When /^I search for a text field located in a section$/ do
76
+ @text_field = @page.container.section_text_field_element
77
+ end
78
+
79
+ Then /^I should be able to type "([^\"]*)" in the section text field$/ do |value|
80
+ @text_field.value = value
81
+ end
82
+
83
+ When /^I search for a hidden field located in a section$/ do
84
+ @hidden_field = @page.container.section_hidden_field_element
85
+ end
86
+
87
+ Then /^I should be able to see that the section hidden field contains "([^\"]*)"$/ do |value|
88
+ @hidden_field.value.should == value
89
+ end
90
+
91
+ When /^I search for a text area located in a section$/ do
92
+ @text_area = @page.container.section_text_area_element
93
+ end
94
+
95
+ Then /^I should be able to type "([^\"]*)" in the section text area$/ do |value|
96
+ @text_area.value = value
97
+ end
98
+
99
+ When /^I search for a select list located in a section$/ do
100
+ @select_list = @page.container.section_select_list_element
101
+ end
102
+
103
+ Then /^I should be able to select "([^\"]*)" in the section select list$/ do |value|
104
+ @select_list.select value
105
+ end
106
+
107
+ When /^I search for a checkbox located in a section$/ do
108
+ @checkbox = @page.container.section_checkbox_element
109
+ end
110
+
111
+ Then /^I should be able to check the section checkbox$/ do
112
+ @checkbox.check
113
+ end
114
+
115
+ When /^I search for a radio button located in a section$/ do
116
+ @radio = @page.container.section_radio_button_element
117
+ end
118
+
119
+ Then /^I should be able to select the section radio button$/ do
120
+ @radio.select
121
+ end
122
+
123
+ When /^I search for a div located in a section$/ do
124
+ @div = @page.container.section_div_element
125
+ end
126
+
127
+ Then /^I should see the text "([^\"]*)" in the section div$/ do |value|
128
+ @div.text.should == value
129
+ end
130
+
131
+ Then /^I should see the text "([^\"]*)" in the section indexed link$/ do |value|
132
+ @link.text.should == value
133
+ end
134
+
135
+ When /^I search for a span located in a section$/ do
136
+ @span = @page.container.section_span_element
137
+ end
138
+
139
+ Then /^I should see the text "([^\"]*)" in the section span$/ do |value|
140
+ @span.text.should == value
141
+ end
142
+
143
+ When /^I search for a table located in a section$/ do
144
+ @table = @page.container.section_table_element
145
+ end
146
+
147
+ Then /^the data for row "([^\"]*)" of the section table should be "([^\"]*)" and "([^\"]*)"$/ do |row, col1, col2|
148
+ table_row = @table[row.to_i - 1]
149
+ table_row[0].text.should == col1
150
+ table_row[1].text.should == col2
151
+ end
152
+
153
+ When /^I search the second table cell located in a table in a section$/ do
154
+ @cell = @page.container.section_cell_element
155
+ end
156
+
157
+ Then /^the section table cell should contain "([^\"]*)"$/ do |value|
158
+ @cell.text.should == value
159
+ end
160
+
161
+ When /^I search for an image located in a section$/ do
162
+ @image = @page.container.section_image_element
163
+ end
164
+
165
+ Then /^the section image should be "([^\"]*)" pixels wide$/ do |width|
166
+ @image.width.should == width.to_i
167
+ end
168
+
169
+ Then /^the section image should be "([^\"]*)" pixels tall$/ do |height|
170
+ @image.height.should == height.to_i
171
+ end
172
+
173
+ When /^I search for a form located in a section$/ do
174
+ @form = @page.container.section_form_element
175
+ end
176
+
177
+ Then /^I should be able to submit the section form$/ do
178
+ @form.submit
179
+ end
180
+
181
+ When /^I search for an ordered list located in a section$/ do
182
+ @list = @page.container.section_ordered_list_element
183
+ end
184
+
185
+ Then /^the first section list items text should be "([^\"]*)"$/ do |value|
186
+ @list[0].text.should == value
187
+ end
188
+
189
+ When /^I search for an unordered list located in a section$/ do
190
+ @list = @page.container.section_unordered_list_element
191
+ end
192
+
193
+ When /^I search for a list item section in an ordered list in a section$/ do
194
+ @li = @page.container.section_list_item_element
195
+ end
196
+
197
+ Then /^I should see the section list items text should be "([^\"]*)"$/ do |value|
198
+ @li.text.should == value
199
+ end
200
+
201
+ When /^I search for a h(\d+) located in a section$/ do |num|
202
+ @header = @page.container.send "section_h#{num}_element"
203
+ end
204
+
205
+ Then /^I should see the section h(\d+)s text should be "([^\"]*)"$/ do |num, value|
206
+ @header.text.should == value
207
+ end
208
+
209
+ When /^I search for a paragraph located in a section$/ do
210
+ @para = @page.container.section_paragraph_element
211
+ end
212
+
213
+ Then /^I should see the section paragraphs text should be "([^\"]*)"$/ do |value|
214
+ @para.text.should == value
215
+ end
216
+
217
+ When /^I search for a file field located in a section$/ do
218
+ @ff = @page.container.section_file_field_element
219
+ end
220
+
221
+ Then /^I should be able to set the section file field$/ do
222
+ @ff.value = __FILE__
223
+ end
224
+
225
+ When(/^I access an element that is outside of the section$/) do
226
+ @element = @page.container.outside_section_element
227
+ end
228
+
229
+ Then(/^I should see that it doesn't exist in the section$/) do
230
+ expect(@element).not_to exist
231
+ end
232
+
233
+ When(/^I select multiple sections$/) do
234
+ @sections = @page.page_inputs
235
+ end
236
+
237
+ Then(/^I should have a section collection containing the sections$/) do
238
+ expect(@sections).to be_an_instance_of(PageObject::SectionCollection)
239
+ end
240
+
241
+ When(/^I search by a specific value of the section$/) do
242
+ @element = @sections.find_by(:value => 'LeanDog')
243
+ end
244
+
245
+ Then(/^I will find the first section with that value$/) do
246
+ expect(@element).to be_a(PageObject)
247
+ expect(@element.value).to eq 'LeanDog'
248
+ end
249
+
250
+ When(/^I filter by a specific value of the sections$/) do
251
+ @elements = @sections.select_by(:value => /\w+/)
252
+ end
253
+
254
+ Then(/^I will find all sections with that value$/) do
255
+ expect(@elements).to be_a PageObject::SectionCollection
256
+ @elements.map(&:value).each do |element|
257
+ expect(element).to match(/\w+/)
258
+ end
259
+ end
260
+
261
+ And(/^I can access any index of that collection of sections$/) do
262
+ expect(@sections[0]).to be_a(PageObject)
263
+ expect(@sections[-1]).to be_a(PageObject)
264
+ end
265
+
266
+ Given(/^I search for a link in an indexed property located in a section$/) do
267
+ @link = @page.container.indexed_list['success'].indexed_link_element
268
+ end