druid-s 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.rspec +1 -0
  4. data/.rvmrc +1 -0
  5. data/.travis.yml +27 -0
  6. data/ChangeLog +541 -0
  7. data/Gemfile +8 -0
  8. data/README.md +78 -0
  9. data/Rakefile +33 -0
  10. data/cucumber.yml +6 -0
  11. data/druid.gemspec +30 -0
  12. data/features/area.feature +33 -0
  13. data/features/async.feature +16 -0
  14. data/features/audio.feature +61 -0
  15. data/features/bold.feature +20 -0
  16. data/features/button.feature +81 -0
  17. data/features/canvas.feature +34 -0
  18. data/features/checkbox.feature +48 -0
  19. data/features/div.feature +45 -0
  20. data/features/element.feature +281 -0
  21. data/features/file_field.feature +38 -0
  22. data/features/form.feature +37 -0
  23. data/features/frames.feature +76 -0
  24. data/features/generic_elements.feature +29 -0
  25. data/features/heading.feature +160 -0
  26. data/features/hidden_field.feature +39 -0
  27. data/features/html/async.html +31 -0
  28. data/features/html/frame_1.html +18 -0
  29. data/features/html/frame_2.html +16 -0
  30. data/features/html/frame_3.html +14 -0
  31. data/features/html/frames.html +12 -0
  32. data/features/html/hover.html +11 -0
  33. data/features/html/iframes.html +12 -0
  34. data/features/html/images/circle.png +0 -0
  35. data/features/html/images/img_pulpit.jpg +0 -0
  36. data/features/html/modal.html +17 -0
  37. data/features/html/modal_1.html +38 -0
  38. data/features/html/modal_2.html +27 -0
  39. data/features/html/multi_elements.html +145 -0
  40. data/features/html/nested_elements.html +75 -0
  41. data/features/html/nested_frame_1.html +1 -0
  42. data/features/html/nested_frame_2.html +11 -0
  43. data/features/html/nested_frame_3.html +14 -0
  44. data/features/html/nested_frames.html +10 -0
  45. data/features/html/planets.gif +0 -0
  46. data/features/html/static_elements.html +203 -0
  47. data/features/html/success.html +8 -0
  48. data/features/html/sun.gif +0 -0
  49. data/features/html/sun.html +7 -0
  50. data/features/image.feature +47 -0
  51. data/features/italic.feature +20 -0
  52. data/features/javascript.feature +28 -0
  53. data/features/label.feature +43 -0
  54. data/features/link.feature +56 -0
  55. data/features/list_item.feature +37 -0
  56. data/features/modal_dialog.feature +9 -0
  57. data/features/multi_elements.feature +498 -0
  58. data/features/nested_elements.feature +121 -0
  59. data/features/ordered_list.feature +46 -0
  60. data/features/page_level_actions.feature +116 -0
  61. data/features/paragraph.feature +33 -0
  62. data/features/populate_page_with.feature +25 -0
  63. data/features/radio_button.feature +51 -0
  64. data/features/radio_button_group.feature +28 -0
  65. data/features/sample-app/public/04-Death_Becomes_Fur.mp4 +0 -0
  66. data/features/sample-app/public/04-Death_Becomes_Fur.oga +0 -0
  67. data/features/sample-app/public/audio_video.html +19 -0
  68. data/features/sample-app/public/jquery-1.3.2.js +4376 -0
  69. data/features/sample-app/public/jquery.html +28 -0
  70. data/features/sample-app/public/movie.mp4 +0 -0
  71. data/features/sample-app/public/movie.ogg +0 -0
  72. data/features/sample-app/public/prototype-1.6.0.3.js +4320 -0
  73. data/features/sample-app/public/prototype.html +32 -0
  74. data/features/sample-app/sample_app.rb +35 -0
  75. data/features/section.feature +132 -0
  76. data/features/select_list.feature +84 -0
  77. data/features/span.feature +43 -0
  78. data/features/step_definations/area_steps.rb +23 -0
  79. data/features/step_definations/async_steps.rb +80 -0
  80. data/features/step_definations/audio_steps.rb +47 -0
  81. data/features/step_definations/bold_steps.rb +11 -0
  82. data/features/step_definations/button_steps.rb +52 -0
  83. data/features/step_definations/canvas_steps.rb +19 -0
  84. data/features/step_definations/checkbox_steps.rb +39 -0
  85. data/features/step_definations/div_steps.rb +28 -0
  86. data/features/step_definations/element_steps.rb +217 -0
  87. data/features/step_definations/file_field_steps.rb +31 -0
  88. data/features/step_definations/form_steps.rb +23 -0
  89. data/features/step_definations/frame_steps.rb +189 -0
  90. data/features/step_definations/generic_element_steps.rb +31 -0
  91. data/features/step_definations/heading_steps.rb +39 -0
  92. data/features/step_definations/hidden_field_steps.rb +27 -0
  93. data/features/step_definations/image_steps.rb +35 -0
  94. data/features/step_definations/italic_steps.rb +11 -0
  95. data/features/step_definations/javasript_steps.rb +52 -0
  96. data/features/step_definations/label_steps.rb +19 -0
  97. data/features/step_definations/link_steps.rb +42 -0
  98. data/features/step_definations/list_item_steps.rb +24 -0
  99. data/features/step_definations/modal_dialog_steps.rb +38 -0
  100. data/features/step_definations/multi_elements_steps.rb +557 -0
  101. data/features/step_definations/nested_elements_steps.rb +219 -0
  102. data/features/step_definations/ordered_list_steps.rb +49 -0
  103. data/features/step_definations/page_level_actions_steps.rb +172 -0
  104. data/features/step_definations/page_traversal_steps.rb +4 -0
  105. data/features/step_definations/paragraph_steps.rb +19 -0
  106. data/features/step_definations/populate_page_with_steps.rb +3 -0
  107. data/features/step_definations/radio_button_group_steps.rb +32 -0
  108. data/features/step_definations/radio_button_steps.rb +31 -0
  109. data/features/step_definations/section_steps.rb +271 -0
  110. data/features/step_definations/select_list_steps.rb +91 -0
  111. data/features/step_definations/span_steps.rb +23 -0
  112. data/features/step_definations/table_cell_steps.rb +27 -0
  113. data/features/step_definations/table_row_steps.rb +23 -0
  114. data/features/step_definations/table_steps.rb +109 -0
  115. data/features/step_definations/text_area_steps.rb +39 -0
  116. data/features/step_definations/text_field_steps.rb +39 -0
  117. data/features/step_definations/unordered_list_steps.rb +27 -0
  118. data/features/step_definations/video_steps.rb +27 -0
  119. data/features/support/ajax_test_environment.rb +26 -0
  120. data/features/support/audio_video_page.rb +23 -0
  121. data/features/support/env.rb +5 -0
  122. data/features/support/hooks.rb +3 -0
  123. data/features/support/page.rb +372 -0
  124. data/features/support/persistent_browser.rb +58 -0
  125. data/features/support/targets/firefox14_osx.rb +5 -0
  126. data/features/support/targets/firefox14_windows7.rb +5 -0
  127. data/features/support/url_helper.rb +50 -0
  128. data/features/table.feature +127 -0
  129. data/features/table_cell.feature +42 -0
  130. data/features/table_row.feature +30 -0
  131. data/features/text_area.feature +44 -0
  132. data/features/text_field.feature +53 -0
  133. data/features/unordered_list.feature +46 -0
  134. data/features/video.feature +66 -0
  135. data/lib/druid/accessors.rb +1082 -0
  136. data/lib/druid/assist.rb +653 -0
  137. data/lib/druid/element_locators.rb +21 -0
  138. data/lib/druid/elements/area.rb +9 -0
  139. data/lib/druid/elements/audio.rb +9 -0
  140. data/lib/druid/elements/bold.rb +8 -0
  141. data/lib/druid/elements/button.rb +12 -0
  142. data/lib/druid/elements/canvas.rb +9 -0
  143. data/lib/druid/elements/check_box.rb +9 -0
  144. data/lib/druid/elements/div.rb +9 -0
  145. data/lib/druid/elements/element.rb +187 -0
  146. data/lib/druid/elements/file_field.rb +9 -0
  147. data/lib/druid/elements/form.rb +9 -0
  148. data/lib/druid/elements/heading.rb +14 -0
  149. data/lib/druid/elements/hidden_field.rb +9 -0
  150. data/lib/druid/elements/image.rb +9 -0
  151. data/lib/druid/elements/italic.rb +9 -0
  152. data/lib/druid/elements/label.rb +8 -0
  153. data/lib/druid/elements/link.rb +9 -0
  154. data/lib/druid/elements/list_item.rb +9 -0
  155. data/lib/druid/elements/media.rb +11 -0
  156. data/lib/druid/elements/option.rb +9 -0
  157. data/lib/druid/elements/ordered_list.rb +29 -0
  158. data/lib/druid/elements/paragraph.rb +9 -0
  159. data/lib/druid/elements/radio_button.rb +9 -0
  160. data/lib/druid/elements/select_list.rb +30 -0
  161. data/lib/druid/elements/span.rb +9 -0
  162. data/lib/druid/elements/table.rb +92 -0
  163. data/lib/druid/elements/table_cell.rb +11 -0
  164. data/lib/druid/elements/table_row.rb +50 -0
  165. data/lib/druid/elements/text_area.rb +10 -0
  166. data/lib/druid/elements/text_field.rb +11 -0
  167. data/lib/druid/elements/unordered_list.rb +32 -0
  168. data/lib/druid/elements/video.rb +8 -0
  169. data/lib/druid/elements.rb +55 -0
  170. data/lib/druid/javascript/angularjs.rb +12 -0
  171. data/lib/druid/javascript/jquery.rb +12 -0
  172. data/lib/druid/javascript/prototype.rb +12 -0
  173. data/lib/druid/javascript/yui.rb +19 -0
  174. data/lib/druid/javascript_framework_facade.rb +76 -0
  175. data/lib/druid/locator_generator.rb +181 -0
  176. data/lib/druid/nested_elements.rb +56 -0
  177. data/lib/druid/page_factory.rb +115 -0
  178. data/lib/druid/page_populator.rb +104 -0
  179. data/lib/druid/section_collection.rb +17 -0
  180. data/lib/druid/version.rb +3 -0
  181. data/lib/druid.rb +452 -0
  182. data/spec/druid/accessors_spec.rb +1209 -0
  183. data/spec/druid/druid_spec.rb +295 -0
  184. data/spec/druid/element_locators_spec.rb +750 -0
  185. data/spec/druid/elements/bold_spec.rb +12 -0
  186. data/spec/druid/elements/button_spec.rb +23 -0
  187. data/spec/druid/elements/check_box_spec.rb +14 -0
  188. data/spec/druid/elements/div_spec.rb +10 -0
  189. data/spec/druid/elements/element_spec.rb +250 -0
  190. data/spec/druid/elements/file_field_spec.rb +13 -0
  191. data/spec/druid/elements/form_spec.rb +18 -0
  192. data/spec/druid/elements/heading_spec.rb +30 -0
  193. data/spec/druid/elements/hidden_field_spec.rb +10 -0
  194. data/spec/druid/elements/image_spec.rb +23 -0
  195. data/spec/druid/elements/itatic_spec.rb +11 -0
  196. data/spec/druid/elements/label_spec.rb +10 -0
  197. data/spec/druid/elements/link_spec.rb +10 -0
  198. data/spec/druid/elements/list_item_spec.rb +10 -0
  199. data/spec/druid/elements/media_spec.rb +12 -0
  200. data/spec/druid/elements/option_spec.rb +21 -0
  201. data/spec/druid/elements/ordered_list_spec.rb +38 -0
  202. data/spec/druid/elements/page_factory_spec.rb +40 -0
  203. data/spec/druid/elements/paragraph_spec.rb +12 -0
  204. data/spec/druid/elements/radio_button_spec.rb +14 -0
  205. data/spec/druid/elements/select_list_spec.rb +51 -0
  206. data/spec/druid/elements/span_spec.rb +10 -0
  207. data/spec/druid/elements/table_cell_spec.rb +14 -0
  208. data/spec/druid/elements/table_row_spec.rb +34 -0
  209. data/spec/druid/elements/table_spec.rb +47 -0
  210. data/spec/druid/elements/text_area_spec.rb +13 -0
  211. data/spec/druid/elements/text_field_spec.rb +22 -0
  212. data/spec/druid/elements/unordered_list_spec.rb +39 -0
  213. data/spec/druid/javascript_framework_facade_spec.rb +59 -0
  214. data/spec/druid/nested_element_spec.rb +128 -0
  215. data/spec/druid/page_factory_spec.rb +235 -0
  216. data/spec/druid/page_populator_spec.rb +173 -0
  217. data/spec/druid/page_section_spec.rb +70 -0
  218. data/spec/spec_helper.rb +9 -0
  219. metadata +517 -0
