druid-s 1.0.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.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/.travis.yml +27 -0
- data/ChangeLog +541 -0
- data/Gemfile +8 -0
- data/README.md +78 -0
- data/Rakefile +33 -0
- data/cucumber.yml +6 -0
- data/druid.gemspec +30 -0
- data/features/area.feature +33 -0
- data/features/async.feature +16 -0
- data/features/audio.feature +61 -0
- data/features/bold.feature +20 -0
- data/features/button.feature +81 -0
- data/features/canvas.feature +34 -0
- data/features/checkbox.feature +48 -0
- data/features/div.feature +45 -0
- data/features/element.feature +281 -0
- data/features/file_field.feature +38 -0
- data/features/form.feature +37 -0
- data/features/frames.feature +76 -0
- data/features/generic_elements.feature +29 -0
- data/features/heading.feature +160 -0
- data/features/hidden_field.feature +39 -0
- data/features/html/async.html +31 -0
- data/features/html/frame_1.html +18 -0
- data/features/html/frame_2.html +16 -0
- data/features/html/frame_3.html +14 -0
- data/features/html/frames.html +12 -0
- data/features/html/hover.html +11 -0
- data/features/html/iframes.html +12 -0
- data/features/html/images/circle.png +0 -0
- data/features/html/images/img_pulpit.jpg +0 -0
- 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/multi_elements.html +145 -0
- data/features/html/nested_elements.html +75 -0
- data/features/html/nested_frame_1.html +1 -0
- data/features/html/nested_frame_2.html +11 -0
- data/features/html/nested_frame_3.html +14 -0
- data/features/html/nested_frames.html +10 -0
- data/features/html/planets.gif +0 -0
- data/features/html/static_elements.html +203 -0
- data/features/html/success.html +8 -0
- data/features/html/sun.gif +0 -0
- data/features/html/sun.html +7 -0
- data/features/image.feature +47 -0
- data/features/italic.feature +20 -0
- data/features/javascript.feature +28 -0
- data/features/label.feature +43 -0
- data/features/link.feature +56 -0
- data/features/list_item.feature +37 -0
- data/features/modal_dialog.feature +9 -0
- data/features/multi_elements.feature +498 -0
- data/features/nested_elements.feature +121 -0
- data/features/ordered_list.feature +46 -0
- data/features/page_level_actions.feature +116 -0
- data/features/paragraph.feature +33 -0
- data/features/populate_page_with.feature +25 -0
- data/features/radio_button.feature +51 -0
- data/features/radio_button_group.feature +28 -0
- data/features/sample-app/public/04-Death_Becomes_Fur.mp4 +0 -0
- data/features/sample-app/public/04-Death_Becomes_Fur.oga +0 -0
- data/features/sample-app/public/audio_video.html +19 -0
- data/features/sample-app/public/jquery-1.3.2.js +4376 -0
- data/features/sample-app/public/jquery.html +28 -0
- data/features/sample-app/public/movie.mp4 +0 -0
- data/features/sample-app/public/movie.ogg +0 -0
- data/features/sample-app/public/prototype-1.6.0.3.js +4320 -0
- data/features/sample-app/public/prototype.html +32 -0
- data/features/sample-app/sample_app.rb +35 -0
- data/features/section.feature +132 -0
- data/features/select_list.feature +84 -0
- data/features/span.feature +43 -0
- data/features/step_definations/area_steps.rb +23 -0
- data/features/step_definations/async_steps.rb +80 -0
- data/features/step_definations/audio_steps.rb +47 -0
- data/features/step_definations/bold_steps.rb +11 -0
- data/features/step_definations/button_steps.rb +52 -0
- data/features/step_definations/canvas_steps.rb +19 -0
- data/features/step_definations/checkbox_steps.rb +39 -0
- data/features/step_definations/div_steps.rb +28 -0
- data/features/step_definations/element_steps.rb +217 -0
- data/features/step_definations/file_field_steps.rb +31 -0
- data/features/step_definations/form_steps.rb +23 -0
- data/features/step_definations/frame_steps.rb +189 -0
- data/features/step_definations/generic_element_steps.rb +31 -0
- data/features/step_definations/heading_steps.rb +39 -0
- data/features/step_definations/hidden_field_steps.rb +27 -0
- data/features/step_definations/image_steps.rb +35 -0
- data/features/step_definations/italic_steps.rb +11 -0
- data/features/step_definations/javasript_steps.rb +52 -0
- data/features/step_definations/label_steps.rb +19 -0
- data/features/step_definations/link_steps.rb +42 -0
- data/features/step_definations/list_item_steps.rb +24 -0
- data/features/step_definations/modal_dialog_steps.rb +38 -0
- data/features/step_definations/multi_elements_steps.rb +557 -0
- data/features/step_definations/nested_elements_steps.rb +219 -0
- data/features/step_definations/ordered_list_steps.rb +49 -0
- data/features/step_definations/page_level_actions_steps.rb +172 -0
- data/features/step_definations/page_traversal_steps.rb +4 -0
- data/features/step_definations/paragraph_steps.rb +19 -0
- data/features/step_definations/populate_page_with_steps.rb +3 -0
- data/features/step_definations/radio_button_group_steps.rb +32 -0
- data/features/step_definations/radio_button_steps.rb +31 -0
- data/features/step_definations/section_steps.rb +271 -0
- data/features/step_definations/select_list_steps.rb +91 -0
- data/features/step_definations/span_steps.rb +23 -0
- data/features/step_definations/table_cell_steps.rb +27 -0
- data/features/step_definations/table_row_steps.rb +23 -0
- data/features/step_definations/table_steps.rb +109 -0
- data/features/step_definations/text_area_steps.rb +39 -0
- data/features/step_definations/text_field_steps.rb +39 -0
- data/features/step_definations/unordered_list_steps.rb +27 -0
- data/features/step_definations/video_steps.rb +27 -0
- data/features/support/ajax_test_environment.rb +26 -0
- data/features/support/audio_video_page.rb +23 -0
- data/features/support/env.rb +5 -0
- data/features/support/hooks.rb +3 -0
- data/features/support/page.rb +372 -0
- data/features/support/persistent_browser.rb +58 -0
- data/features/support/targets/firefox14_osx.rb +5 -0
- data/features/support/targets/firefox14_windows7.rb +5 -0
- data/features/support/url_helper.rb +50 -0
- data/features/table.feature +127 -0
- data/features/table_cell.feature +42 -0
- data/features/table_row.feature +30 -0
- data/features/text_area.feature +44 -0
- data/features/text_field.feature +53 -0
- data/features/unordered_list.feature +46 -0
- data/features/video.feature +66 -0
- data/lib/druid/accessors.rb +1082 -0
- data/lib/druid/assist.rb +653 -0
- data/lib/druid/element_locators.rb +21 -0
- data/lib/druid/elements/area.rb +9 -0
- data/lib/druid/elements/audio.rb +9 -0
- data/lib/druid/elements/bold.rb +8 -0
- data/lib/druid/elements/button.rb +12 -0
- data/lib/druid/elements/canvas.rb +9 -0
- data/lib/druid/elements/check_box.rb +9 -0
- data/lib/druid/elements/div.rb +9 -0
- data/lib/druid/elements/element.rb +187 -0
- data/lib/druid/elements/file_field.rb +9 -0
- data/lib/druid/elements/form.rb +9 -0
- data/lib/druid/elements/heading.rb +14 -0
- data/lib/druid/elements/hidden_field.rb +9 -0
- data/lib/druid/elements/image.rb +9 -0
- data/lib/druid/elements/italic.rb +9 -0
- data/lib/druid/elements/label.rb +8 -0
- data/lib/druid/elements/link.rb +9 -0
- data/lib/druid/elements/list_item.rb +9 -0
- data/lib/druid/elements/media.rb +11 -0
- data/lib/druid/elements/option.rb +9 -0
- data/lib/druid/elements/ordered_list.rb +29 -0
- data/lib/druid/elements/paragraph.rb +9 -0
- data/lib/druid/elements/radio_button.rb +9 -0
- data/lib/druid/elements/select_list.rb +30 -0
- data/lib/druid/elements/span.rb +9 -0
- data/lib/druid/elements/table.rb +92 -0
- data/lib/druid/elements/table_cell.rb +11 -0
- data/lib/druid/elements/table_row.rb +50 -0
- data/lib/druid/elements/text_area.rb +10 -0
- data/lib/druid/elements/text_field.rb +11 -0
- data/lib/druid/elements/unordered_list.rb +32 -0
- data/lib/druid/elements/video.rb +8 -0
- data/lib/druid/elements.rb +55 -0
- data/lib/druid/javascript/angularjs.rb +12 -0
- data/lib/druid/javascript/jquery.rb +12 -0
- data/lib/druid/javascript/prototype.rb +12 -0
- data/lib/druid/javascript/yui.rb +19 -0
- data/lib/druid/javascript_framework_facade.rb +76 -0
- data/lib/druid/locator_generator.rb +181 -0
- data/lib/druid/nested_elements.rb +56 -0
- data/lib/druid/page_factory.rb +115 -0
- data/lib/druid/page_populator.rb +104 -0
- data/lib/druid/section_collection.rb +17 -0
- data/lib/druid/version.rb +3 -0
- data/lib/druid.rb +452 -0
- data/spec/druid/accessors_spec.rb +1209 -0
- data/spec/druid/druid_spec.rb +295 -0
- data/spec/druid/element_locators_spec.rb +750 -0
- data/spec/druid/elements/bold_spec.rb +12 -0
- data/spec/druid/elements/button_spec.rb +23 -0
- data/spec/druid/elements/check_box_spec.rb +14 -0
- data/spec/druid/elements/div_spec.rb +10 -0
- data/spec/druid/elements/element_spec.rb +250 -0
- data/spec/druid/elements/file_field_spec.rb +13 -0
- data/spec/druid/elements/form_spec.rb +18 -0
- data/spec/druid/elements/heading_spec.rb +30 -0
- data/spec/druid/elements/hidden_field_spec.rb +10 -0
- data/spec/druid/elements/image_spec.rb +23 -0
- data/spec/druid/elements/itatic_spec.rb +11 -0
- data/spec/druid/elements/label_spec.rb +10 -0
- data/spec/druid/elements/link_spec.rb +10 -0
- data/spec/druid/elements/list_item_spec.rb +10 -0
- data/spec/druid/elements/media_spec.rb +12 -0
- data/spec/druid/elements/option_spec.rb +21 -0
- data/spec/druid/elements/ordered_list_spec.rb +38 -0
- data/spec/druid/elements/page_factory_spec.rb +40 -0
- data/spec/druid/elements/paragraph_spec.rb +12 -0
- data/spec/druid/elements/radio_button_spec.rb +14 -0
- data/spec/druid/elements/select_list_spec.rb +51 -0
- data/spec/druid/elements/span_spec.rb +10 -0
- data/spec/druid/elements/table_cell_spec.rb +14 -0
- data/spec/druid/elements/table_row_spec.rb +34 -0
- data/spec/druid/elements/table_spec.rb +47 -0
- data/spec/druid/elements/text_area_spec.rb +13 -0
- data/spec/druid/elements/text_field_spec.rb +22 -0
- data/spec/druid/elements/unordered_list_spec.rb +39 -0
- data/spec/druid/javascript_framework_facade_spec.rb +59 -0
- data/spec/druid/nested_element_spec.rb +128 -0
- data/spec/druid/page_factory_spec.rb +235 -0
- data/spec/druid/page_populator_spec.rb +173 -0
- data/spec/druid/page_section_spec.rb +70 -0
- data/spec/spec_helper.rb +9 -0
- metadata +517 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
class NestedElementsPage
|
|
2
|
+
include Druid
|
|
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.outer_div_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
|
+
h1(:nested_h1) { |page| page.outer_div_element.h1_element }
|
|
23
|
+
h2(:nested_h2) { |page| page.outer_div_element.h2_element }
|
|
24
|
+
h3(:nested_h3) { |page| page.outer_div_element.h3_element }
|
|
25
|
+
h4(:nested_h4) { |page| page.outer_div_element.h4_element }
|
|
26
|
+
h5(:nested_h5) { |page| page.outer_div_element.h5_element }
|
|
27
|
+
h6(:nested_h6) { |page| page.outer_div_element.h6_element }
|
|
28
|
+
paragraph(:nested_paragraph) { |page| page.outer_div_element.paragraph_element }
|
|
29
|
+
file_field(:nested_file_field) { |page| page.outer_div_element.file_field_element }
|
|
30
|
+
label(:nested_label) { |page| page.outer_div_element.label_element }
|
|
31
|
+
unordered_list(:outer_list, :id => 'outer')
|
|
32
|
+
ordered_list(:ordered_outer, :id => 'ol-outer')
|
|
33
|
+
end
|
|
34
|
+
Given(/^I am on the nested elements page$/) do
|
|
35
|
+
@page = NestedElementsPage.new(@driver)
|
|
36
|
+
@page.navigate_to(UrlHelper.nested_elements)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
When(/^I search for a link located in a div$/) do
|
|
40
|
+
@link = @page.nested_link_element
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
Then(/^I should be able to click the nested link$/) do
|
|
44
|
+
@link.click
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
When(/^I search for a button located in a div$/) do
|
|
48
|
+
@button = @page.nested_button_element
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
Then(/^I should be able to click the nested button$/) do
|
|
52
|
+
@button.click
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
When(/^I search for a text field located in a div$/) do
|
|
56
|
+
@text_field = @page.nested_text_field_element
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
Then(/^I should be able to type "([^"]*)" in the nested text field$/) do |value|
|
|
60
|
+
@text_field.value = value
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
When(/^I search for a hidden field located in a div$/) do
|
|
64
|
+
@hidden_field = @page.nested_hidden_field_element
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
Then(/^I should be able to see that the nested hidden field contains "([^"]*)"$/) do |value|
|
|
68
|
+
expect(@hidden_field.value).to eql value
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
When(/^I search for a text area located in a div$/) do
|
|
72
|
+
@text_area = @page.nested_text_area_element
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
Then(/^I should be able to type "([^"]*)" in the nested text area$/) do |value|
|
|
76
|
+
@text_area.value = value
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
When(/^I search for a select list located in a div$/) do
|
|
80
|
+
@select_list = @page.nested_select_list_element
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
Then(/^I should be able to select "([^"]*)" in the nested select list$/) do |value|
|
|
84
|
+
@select_list.select value
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
When(/^I search for a checkbox located in a div$/) do
|
|
88
|
+
@checkbox = @page.nested_checkbox_element
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
Then(/^I should be able to check the nested checkbox$/) do
|
|
92
|
+
@checkbox.check
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
When(/^I search for a radio button located in a div$/) do
|
|
96
|
+
@radio_button = @page.nested_radio_button_element
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
Then(/^I should be able to select the nested radio button$/) do
|
|
100
|
+
@radio_button.select
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
When(/^I search for a div located in a div$/) do
|
|
104
|
+
@div = @page.nested_div_element
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
Then(/^I should see the text "([^"]*)" in the nested div$/) do |text|
|
|
108
|
+
expect(@div.text).to eql text
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
When(/^I search for a span located in a div$/) do
|
|
112
|
+
@span = @page.nested_span_element
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
Then(/^I should see the text "([^"]*)" in the nested span$/) do |text|
|
|
116
|
+
expect(@span.text).to eql text
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
When(/^I search for a table located in a div$/) do
|
|
120
|
+
@table = @page.nested_table_element
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
Then(/^the data for row "([^"]*)" of the nested table should be "([^"]*)" and "([^"]*)"$/) do |row, col1, col2|
|
|
124
|
+
table_row = @table[row.to_i - 1]
|
|
125
|
+
expect(table_row[0].text).to eql col1
|
|
126
|
+
expect(table_row[1].text).to eql col2
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
When(/^I search the second table cell located in a table in a div$/) do
|
|
130
|
+
@cell = @page.nested_cell_element
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
Then(/^the nested table cell should contain "([^"]*)"$/) do |text|
|
|
134
|
+
expect(@cell.text).to eql text
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
When(/^I search for an image located in a div$/) do
|
|
138
|
+
@image = @page.nested_image_element
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
Then(/^the nested image should be "([^"]*)" pixels wide$/) do |width|
|
|
142
|
+
expect(@image.width).to eql width.to_i
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
Then(/^the nested image should be "([^"]*)" pixels tall$/) do |height|
|
|
146
|
+
expect(@image.height).to eql height.to_i
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
When(/^I search for a form located in a div$/) do
|
|
150
|
+
@form = @page.nested_form_element
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
Then(/^I should be able to submit the nested form$/) do
|
|
154
|
+
@form.submit
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
When(/^I search for an ordered list located in a div$/) do
|
|
158
|
+
@list = @page.nested_ordered_list_element
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
Then(/^the first nested list items text should be "([^"]*)"$/) do |text|
|
|
162
|
+
expect(@list[0].text).to eql text
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
When(/^I search for an unordered list located in a div$/) do
|
|
166
|
+
@list = @page.nested_unordered_list_element
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
When(/^I search for a list item nested in a ordered list in a div$/) do
|
|
170
|
+
@li = @page.nested_list_item_element
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
Then(/^I should see the nested list items text should be "([^"]*)"$/) do |text|
|
|
174
|
+
expect(@li.text).to eql text
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
When(/^I search for a h(\d+) located in a div$/) do |head_type|
|
|
178
|
+
@header = @page.send "nested_h#{head_type}_element"
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
Then(/^I should see the nested h(\d+)s text should be "([^"]*)"$/) do |head_type, text|
|
|
182
|
+
expect(@header.text).to eql text
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
When(/^I search for a paragraph located in a div$/) do
|
|
186
|
+
@para = @page.nested_paragraph_element
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
Then(/^I should see the nested paragraphs text should be "([^"]*)"$/) do |text|
|
|
190
|
+
expect(@para.text).to eql text
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
When(/^I search for a file field located in a div$/) do
|
|
194
|
+
@ff = @page.nested_file_field_element
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
Then(/^I should be able to retrieve the nested file field$/) do
|
|
198
|
+
expect(@ff.exist?).to be true
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
When(/^I get the outter unordered list$/) do
|
|
202
|
+
@list = @page.outer_list_element
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
When(/^I get the outter ordered list$/) do
|
|
206
|
+
@list = @page.ordered_outer_element
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
Then(/^I should see "([^"]*)" for list item (\d+)$/) do |text, item_num|
|
|
210
|
+
expect(@list[item_num.to_i - 1].text).to eql text
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
When(/^I search for a label located in a div$/) do
|
|
214
|
+
@label = @page.nested_label_element
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
Then(/^I should see the nested labels text should be "([^"]*)"$/) do |text|
|
|
218
|
+
expect(@label.text).to eql text
|
|
219
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
When(/^I get the first item from the ordered list$/) do
|
|
2
|
+
@element = @page.ol_id_element[0]
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
Then(/^the list item's text should be "(.*?)"$/) do |text|
|
|
6
|
+
expect(@element.text).to eql text
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
When(/^I locate the ordered list by "(.*?)"$/) do |how|
|
|
10
|
+
@list = @page.send "ol_#{how}_element"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
When(/^I get the first item from the list$/) do
|
|
14
|
+
@element = @list[0]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Then(/^the list should contain (\d+) items$/) do |items|
|
|
18
|
+
expect(@list.items).to eql items.to_i
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
Then(/^each item should contain "(.*?)"$/) do |text|
|
|
22
|
+
@list.each do |item|
|
|
23
|
+
expect(item.text).to include text
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
When(/^I search for the ordered list by "(.*?)" and "(.*?)"$/) do |param1, param2|
|
|
28
|
+
@list = @page.send "ol_#{param1}_#{param2}_element"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
Then(/^the list items text should be "(.*?)"$/) do |expected_text|
|
|
32
|
+
expect(@element.text).to eql expected_text
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
When(/^I retrieve a ordered list element$/) do
|
|
36
|
+
@element = @page.ol_id_element
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
When(/^I search for the ordered list while the script is executing$/) do
|
|
40
|
+
@list = @page.ordered_list_element(:id => 'ol_id')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
Then(/^I should see that the ordered list exists$/) do
|
|
44
|
+
expect(@page.ol_id?).to be true
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
Then(/^the text for the ordered list should contain "([^"]*)"$/) do |text|
|
|
48
|
+
expect(@page.send("ol_id")).to include text
|
|
49
|
+
end
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
Then(/^the page should contain the text "(.*?)"$/) do |text|
|
|
2
|
+
expect(@page.text).to include text
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
Then(/^the page should contain the html "(.*?)"$/) do |html|
|
|
6
|
+
expect(@page.html).to include html
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
Then(/^the page should have the title "(.*?)"$/) do |title|
|
|
10
|
+
expect(@page.title).to include title
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Then(/^I am able to go to baidu\.com$/) do
|
|
14
|
+
@page.goto
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Given(/^I can goto baidu\.com by default$/) do
|
|
18
|
+
@page = Page.new(@driver)
|
|
19
|
+
@page.goto
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
Given(/^I can goto baidu\.com using visit_page without block$/) do
|
|
23
|
+
visit_page(Page)
|
|
24
|
+
# @page = visit_page Page
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
Then(/^the page should have the title "(.*?)" using on_page without block$/) do |text|
|
|
28
|
+
expect(on_page(Page).title).to include text
|
|
29
|
+
# expect(on_page(@page).title).to include text
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
Given(/^I can goto baidu\.com using visit_page with block$/) do
|
|
33
|
+
visit_page(Page) do |page|
|
|
34
|
+
expect(page.title).to include "百度"
|
|
35
|
+
end
|
|
36
|
+
# @page = visit_page Page do |page|
|
|
37
|
+
# expect(page.title).to include "百度"
|
|
38
|
+
# end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
Then(/^the page should have the title "(.*?)" using on_page with block$/) do |text|
|
|
42
|
+
on_page(Page) do |page|
|
|
43
|
+
expect(page.title).to include text
|
|
44
|
+
end
|
|
45
|
+
# on_page(@page) do |page|
|
|
46
|
+
# expect(page.title).to include text
|
|
47
|
+
# end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
Then(/^I should be able to wait for a block to return true$/) do
|
|
51
|
+
@page.google_search_id
|
|
52
|
+
@page.wait_until(10, "too long to display page") do
|
|
53
|
+
@page.text.include? 'Success'
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
When(/^I handle the alert$/) do
|
|
58
|
+
@msg = @page.alert do
|
|
59
|
+
@page.alert_button
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
Then(/^I should be able to get the alert's message$/) do
|
|
64
|
+
expect(@msg).to eql "I am an alert"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
When(/^I handle the confirm$/) do
|
|
68
|
+
@msg = @page.confirm(true) do
|
|
69
|
+
@page.confirm_button
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
Then(/^I should be able to get the confirm's message$/) do
|
|
74
|
+
expect(@msg).to eql "set the value"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
When(/^I handle the prompt$/) do
|
|
78
|
+
@msg = @page.prompt("Tim") do
|
|
79
|
+
@page.prompt_button
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
Then(/^I should be able to get the message and default value$/) do
|
|
84
|
+
expect(@msg).to eql "enter your name"
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
When(/^I open a second window$/) do
|
|
88
|
+
@page.open_window
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
class SecondPage
|
|
92
|
+
include Druid
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
Then(/^I should be able to attach to page object using title$/) do
|
|
96
|
+
@second_page = SecondPage.new(@driver)
|
|
97
|
+
@second_page.attach_to_window(:title => "Success")
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
Then(/^I should be able to attach to page object using url$/) do
|
|
101
|
+
@second_page = SecondPage.new(@driver)
|
|
102
|
+
@second_page.attach_to_window(:url => "success.html")
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
Then(/^I should be able to attach to page object using index$/) do
|
|
106
|
+
@second_page = SecondPage.new(@driver)
|
|
107
|
+
@second_page.attach_to_window(:index => 1)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
Then(/^I should be able to refresh the page$/) do
|
|
111
|
+
@page.refresh
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
When(/^I press the back button$/) do
|
|
115
|
+
@page.back
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
When(/^I press the forward button$/) do
|
|
119
|
+
@page.forward
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
Then(/^the page should have the expected title$/) do
|
|
123
|
+
expect(@page).to have_expected_title
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
Then(/^the page should have the expected element$/) do
|
|
127
|
+
expect(@page).to have_expected_element
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
Then(/^the page should not have the expected element$/) do
|
|
131
|
+
class FakePage
|
|
132
|
+
include Druid
|
|
133
|
+
expected_element :blah
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
expect(FakePage.new(@driver)).not_to have_expected_element
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
When(/^I handle the alert that reloads the page$/) do
|
|
141
|
+
@msg = @page.alert do
|
|
142
|
+
@page.alert_button_that_reloads
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
When(/^I handle the confirm that reloads the page$/) do
|
|
147
|
+
@msg = @page.confirm(true) do
|
|
148
|
+
@page.confirm_button_that_reloads
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
When(/^I handle the possible alert$/) do
|
|
153
|
+
@msg = @page.alert do
|
|
154
|
+
@page.alert_button_element.focus
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
Then(/^I should be able to verify the popup didn't have a message$/) do
|
|
159
|
+
expect(@msg).to be_nil
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
When(/^I handle the possible confirm$/) do
|
|
163
|
+
@msg = @page.confirm(true) do
|
|
164
|
+
@page.confirm_button_element.focus
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
When(/^I handle the possible prompt$/) do
|
|
169
|
+
@msg = @page.prompt("Tim") do
|
|
170
|
+
@page.prompt_button_element.focus
|
|
171
|
+
end
|
|
172
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
When(/^I get the text from the paragraph$/) do
|
|
2
|
+
@text = @page.p_id
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
When(/^I search for the paragraph by "([^"]*)"$/) do |how|
|
|
6
|
+
@text = @page.send "p_#{how}".to_sym
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
When(/^I search for the paragraph by "([^"]*)" and "([^"]*)"$/) do |param1, param2|
|
|
10
|
+
@text = @page.send "p_#{param1}_#{param2}".to_sym
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
When(/^I get the text from a paragraph while the script is executing$/) do
|
|
14
|
+
@text = @page.paragraph_element(:id => 'p_id').text
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Then(/^I should see that the paragraph exists$/) do
|
|
18
|
+
expect(@page.p_id?).to be true
|
|
19
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Then(/^I should see that the radio button group exists$/) do
|
|
2
|
+
expect(@page.favorite_cheese?).to be true
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
Then(/^no radio buttons should be selected in the group$/) do
|
|
6
|
+
expect(@page.favorite_cheese_selected?).to be false
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
When(/^I select the "([^"]*)" radio button in the group$/) do |how|
|
|
10
|
+
@page.select_favorite_cheese("#{how}")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Then(/^the "([^"]*)" radio button should be selected in the group$/) do |how|
|
|
14
|
+
expect(@page.favorite_cheese_selected?).to eql how
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Then(/^the "([^"]*)" radio button should not be selected$/) do |how|
|
|
18
|
+
expect(@page.favorite_cheese_selected?).not_to eql how
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
When(/^I ask for the elements of a radio button group$/) do
|
|
22
|
+
@elements = @page.favorite_cheese_elements
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
Then(/^I should have an array with elements for each radio button$/) do
|
|
26
|
+
expect(@elements.length).to eql 3
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
Then(/^the radio button element values should be "([^"]*)", "([^"]*)", "([^"]*)"$/) do |val1, val2, val3|
|
|
30
|
+
expect(@page.favorite_cheese_values).to eql [val1, val2, val3]
|
|
31
|
+
|
|
32
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
When(/^I select the "(.*?)" radio button$/) do |name|
|
|
2
|
+
@page.send "select_#{name.downcase}_id".to_sym
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
Then(/^the "(.*?)" radio button should be selected$/) do |name|
|
|
6
|
+
expect(@page.send "#{name.downcase}_id_selected?".to_sym).to be true
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
When(/^I locate the radio button by "(.*?)"$/) do |how|
|
|
10
|
+
@how = how
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
When(/^I select the radio button$/) do
|
|
14
|
+
@page.send "select_milk_#{@how}".to_sym
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
When(/^I retrieve a radio button$/) do
|
|
18
|
+
@element = @page.milk_id_element
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
When(/^I search for the radio button by "(.*?)" and "(.*?)"$/) do |param1, param2|
|
|
22
|
+
@how = "#{param1}_#{param2}"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
When(/^I select the radio button while the script is executing$/) do
|
|
26
|
+
@page.radio_button_element(:id => "milk_id").select
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
Then(/^I should see that the radio button exists$/) do
|
|
30
|
+
expect(@page.milk_id?).to be true
|
|
31
|
+
end
|