page-object 0.2.5 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +25 -0
- data/Rakefile +3 -3
- data/features/element.feature +232 -1
- data/features/frames.feature +1 -1
- data/features/html/modal.html +17 -0
- data/features/html/modal_1.html +38 -0
- data/features/html/modal_2.html +27 -0
- data/features/html/nested_elements.html +42 -0
- data/features/html/static_elements.html +1 -0
- data/features/modal_dialog.feature +15 -0
- data/features/nested_elements.feature +73 -0
- data/features/step_definitions/frames_steps.rb +1 -1
- data/features/step_definitions/modal_dialog_steps.rb +62 -0
- data/features/step_definitions/nested_elements_steps.rb +165 -0
- data/features/support/page.rb +1 -0
- data/features/support/url_helper.rb +8 -0
- data/lib/page-object.rb +26 -0
- data/lib/page-object/accessors.rb +36 -36
- data/lib/page-object/elements/button.rb +3 -3
- data/lib/page-object/elements/check_box.rb +7 -7
- data/lib/page-object/elements/element.rb +16 -10
- data/lib/page-object/elements/form.rb +7 -7
- data/lib/page-object/elements/image.rb +7 -7
- data/lib/page-object/elements/link.rb +3 -3
- data/lib/page-object/elements/ordered_list.rb +7 -7
- data/lib/page-object/elements/radio_button.rb +7 -7
- data/lib/page-object/elements/select_list.rb +7 -7
- data/lib/page-object/elements/table.rb +7 -7
- data/lib/page-object/elements/table_row.rb +7 -7
- data/lib/page-object/elements/text_area.rb +7 -7
- data/lib/page-object/elements/text_field.rb +7 -7
- data/lib/page-object/elements/unordered_list.rb +7 -7
- data/lib/page-object/nested_elements.rb +72 -0
- data/lib/page-object/platforms.rb +2 -2
- data/lib/page-object/platforms/selenium_webdriver.rb +17 -0
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/button.rb +1 -1
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/check_box.rb +1 -1
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/element.rb +1 -1
- data/lib/page-object/platforms/{watir → selenium_webdriver}/form.rb +1 -1
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/image.rb +1 -1
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/link.rb +1 -1
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/ordered_list.rb +2 -2
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/page_object.rb +59 -59
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/radio_button.rb +1 -1
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/select_list.rb +2 -2
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/table.rb +2 -2
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/table_row.rb +2 -2
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/text_area.rb +1 -1
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/text_field.rb +1 -1
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/unordered_list.rb +2 -2
- data/lib/page-object/platforms/watir_webdriver.rb +17 -0
- data/lib/page-object/platforms/{watir → watir_webdriver}/check_box.rb +1 -1
- data/lib/page-object/platforms/{watir → watir_webdriver}/element.rb +1 -1
- data/lib/page-object/platforms/{selenium → watir_webdriver}/form.rb +1 -1
- data/lib/page-object/platforms/{watir → watir_webdriver}/image.rb +1 -1
- data/lib/page-object/platforms/{watir → watir_webdriver}/ordered_list.rb +2 -2
- data/lib/page-object/platforms/watir_webdriver/page_object.rb +486 -0
- data/lib/page-object/platforms/{watir → watir_webdriver}/radio_button.rb +1 -1
- data/lib/page-object/platforms/{watir → watir_webdriver}/select_list.rb +3 -3
- data/lib/page-object/platforms/{watir → watir_webdriver}/table.rb +2 -2
- data/lib/page-object/platforms/{watir → watir_webdriver}/table_row.rb +2 -2
- data/lib/page-object/platforms/{watir → watir_webdriver}/text_area.rb +1 -1
- data/lib/page-object/platforms/{watir → watir_webdriver}/text_field.rb +1 -1
- data/lib/page-object/platforms/{watir → watir_webdriver}/unordered_list.rb +2 -2
- data/lib/page-object/version.rb +1 -1
- data/page-object.gemspec +1 -1
- data/spec/page-object/elements/button_spec.rb +1 -1
- data/spec/page-object/elements/check_box_spec.rb +1 -1
- data/spec/page-object/elements/element_spec.rb +9 -5
- data/spec/page-object/elements/form_spec.rb +2 -2
- data/spec/page-object/elements/image_spec.rb +4 -4
- data/spec/page-object/elements/link_spec.rb +1 -1
- data/spec/page-object/elements/nested_element_spec.rb +185 -0
- data/spec/page-object/elements/ordered_list_spec.rb +6 -6
- data/spec/page-object/elements/radio_button_spec.rb +1 -1
- data/spec/page-object/elements/select_list_spec.rb +5 -5
- data/spec/page-object/elements/table_row_spec.rb +6 -6
- data/spec/page-object/elements/table_spec.rb +2 -2
- data/spec/page-object/elements/text_area_spec.rb +1 -1
- data/spec/page-object/elements/text_field_spec.rb +1 -1
- data/spec/page-object/elements/unordered_list_spec.rb +6 -6
- data/spec/page-object/page-object_spec.rb +12 -2
- data/spec/page-object/platforms/{selenium → selenium_webdriver}/selenium_page_object_spec.rb +2 -2
- data/spec/page-object/platforms/selenium_webdriver_spec.rb +29 -0
- data/spec/page-object/platforms/{watir_spec.rb → watir_webdriver_spec.rb} +11 -6
- metadata +58 -39
- data/lib/page-object/platforms/selenium.rb +0 -16
- data/lib/page-object/platforms/watir.rb +0 -16
- data/lib/page-object/platforms/watir/page_object.rb +0 -482
- data/spec/page-object/platforms/selenium_spec.rb +0 -26
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Feature: Attributes on Elements
|
|
2
|
+
|
|
3
|
+
Background:
|
|
4
|
+
Given I am on the nested elements page
|
|
5
|
+
|
|
6
|
+
Scenario: Finding a link within a div
|
|
7
|
+
When I search for a link located in a div
|
|
8
|
+
Then I should be able to click the nested link
|
|
9
|
+
|
|
10
|
+
Scenario: Finding a button within a div
|
|
11
|
+
When I search for a button located in a div
|
|
12
|
+
Then I should be able to click the nested button
|
|
13
|
+
|
|
14
|
+
Scenario: Finding a text field within a div
|
|
15
|
+
When I search for a text field located in a div
|
|
16
|
+
Then I should be able to type "123abc" in the nested text field
|
|
17
|
+
|
|
18
|
+
Scenario: Finding a hidden field within a div
|
|
19
|
+
When I search for a hidden field located in a div
|
|
20
|
+
Then I should be able to see that the nested hidden field contains "LeanDog"
|
|
21
|
+
|
|
22
|
+
Scenario: Finding a text area within a div
|
|
23
|
+
When I search for a text area located in a div
|
|
24
|
+
Then I should be able to type "abcdefg" in the nested text area
|
|
25
|
+
|
|
26
|
+
Scenario: Finding a select list within a div
|
|
27
|
+
When I search for a select list located in a div
|
|
28
|
+
Then I should be able to select "Test 2" in the nested select list
|
|
29
|
+
|
|
30
|
+
Scenario: Finding a checkbox within a div
|
|
31
|
+
When I search for a checkbox located in a div
|
|
32
|
+
Then I should be able to check the nested checkbox
|
|
33
|
+
|
|
34
|
+
Scenario: Finding a radio button witin a div
|
|
35
|
+
When I search for a radio button located in a div
|
|
36
|
+
Then I should be able to select the nested radio button
|
|
37
|
+
|
|
38
|
+
Scenario: Finding a div within a div
|
|
39
|
+
When I search for a div located in a div
|
|
40
|
+
Then I should see the text "page-object rocks!" in the nested div
|
|
41
|
+
|
|
42
|
+
Scenario: Finding a span within a div
|
|
43
|
+
When I search for a span located in a div
|
|
44
|
+
Then I should see the text "My alert" in the nested span
|
|
45
|
+
|
|
46
|
+
Scenario: Finding a table within a div
|
|
47
|
+
When I search for a table located in a div
|
|
48
|
+
Then the data for row "1" of the nested table should be "Data1" and "Data2"
|
|
49
|
+
|
|
50
|
+
Scenario: Finding a table cell within a div
|
|
51
|
+
When I search the second table cell located in a table in a div
|
|
52
|
+
Then the nested table cell should contain "Data2"
|
|
53
|
+
|
|
54
|
+
Scenario: Finding an image within a div
|
|
55
|
+
When I search for an image located in a div
|
|
56
|
+
Then the nested image should be "106" pixels wide
|
|
57
|
+
And the nested image should be "106" pixels tall
|
|
58
|
+
|
|
59
|
+
Scenario: Finding a form within a div
|
|
60
|
+
When I search for a form located in a div
|
|
61
|
+
Then I should be able to submit the nested form
|
|
62
|
+
|
|
63
|
+
Scenario: Finding an ordered list within a div
|
|
64
|
+
When I search for an ordered list located in a div
|
|
65
|
+
Then the first nested list items text should be "Number One"
|
|
66
|
+
|
|
67
|
+
Scenario: Finding an unordered list within a div
|
|
68
|
+
When I search for an unordered list located in a div
|
|
69
|
+
Then the first nested list items text should be "Item One"
|
|
70
|
+
|
|
71
|
+
Scenario: Finding a list item nested in an ordered list within a div
|
|
72
|
+
When I search for a list item nested in an ordered list in a div
|
|
73
|
+
Then I should see the nested list items text should be "Number One"
|
|
@@ -66,7 +66,7 @@ Given /^I am on the nested frame elements page$/ do
|
|
|
66
66
|
@page.navigate_to(UrlHelper.nested_frame_elements)
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
Then /^I should be able to click the
|
|
69
|
+
Then /^I should be able to click the link in the frame$/ do
|
|
70
70
|
@page.nested_link
|
|
71
71
|
@page.text.should include "Success"
|
|
72
72
|
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
class ModalPage
|
|
2
|
+
include PageObject
|
|
3
|
+
|
|
4
|
+
button(:launch_modal, :id => 'launch_modal_button')
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
class ModalDialog
|
|
8
|
+
include PageObject
|
|
9
|
+
|
|
10
|
+
button(:close_window, :id => 'close_window')
|
|
11
|
+
button(:close_window_with_delay, :id => 'delayed_close')
|
|
12
|
+
button(:launch_another_modal, :id => 'launch_modal_button')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class AnotherModalDialog
|
|
16
|
+
include PageObject
|
|
17
|
+
|
|
18
|
+
button(:close_window, :id => 'close_window2')
|
|
19
|
+
button(:close_window_with_delay, :id => 'delayed_close2')
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
Given /^I am on the modal page$/ do
|
|
24
|
+
ModalPage.new(@browser).navigate_to(UrlHelper.modal)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
When /^I open a modal dialog$/ do
|
|
28
|
+
page = ModalPage.new(@browser)
|
|
29
|
+
page.modal_dialog do
|
|
30
|
+
page.launch_modal
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
Then /^I should be able to close the modal$/ do
|
|
35
|
+
dialog = ModalDialog.new(@browser)
|
|
36
|
+
dialog.attach_to_window(:title => 'Modal 1') do
|
|
37
|
+
dialog.close_window
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
When /^I open another modal dialog from that one$/ do
|
|
42
|
+
dialog = ModalDialog.new(@browser)
|
|
43
|
+
dialog.attach_to_window(:title => 'Modal 1') #do
|
|
44
|
+
dialog.modal_dialog #do
|
|
45
|
+
# dialog.launch_another_modal
|
|
46
|
+
# end
|
|
47
|
+
dialog.launch_another_modal
|
|
48
|
+
# end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
Then /^I should be able to close both modals$/ do
|
|
52
|
+
pending
|
|
53
|
+
# another = AnotherModalDialog.new(@browser)
|
|
54
|
+
# another.attach_to_window(:title => 'Modal 2') do
|
|
55
|
+
# another.close_window
|
|
56
|
+
# end
|
|
57
|
+
|
|
58
|
+
# dialog = ModalDialog.new(@browser)
|
|
59
|
+
# dialog.attach_to_window(:title => 'Modal 1') do
|
|
60
|
+
# dialog.close_window
|
|
61
|
+
# end
|
|
62
|
+
end
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
class NestedElementsPage
|
|
2
|
+
include PageObject
|
|
3
|
+
|
|
4
|
+
div(:outer_div, :id => 'div_id')
|
|
5
|
+
link(:nested_link) { |page| page.outer_div_element.link_element }
|
|
6
|
+
button(:nested_button) { |page| page.outer_div_element.button_element }
|
|
7
|
+
text_field(:nested_text_field) { |page| page.outer_div_element.text_field_element }
|
|
8
|
+
hidden_field(:nested_hidden_field) { |page| page.outer_div_element.hidden_field_element }
|
|
9
|
+
text_area(:nested_text_area) { |page| page.outer_div_element.text_area_element }
|
|
10
|
+
select_list(:nested_select_list) { |page| page.outer_div_element.select_list_element }
|
|
11
|
+
checkbox(:nested_checkbox) { |page| page.outer_div_element.checkbox_element }
|
|
12
|
+
radio_button(:nested_radio_button) { |page| page.outer_div_element.radio_button_element }
|
|
13
|
+
div(:nested_div) { |page| page.outer_div_element.div_element }
|
|
14
|
+
span(:nested_span) { |page| page.outer_div_element.span_element }
|
|
15
|
+
table(:nested_table) { |page| page.outer_div_element.table_element }
|
|
16
|
+
cell(:nested_cell) { |page| page.nested_table_element.cell_element(:index => 1) }
|
|
17
|
+
image(:nested_image) { |page| page.outer_div_element.image_element }
|
|
18
|
+
form(:nested_form) { |page| page.outer_div_element.form_element }
|
|
19
|
+
ordered_list(:nested_ordered_list) { |page| page.outer_div_element.ordered_list_element }
|
|
20
|
+
unordered_list(:nested_unordered_list) { |page| page.outer_div_element.unordered_list_element }
|
|
21
|
+
list_item(:nested_list_item) { |page| page.nested_ordered_list_element.list_item_element }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
Given /^I am on the nested elements page$/ do
|
|
25
|
+
@page = NestedElementsPage.new(@browser)
|
|
26
|
+
@page.navigate_to(UrlHelper.nested_elements)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
When /^I search for a link located in a div$/ do
|
|
30
|
+
@link = @page.nested_link_element
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
Then /^I should be able to click the nested link$/ do
|
|
34
|
+
@link.click
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
When /^I search for a button located in a div$/ do
|
|
38
|
+
@button = @page.nested_button_element
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
Then /^I should be able to click the nested button$/ do
|
|
42
|
+
@button.click
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
When /^I search for a text field located in a div$/ do
|
|
46
|
+
@text_field = @page.nested_text_field_element
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
Then /^I should be able to type "([^\"]*)" in the nested text field$/ do |value|
|
|
50
|
+
@text_field.value = value
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
When /^I search for a hidden field located in a div$/ do
|
|
54
|
+
@hidden_field = @page.nested_hidden_field_element
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
Then /^I should be able to see that the nested hidden field contains "([^\"]*)"$/ do |value|
|
|
58
|
+
@hidden_field.value.should == value
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
When /^I search for a text area located in a div$/ do
|
|
62
|
+
@text_area = @page.nested_text_area_element
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
Then /^I should be able to type "([^\"]*)" in the nested text area$/ do |value|
|
|
66
|
+
@text_area.value = value
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
When /^I search for a select list located in a div$/ do
|
|
70
|
+
@select_list = @page.nested_select_list_element
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
Then /^I should be able to select "([^\"]*)" in the nested select list$/ do |value|
|
|
74
|
+
@select_list.select value
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
When /^I search for a checkbox located in a div$/ do
|
|
78
|
+
@checkbox = @page.nested_checkbox_element
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
Then /^I should be able to check the nested checkbox$/ do
|
|
82
|
+
@checkbox.check
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
When /^I search for a radio button located in a div$/ do
|
|
86
|
+
@radio = @page.nested_radio_button_element
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
Then /^I should be able to select the nested radio button$/ do
|
|
90
|
+
@radio.select
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
When /^I search for a div located in a div$/ do
|
|
94
|
+
@div = @page.nested_div_element
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
Then /^I should see the text "([^\"]*)" in the nested div$/ do |value|
|
|
98
|
+
@div.text.should == value
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
When /^I search for a span located in a div$/ do
|
|
102
|
+
@span = @page.nested_span_element
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
Then /^I should see the text "([^\"]*)" in the nested span$/ do |value|
|
|
106
|
+
@span.text.should == value
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
When /^I search for a table located in a div$/ do
|
|
110
|
+
@table = @page.nested_table_element
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
Then /^the data for row "([^\"]*)" of the nested table should be "([^\"]*)" and "([^\"]*)"$/ do |row, col1, col2|
|
|
114
|
+
table_row = @table[row.to_i - 1]
|
|
115
|
+
table_row[0].text.should == col1
|
|
116
|
+
table_row[1].text.should == col2
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
When /^I search the second table cell located in a table in a div$/ do
|
|
120
|
+
@cell = @page.nested_cell_element
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
Then /^the nested table cell should contain "([^"]*)"$/ do |value|
|
|
124
|
+
@cell.text.should == value
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
When /^I search for an image located in a div$/ do
|
|
128
|
+
@image = @page.nested_image_element
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
Then /^the nested image should be "([^"]*)" pixels wide$/ do |width|
|
|
132
|
+
@image.width.should == width.to_i
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
Then /^the nested image should be "([^"]*)" pixels tall$/ do |height|
|
|
136
|
+
@image.height.should == height.to_i
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
When /^I search for a form located in a div$/ do
|
|
140
|
+
@form = @page.nested_form_element
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
Then /^I should be able to submit the nested form$/ do
|
|
144
|
+
@form.submit
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
When /^I search for an ordered list located in a div$/ do
|
|
148
|
+
@list = @page.nested_ordered_list_element
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
Then /^the first nested list items text should be "([^"]*)"$/ do |value|
|
|
152
|
+
@list[0].text.should == value
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
When /^I search for an unordered list located in a div$/ do
|
|
156
|
+
@list = @page.nested_unordered_list_element
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
When /^I search for a list item nested in an ordered list in a div$/ do
|
|
160
|
+
@li = @page.nested_list_item_element
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
Then /^I should see the nested list items text should be "([^"]*)"$/ do |value|
|
|
164
|
+
@li.text.should == value
|
|
165
|
+
end
|
data/features/support/page.rb
CHANGED
data/lib/page-object.rb
CHANGED
|
@@ -2,6 +2,7 @@ require 'page-object/version'
|
|
|
2
2
|
require 'page-object/accessors'
|
|
3
3
|
require 'page-object/platforms'
|
|
4
4
|
require 'page-object/element_locators'
|
|
5
|
+
require 'page-object/nested_elements'
|
|
5
6
|
|
|
6
7
|
#
|
|
7
8
|
# Module that when included adds functionality to a page object. This module
|
|
@@ -153,6 +154,31 @@ module PageObject
|
|
|
153
154
|
platform.prompt(answer, &block)
|
|
154
155
|
end
|
|
155
156
|
|
|
157
|
+
#
|
|
158
|
+
# Override the normal showModalDialog call is it opens a window instead
|
|
159
|
+
# of a dialog. You will need to attach to the new window in order to
|
|
160
|
+
# continue.
|
|
161
|
+
#
|
|
162
|
+
# @example
|
|
163
|
+
# @page.modal_dialog do
|
|
164
|
+
# @page.action_that_spawns_the_modal
|
|
165
|
+
# end
|
|
166
|
+
#
|
|
167
|
+
# @param block a block that contains the call that will cause the modal dialog.
|
|
168
|
+
#
|
|
169
|
+
def modal_dialog(&block)
|
|
170
|
+
script =
|
|
171
|
+
%Q{
|
|
172
|
+
window.showModalDialog = function(sURL, vArguments, sFeatures) {
|
|
173
|
+
window.dialogArguments = vArguments;
|
|
174
|
+
modalWin = window.open(sURL, 'modal', sFeatures);
|
|
175
|
+
return modalWin;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
browser.execute_script script
|
|
179
|
+
yield if block_given?
|
|
180
|
+
end
|
|
181
|
+
|
|
156
182
|
#
|
|
157
183
|
# Attach to a running window. You can locate the window using either
|
|
158
184
|
# the window's title or url. If it failes to connect to a window it will
|
|
@@ -69,15 +69,15 @@ module PageObject
|
|
|
69
69
|
#
|
|
70
70
|
def text_field(name, identifier=nil, &block)
|
|
71
71
|
define_method(name) do
|
|
72
|
-
return platform.text_field_value_for identifier.clone unless
|
|
72
|
+
return platform.text_field_value_for identifier.clone unless block_given?
|
|
73
73
|
self.send("#{name}_element").value
|
|
74
74
|
end
|
|
75
75
|
define_method("#{name}=") do |value|
|
|
76
|
-
return platform.text_field_value_set(identifier.clone, value) unless
|
|
76
|
+
return platform.text_field_value_set(identifier.clone, value) unless block_given?
|
|
77
77
|
self.send("#{name}_element").value = value
|
|
78
78
|
end
|
|
79
79
|
define_method("#{name}_element") do
|
|
80
|
-
return call_block(&block) if
|
|
80
|
+
return call_block(&block) if block_given?
|
|
81
81
|
platform.text_field_for(identifier.clone)
|
|
82
82
|
end
|
|
83
83
|
alias_method "#{name}_text_field".to_sym, "#{name}_element".to_sym
|
|
@@ -106,11 +106,11 @@ module PageObject
|
|
|
106
106
|
#
|
|
107
107
|
def hidden_field(name, identifier=nil, &block)
|
|
108
108
|
define_method(name) do
|
|
109
|
-
return platform.hidden_field_value_for identifier.clone unless
|
|
109
|
+
return platform.hidden_field_value_for identifier.clone unless block_given?
|
|
110
110
|
self.send("#{name}_element").value
|
|
111
111
|
end
|
|
112
112
|
define_method("#{name}_element") do
|
|
113
|
-
return call_block(&block) if
|
|
113
|
+
return call_block(&block) if block_given?
|
|
114
114
|
platform.hidden_field_for(identifier.clone)
|
|
115
115
|
end
|
|
116
116
|
alias_method "#{name}_hidden_field".to_sym, "#{name}_element".to_sym
|
|
@@ -139,15 +139,15 @@ module PageObject
|
|
|
139
139
|
#
|
|
140
140
|
def text_area(name, identifier=nil, &block)
|
|
141
141
|
define_method(name) do
|
|
142
|
-
return platform.text_area_value_for identifier.clone unless
|
|
142
|
+
return platform.text_area_value_for identifier.clone unless block_given?
|
|
143
143
|
self.send("#{name}_element").value
|
|
144
144
|
end
|
|
145
145
|
define_method("#{name}=") do |value|
|
|
146
|
-
return platform.text_area_value_set(identifier.clone, value) unless
|
|
146
|
+
return platform.text_area_value_set(identifier.clone, value) unless block_given?
|
|
147
147
|
self.send("#{name}_element").value = value
|
|
148
148
|
end
|
|
149
149
|
define_method("#{name}_element") do
|
|
150
|
-
return call_block(&block) if
|
|
150
|
+
return call_block(&block) if block_given?
|
|
151
151
|
platform.text_area_for(identifier.clone)
|
|
152
152
|
end
|
|
153
153
|
alias_method "#{name}_text_area".to_sym, "#{name}_element".to_sym
|
|
@@ -176,15 +176,15 @@ module PageObject
|
|
|
176
176
|
#
|
|
177
177
|
def select_list(name, identifier=nil, &block)
|
|
178
178
|
define_method(name) do
|
|
179
|
-
return platform.select_list_value_for identifier.clone unless
|
|
179
|
+
return platform.select_list_value_for identifier.clone unless block_given?
|
|
180
180
|
self.send("#{name}_element").value
|
|
181
181
|
end
|
|
182
182
|
define_method("#{name}=") do |value|
|
|
183
|
-
return platform.select_list_value_set(identifier.clone, value) unless
|
|
183
|
+
return platform.select_list_value_set(identifier.clone, value) unless block_given?
|
|
184
184
|
self.send("#{name}_element").select(value)
|
|
185
185
|
end
|
|
186
186
|
define_method("#{name}_element") do
|
|
187
|
-
return call_block(&block) if
|
|
187
|
+
return call_block(&block) if block_given?
|
|
188
188
|
platform.select_list_for(identifier.clone)
|
|
189
189
|
end
|
|
190
190
|
alias_method "#{name}_select_list".to_sym, "#{name}_element".to_sym
|
|
@@ -215,11 +215,11 @@ module PageObject
|
|
|
215
215
|
#
|
|
216
216
|
def link(name, identifier=nil, &block)
|
|
217
217
|
define_method(name) do
|
|
218
|
-
return platform.click_link_for identifier.clone unless
|
|
218
|
+
return platform.click_link_for identifier.clone unless block_given?
|
|
219
219
|
self.send("#{name}_element").click
|
|
220
220
|
end
|
|
221
221
|
define_method("#{name}_element") do
|
|
222
|
-
return call_block(&block) if
|
|
222
|
+
return call_block(&block) if block_given?
|
|
223
223
|
platform.link_for(identifier.clone)
|
|
224
224
|
end
|
|
225
225
|
alias_method "#{name}_link".to_sym, "#{name}_element".to_sym
|
|
@@ -246,19 +246,19 @@ module PageObject
|
|
|
246
246
|
#
|
|
247
247
|
def checkbox(name, identifier=nil, &block)
|
|
248
248
|
define_method("check_#{name}") do
|
|
249
|
-
return platform.check_checkbox(identifier.clone) unless
|
|
249
|
+
return platform.check_checkbox(identifier.clone) unless block_given?
|
|
250
250
|
self.send("#{name}_element").check
|
|
251
251
|
end
|
|
252
252
|
define_method("uncheck_#{name}") do
|
|
253
|
-
return platform.uncheck_checkbox(identifier.clone) unless
|
|
253
|
+
return platform.uncheck_checkbox(identifier.clone) unless block_given?
|
|
254
254
|
self.send("#{name}_element").uncheck
|
|
255
255
|
end
|
|
256
256
|
define_method("#{name}_checked?") do
|
|
257
|
-
return platform.checkbox_checked?(identifier.clone) unless
|
|
257
|
+
return platform.checkbox_checked?(identifier.clone) unless block_given?
|
|
258
258
|
self.send("#{name}_element").checked?
|
|
259
259
|
end
|
|
260
260
|
define_method("#{name}_element") do
|
|
261
|
-
return call_block(&block) if
|
|
261
|
+
return call_block(&block) if block_given?
|
|
262
262
|
platform.checkbox_for(identifier.clone)
|
|
263
263
|
end
|
|
264
264
|
alias_method "#{name}_checkbox".to_sym, "#{name}_element".to_sym
|
|
@@ -286,19 +286,19 @@ module PageObject
|
|
|
286
286
|
#
|
|
287
287
|
def radio_button(name, identifier=nil, &block)
|
|
288
288
|
define_method("select_#{name}") do
|
|
289
|
-
return platform.select_radio(identifier.clone) unless
|
|
289
|
+
return platform.select_radio(identifier.clone) unless block_given?
|
|
290
290
|
self.send("#{name}_element").select
|
|
291
291
|
end
|
|
292
292
|
define_method("clear_#{name}") do
|
|
293
|
-
return platform.clear_radio(identifier.clone) unless
|
|
293
|
+
return platform.clear_radio(identifier.clone) unless block_given?
|
|
294
294
|
self.send("#{name}_element").clear
|
|
295
295
|
end
|
|
296
296
|
define_method("#{name}_selected?") do
|
|
297
|
-
return platform.radio_selected?(identifier.clone) unless
|
|
297
|
+
return platform.radio_selected?(identifier.clone) unless block_given?
|
|
298
298
|
self.send("#{name}_element").selected?
|
|
299
299
|
end
|
|
300
300
|
define_method("#{name}_element") do
|
|
301
|
-
return call_block(&block) if
|
|
301
|
+
return call_block(&block) if block_given?
|
|
302
302
|
platform.radio_button_for(identifier.clone)
|
|
303
303
|
end
|
|
304
304
|
alias_method "#{name}_radio_button".to_sym, "#{name}_element".to_sym
|
|
@@ -326,11 +326,11 @@ module PageObject
|
|
|
326
326
|
#
|
|
327
327
|
def button(name, identifier=nil, &block)
|
|
328
328
|
define_method(name) do
|
|
329
|
-
return platform.click_button_for identifier.clone unless
|
|
329
|
+
return platform.click_button_for identifier.clone unless block_given?
|
|
330
330
|
self.send("#{name}_element").click
|
|
331
331
|
end
|
|
332
332
|
define_method("#{name}_element") do
|
|
333
|
-
return call_block(&block) if
|
|
333
|
+
return call_block(&block) if block_given?
|
|
334
334
|
platform.button_for(identifier.clone)
|
|
335
335
|
end
|
|
336
336
|
alias_method "#{name}_button".to_sym, "#{name}_element".to_sym
|
|
@@ -357,11 +357,11 @@ module PageObject
|
|
|
357
357
|
#
|
|
358
358
|
def div(name, identifier=nil, &block)
|
|
359
359
|
define_method(name) do
|
|
360
|
-
return platform.div_text_for identifier.clone unless
|
|
360
|
+
return platform.div_text_for identifier.clone unless block_given?
|
|
361
361
|
self.send("#{name}_element").text
|
|
362
362
|
end
|
|
363
363
|
define_method("#{name}_element") do
|
|
364
|
-
return call_block(&block) if
|
|
364
|
+
return call_block(&block) if block_given?
|
|
365
365
|
platform.div_for(identifier.clone)
|
|
366
366
|
end
|
|
367
367
|
alias_method "#{name}_div".to_sym, "#{name}_element".to_sym
|
|
@@ -387,11 +387,11 @@ module PageObject
|
|
|
387
387
|
#
|
|
388
388
|
def span(name, identifier=nil, &block)
|
|
389
389
|
define_method(name) do
|
|
390
|
-
return platform.span_text_for identifier.clone unless
|
|
390
|
+
return platform.span_text_for identifier.clone unless block_given?
|
|
391
391
|
self.send("#{name}_element").text
|
|
392
392
|
end
|
|
393
393
|
define_method("#{name}_element") do
|
|
394
|
-
return call_block(&block) if
|
|
394
|
+
return call_block(&block) if block_given?
|
|
395
395
|
platform.span_for(identifier.clone)
|
|
396
396
|
end
|
|
397
397
|
alias_method "#{name}_span".to_sym, "#{name}_element".to_sym
|
|
@@ -416,7 +416,7 @@ module PageObject
|
|
|
416
416
|
#
|
|
417
417
|
def table(name, identifier=nil, &block)
|
|
418
418
|
define_method("#{name}_element") do
|
|
419
|
-
return call_block(&block) if
|
|
419
|
+
return call_block(&block) if block_given?
|
|
420
420
|
platform.table_for(identifier.clone)
|
|
421
421
|
end
|
|
422
422
|
alias_method "#{name}_table".to_sym, "#{name}_element".to_sym
|
|
@@ -443,11 +443,11 @@ module PageObject
|
|
|
443
443
|
#
|
|
444
444
|
def cell(name, identifier=nil, &block)
|
|
445
445
|
define_method("#{name}") do
|
|
446
|
-
return platform.cell_text_for identifier.clone unless
|
|
446
|
+
return platform.cell_text_for identifier.clone unless block_given?
|
|
447
447
|
self.send("#{name}_element").text
|
|
448
448
|
end
|
|
449
449
|
define_method("#{name}_element") do
|
|
450
|
-
return call_block(&block) if
|
|
450
|
+
return call_block(&block) if block_given?
|
|
451
451
|
platform.cell_for(identifier.clone)
|
|
452
452
|
end
|
|
453
453
|
alias_method "#{name}_cell".to_sym, "#{name}_element".to_sym
|
|
@@ -472,7 +472,7 @@ module PageObject
|
|
|
472
472
|
#
|
|
473
473
|
def image(name, identifier=nil, &block)
|
|
474
474
|
define_method("#{name}_element") do
|
|
475
|
-
return call_block(&block) if
|
|
475
|
+
return call_block(&block) if block_given?
|
|
476
476
|
platform.image_for(identifier.clone)
|
|
477
477
|
end
|
|
478
478
|
alias_method "#{name}_image".to_sym, "#{name}_element".to_sym
|
|
@@ -496,7 +496,7 @@ module PageObject
|
|
|
496
496
|
#
|
|
497
497
|
def form(name, identifier=nil, &block)
|
|
498
498
|
define_method("#{name}_element") do
|
|
499
|
-
return call_block(&block) if
|
|
499
|
+
return call_block(&block) if block_given?
|
|
500
500
|
platform.form_for(identifier.clone)
|
|
501
501
|
end
|
|
502
502
|
alias_method "#{name}_form".to_sym, "#{name}_element".to_sym
|
|
@@ -522,11 +522,11 @@ module PageObject
|
|
|
522
522
|
#
|
|
523
523
|
def list_item(name, identifier=nil, &block)
|
|
524
524
|
define_method(name) do
|
|
525
|
-
return platform.list_item_text_for identifier.clone unless
|
|
525
|
+
return platform.list_item_text_for identifier.clone unless block_given?
|
|
526
526
|
self.send("#{name}_element").text
|
|
527
527
|
end
|
|
528
528
|
define_method("#{name}_element") do
|
|
529
|
-
return call_block(&block) if
|
|
529
|
+
return call_block(&block) if block_given?
|
|
530
530
|
platform.list_item_for(identifier.clone)
|
|
531
531
|
end
|
|
532
532
|
alias_method "#{name}_list_item".to_sym, "#{name}_element".to_sym
|
|
@@ -551,7 +551,7 @@ module PageObject
|
|
|
551
551
|
#
|
|
552
552
|
def unordered_list(name, identifier=nil, &block)
|
|
553
553
|
define_method("#{name}_element") do
|
|
554
|
-
return call_block(&block) if
|
|
554
|
+
return call_block(&block) if block_given?
|
|
555
555
|
platform.unordered_list_for(identifier.clone)
|
|
556
556
|
end
|
|
557
557
|
alias_method "#{name}_unordered_list".to_sym, "#{name}_element".to_sym
|
|
@@ -576,7 +576,7 @@ module PageObject
|
|
|
576
576
|
#
|
|
577
577
|
def ordered_list(name, identifier=nil, &block)
|
|
578
578
|
define_method("#{name}_element") do
|
|
579
|
-
return call_block(&block) if
|
|
579
|
+
return call_block(&block) if block_given?
|
|
580
580
|
platform.ordered_list_for(identifier.clone)
|
|
581
581
|
end
|
|
582
582
|
alias_method "#{name}_ordered_list".to_sym, "#{name}_element".to_sym
|