@@ -0,0 +1,32 @@
1
+ <htmL>
2
+ <head>
3
+ <title>Prototype - Sample App</title>
4
+ <script type="application/x-javascript" src="/prototype-1.6.0.3.js"></script>
5
+ </head>
6
+ <body>
7
+ <div id="ajax-demo">
8
+ <h2>AJAX Calculator</h2>
9
+ <form id="calculator-form" action="#" method="post" onSubmit="return false;">
10
+ <input id="calculator-expression" name="calculator-expression"/>
11
+ <input type="submit" id="calculator-button" value="Compute" />
12
+ <br/><br/>
13
+ <div>Result: <input id="calculator-result" disabled /></div>
14
+ </form>
15
+
16
+ <script type="text/javascript" language="javascript">
17
+ Event.observe(window, 'load', function() {
18
+ Event.observe('calculator-button', 'click', function (event) {
19
+ new Ajax.Request('/compute', {
20
+ method: 'post',
21
+ parameters: $('calculator-form').serialize(true),
22
+ onSuccess: function(transport) {
23
+ $('calculator-result').value = transport.responseText;
24
+ },
25
+ });
26
+ return false;
27
+ });
28
+ });
29
+ </script>
30
+ </div>
31
+
32
+ </body>
@@ -0,0 +1,35 @@
1
+ require 'rubygems'
2
+ require 'rack'
3
+ require 'rackup'
4
+ require 'webrick'
5
+
6
+ class SampleApp
7
+
8
+ def self.start(host, port)
9
+ Rackup::Handler::WEBrick.run new,
10
+ :Host => host,
11
+ :Port => port,
12
+ :Logger => ::WEBrick::Log.new(RUBY_PLATFORM =~ /mswin|mingw/ ? 'NUL:' : '/dev/null'),
13
+ :AccessLog => [nil, nil]
14
+ end
15
+
16
+ def initialize
17
+ @public = File.expand_path("../public", __FILE__)
18
+ end
19
+
20
+ def call(env)
21
+ req = Rack::Request.new(env)
22
+
23
+ case req.path
24
+ when "/"
25
+ [200, {}, ["Sample Application"]]
26
+ when "/compute"
27
+ sleep 5
28
+ resp = eval(req.params['calculator-expression']).to_s
29
+ [200, {}, [resp]]
30
+ else
31
+ @public.call(env)
32
+ end
33
+ end
34
+
35
+ end
@@ -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 is 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: Selecting multiple sections
116
+ When I select multiple sections
117
+ Then I should have a section collection containing the sections
118
+ And I can access any index of that collection of sections
119
+
120
+ Scenario: Searching section collection
121
+ Given I select multiple sections
122
+ When I search by a specific value of the section
123
+ Then I will find the first section with that value
124
+
125
+ Scenario: Filtering section collection
126
+ Given I select multiple sections
127
+ When I filter by a specific value of the sections
128
+ Then I will find all sections with that value
129
+
130
+ Scenario: Sections roots can be accessed
131
+ When I have a page section
132
+ Then methods called on the section are passed to the root if missing
@@ -0,0 +1,84 @@
1
+ Feature: Select List
2
+ In order to interact with select lists
3
+ Testers will need access and interrogation ability
4
+
5
+ Background:
6
+ Given I am on the static elements page
7
+
8
+ Scenario: Selecting an element on the select list
9
+ When I select "Test 2" from the select list
10
+ Then the current item should be "Test 2"
11
+
12
+ Scenario: Selecting an element when there is a forward slash
13
+ When I select "Test/Test 3" from the select list
14
+ Then the current item should be "Test/Test 3"
15
+
16
+ Scenario Outline: Locating select lists on the Page
17
+ When I locate the select list by "<locate_by>"
18
+ Then I should be able to select "Test 2"
19
+ And the value for the selected item should be "Test 2"
20
+ And the value for the option should be "option2"
21
+
22
+ Examples:
23
+ | locate_by |
24
+ | id |
25
+ | class |
26
+ | name |
27
+ | xpath |
28
+ | index |
29
+ | label |
30
+ | css |
31
+
32
+ Scenario: Retrieve a select list
33
+ When I retrieve a select list
34
+ Then I should know it exists
35
+ And I should know it is visible
36
+
37
+ @dev
38
+ Scenario: Iterating through the options in the select list
39
+ When I search for the select list by "id"
40
+ Then option "1" should contain "Test 1"
41
+ And option "2" should contain "Test 2"
42
+ And each option should contain "Test"
43
+
44
+ @multi
45
+ Scenario Outline: Locating a select list using multiple parameters
46
+ When I search for the select list bys "<param1>" and "<param2>"
47
+ Then I should be able to select "Test 2"
48
+ And the value for the selected item should be "Test 2"
49
+ And the value for the option should be "option2"
50
+
51
+ Examples:
52
+ | param1 | param2 |
53
+ | class | index |
54
+ | name | index |
55
+
56
+ @locator
57
+ Scenario: Finding a select list dynamically
58
+ When I find a select list while the script is executing
59
+ Then I should see that the select list exists
60
+ And I should be able to select "Test 2" from the list
61
+
62
+ Scenario: Getting the selected option
63
+ When I select "Test 2" from the select list
64
+ Then the selected option should be "Test 2"
65
+
66
+ Scenario: Determining if a select list includes some options
67
+ Then the select list should include "Test 2"
68
+
69
+ Scenario: It should know if an option is selected
70
+ When I select "Test 2" from the select list
71
+ Then the select list should know that "Test 2" is selected
72
+
73
+ Scenario: Clearing multiple select list
74
+ When I clear multiple select list
75
+ Then multiple select list should have no selected options
76
+ And cleared multiple select list should return nil for value
77
+
78
+ Scenario: Selecting an option by its value
79
+ When I select an option using the value "option2"
80
+ Then the selected option should be "Test 2"
81
+
82
+ Scenario: Getting the value from a selected option
83
+ When I select an option using the value "option2"
84
+ Then the selected option should have a value of "option2"
@@ -0,0 +1,43 @@
1
+ Feature: Span
2
+
3
+ Background:
4
+ Given I am on the static elements page
5
+
6
+ Scenario: Getting the text from a span
7
+ When I get the text from the span
8
+ Then the text should be "My alert"
9
+
10
+ @name
11
+ Scenario Outline: Locating spans on the page
12
+ When I locate the span by "<locate_by>"
13
+ Then the text should be "My alert"
14
+
15
+ Examples:
16
+ | locate_by |
17
+ | id |
18
+ | class |
19
+ | xpath |
20
+ | index |
21
+ | text |
22
+ | title |
23
+ | css |
24
+
25
+ Scenario: Retrieve a Span
26
+ When I retrieve a span element
27
+ Then I should know it exists
28
+ And I should know it is visible
29
+
30
+ @multi
31
+ Scenario Outline: Locating span using multiple parameters
32
+ When I search for the span by "<param1>" and "<param2>"
33
+ Then the text should be "My alert"
34
+
35
+ Examples:
36
+ | param1 | param2 |
37
+ | class | index |
38
+
39
+ @locator
40
+ Scenario: Finding a span dynamically
41
+ When I get the text from a span while the script is executing
42
+ Then I should see that the span exists
43
+ And the text should be "My alert"
@@ -0,0 +1,23 @@
1
+ When(/^I retrieve the area element$/) do
2
+ @element = @page.area_id_element
3
+ end
4
+
5
+ When(/^I search for the area by "([^"]*)"$/) do |how|
6
+ @how = how
7
+ end
8
+
9
+ Then(/^I should be able to click the area$/) do
10
+ @page.send("area_#{@how}")
11
+ end
12
+
13
+ Then(/^I should see the coordinates are "([^"]*)"$/) do |coords|
14
+ expect(@element.coords).to eql coords
15
+ end
16
+
17
+ Then(/^I should see the shape are "([^"]*)"$/) do |shape|
18
+ expect(@element.shape).to eql shape
19
+ end
20
+
21
+ Then(/^I should see the href is "([^"]*)"$/) do |href|
22
+ expect(@element.href).to include href
23
+ end
@@ -0,0 +1,80 @@
1
+ def success
2
+
3
+ end
4
+
5
+ Then(/^I should be able to wait until it is present$/) do
6
+ @element.when_present do
7
+ success
8
+ end
9
+ end
10
+
11
+ Then(/^I should be able to wait until it is visible$/) do
12
+ @element.when_visible do
13
+ success
14
+ end
15
+ end
16
+
17
+ Then(/^I should be able to wait until it is not visible$/) do
18
+ begin
19
+ @element.when_not_visible do
20
+ fail
21
+ end
22
+ rescue
23
+ success
24
+ end
25
+ end
26
+
27
+ Then(/^I should be able to wait until a block returns true$/) do
28
+ @element.wait_until do
29
+ @element.present?
30
+ end
31
+ end
32
+
33
+ class AsyncPage
34
+ include Druid
35
+
36
+ button(:target, :value => 'Target')
37
+ button(:hide, :value => 'Hide Button')
38
+ button(:unhide, :value => 'Unhide Button')
39
+ button(:create_button, :value => "Create Button")
40
+ button(:remove_button, :value => "Remove Button")
41
+ button(:created_button, :value => "New Button")
42
+ end
43
+
44
+ Given(/^I am on the async elements page$/) do
45
+ @page = AsyncPage.new(@driver)
46
+ @page.navigate_to(UrlHelper.async)
47
+ end
48
+
49
+ When(/^I make the button invisible$/) do
50
+ @page.hide
51
+ sleep 2
52
+ end
53
+
54
+ Then(/^I should be able to click it when it becomes visible$/) do
55
+ @page.unhide
56
+ @page.target_element.when_visible do
57
+ @page.target
58
+ end
59
+ end
60
+
61
+ Then(/^I should be able to wait until the button becomes invisible$/) do
62
+ @page.hide
63
+ @page.target_element.when_not_visible do
64
+ expect(@page.target_element.attribute("block")).to eql "none"
65
+ end
66
+ end
67
+
68
+ When(/^I add a button a few seconds from now$/) do
69
+ @page.create_button
70
+ end
71
+
72
+ When(/^I remove a button a few seconds from now$/) do
73
+ @page.created_button_element.when_present
74
+ @page.remove_button
75
+ end
76
+
77
+ Then(/^I should not be able to find the button$/) do
78
+ @page.created_button_element.when_not_present
79
+ expect(@page.created_button_element.exist?).to be false
80
+ end
@@ -0,0 +1,47 @@
1
+ When(/^I search for the audio element by "([^"]*)"$/) do |how|
2
+ @element = @avpage.send "audio_#{how}_element"
3
+ end
4
+
5
+ When(/^I search for the audio element by "([^"]*)" and "([^"]*)"$/) do |param1, param2|
6
+ @element = @avpage.send "audio_#{param1}_#{param2}_element"
7
+ end
8
+
9
+ Then(/^I should know the audio is not autoplay$/) do
10
+ expect(@element).not_to be_autoplay
11
+ end
12
+
13
+ Then(/^I should know that the controls are displayed$/) do
14
+ expect(@element).to have_controls
15
+ end
16
+
17
+ Then(/^I should know that the audio is paused$/) do
18
+ expect(@element).to be_paused
19
+ end
20
+
21
+ Then(/^I should know that its volume is (\d+)$/) do |volume|
22
+ expect(@element.volume).to eql volume.to_f
23
+ end
24
+
25
+ Given(/^I am on the audio video page$/) do
26
+ @avpage = visit AudioVideoPage
27
+ end
28
+
29
+ When(/^I retrieve the audio element from the page$/) do
30
+ @element = @avpage.audio_id_element
31
+ end
32
+
33
+ Then(/^I should know that it has not ended$/) do
34
+ expect(@element).not_to be_ended
35
+ end
36
+
37
+ Then(/^I should know that it is not seeking$/) do
38
+ expect(@element).not_to be_seeking
39
+ end
40
+
41
+ Then(/^I should know that it is not in a loop$/) do
42
+ expect(@element).not_to be_loop
43
+ end
44
+
45
+ Then(/^I should know that it is muted$/) do
46
+ expect(@element).not_to be_muted
47
+ end
@@ -0,0 +1,11 @@
1
+ When(/^I get the bold text for the "([^"]*)" element$/) do |el|
2
+ @b = @page.send "#{el}_id"
3
+ end
4
+
5
+ Then(/^I should see "([^"]*)" in bold$/) do |text|
6
+ expect(@b).to eql text
7
+ end
8
+
9
+ When(/^I search bold text for the b by "([^"]*)"$/) do |type|
10
+ @b = @page.send "b_#{type}"
11
+ end
@@ -0,0 +1,52 @@
1
+ When(/^I click the button$/) do
2
+ @page.button_id
3
+ end
4
+
5
+ Then(/^I should be on the success page$/) do
6
+ expect(@page.text).to include 'Success'
7
+ expect(@page.title).to eql 'Success'
8
+ end
9
+
10
+ When(/^I locate the button by "(.*?)"$/) do |how|
11
+ @how = how
12
+ end
13
+
14
+ Then(/^I should be able to click the button$/) do
15
+ @page.send "button_#{@how}".to_sym
16
+ end
17
+
18
+ When(/^I retrieve a button element$/) do
19
+ @element = @page.send "button_id_element".to_sym
20
+ end
21
+
22
+ When(/^I search for the button by "(.*?)" and "(.*?)"$/) do |param1, param2|
23
+ @how = "#{param1}_#{param2}"
24
+ end
25
+
26
+ When(/^I find a button while the script is executing$/) do
27
+ @button = @page.button_element(:id => 'button_id')
28
+ end
29
+
30
+ Then(/^I should be able to click the button element$/) do
31
+ @button.click
32
+ end
33
+
34
+ Then(/^I should be able to click the real button$/) do
35
+ @page.send "btn_#{@how}".to_sym
36
+ end
37
+
38
+ When(/^I click the button with type image$/) do
39
+ @page.button_image_id
40
+ end
41
+
42
+ When(/^I click the image button using src$/) do
43
+ @page.button_image_src
44
+ end
45
+
46
+ When(/^I click the image button using alt$/) do
47
+ @page.button_image_alt
48
+ end
49
+
50
+ Then(/^I should see that the button exists$/) do
51
+ expect(@page.button_id?).to eql true
52
+ end
@@ -0,0 +1,19 @@
1
+ When(/^I retrieve the canvas element$/) do
2
+ @element = @page.canvas_id_element
3
+ end
4
+
5
+ When(/^I search for the canvas by "([^"]*)"$/) do |how|
6
+ @element = @page.send "canvas_#{how}_element"
7
+ end
8
+
9
+ Then(/^I should see that the canvas width is "([^"]*)"$/) do |width|
10
+ expect(@element.width).to eql width.to_i
11
+ end
12
+
13
+ Then(/^I should see that the canvas height is "([^"]*)"$/) do |height|
14
+ expect(@element.height).to eql height.to_i
15
+ end
16
+
17
+ When(/^I search for the canvas element by "([^"]*)" and "([^"]*)"$/) do |param1, param2|
18
+ @element = @page.send "canvas_#{param1}_#{param2}_element"
19
+ end
@@ -0,0 +1,39 @@
1
+ When(/^I select the First check box$/) do
2
+ @page.check_cb_id
3
+ end
4
+
5
+ Then(/^the First check box should be selected$/) do
6
+ expect(@page.cb_id_checked?).to be true
7
+ end
8
+
9
+ When(/^I unselect the First check box$/) do
10
+ @page.uncheck_cb_id
11
+ end
12
+
13
+ Then(/^the First check box should not be selected$/) do
14
+ expect(@page.cb_id_checked?).to be false
15
+ end
16
+
17
+ When(/^I locate the check box by "(.*?)"$/) do |how|
18
+ @how = how
19
+ end
20
+
21
+ Then(/^I should be able to check the check box$/) do
22
+ @page.send "check_cb_#{@how}".to_sym
23
+ end
24
+
25
+ When(/^I retrieve a check box element$/) do
26
+ @element = @page.cb_id_element
27
+ end
28
+
29
+ When(/^I search for the check box by "(.*?)" and "(.*?)"$/) do |param1, param2|
30
+ @how = "#{param1}_#{param2}"
31
+ end
32
+
33
+ When(/^I select the first check box while the script is executing$/) do
34
+ @page.checkbox_element(:id => "cb_id").check
35
+ end
36
+
37
+ Then(/^I should see that the checkbox exists$/) do
38
+ expect(@page.cb_id?).to be true
39
+ end
@@ -0,0 +1,28 @@
1
+ When(/^I get the text from the div$/) do
2
+ @text = @page.div_id
3
+ end
4
+
5
+ Then(/^the text should be "(.*?)"$/) do |expected_text|
6
+ expect(@text.tr("\n", ' ')).to eql expected_text
7
+ end
8
+
9
+ When(/^I locate the div by "(.*?)"$/) do |how|
10
+ @text = @page.send "div_#{how}".to_sym
11
+ end
12
+
13
+ When(/^I retrieve the div element$/) do
14
+ @element = @page.div_id_element
15
+ end
16
+
17
+ When(/^I search for the div by "(.*?)" and "(.*?)"$/) do |param1, param2|
18
+ @text = @page.send "div_#{param1}_#{param2}".to_sym
19
+ end
20
+
21
+
22
+ When(/^I get the text from a div while the script is executing$/) do
23
+ @text = @page.div_element(:id => 'div_id').text
24
+ end
25
+
26
+ Then(/^I should see that the div exists$/) do
27
+ expect(@page.div_id?).to be true
28
+ end