browserstack-webdriver 0.0.1

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.
Files changed (202) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +791 -0
  3. data/README.md +31 -0
  4. data/build.desc +334 -0
  5. data/lib/selenium-client.rb +2 -0
  6. data/lib/selenium-webdriver.rb +1 -0
  7. data/lib/selenium/client.rb +37 -0
  8. data/lib/selenium/client/base.rb +132 -0
  9. data/lib/selenium/client/driver.rb +10 -0
  10. data/lib/selenium/client/errors.rb +9 -0
  11. data/lib/selenium/client/extensions.rb +118 -0
  12. data/lib/selenium/client/idiomatic.rb +488 -0
  13. data/lib/selenium/client/javascript_expression_builder.rb +116 -0
  14. data/lib/selenium/client/javascript_frameworks/jquery.rb +13 -0
  15. data/lib/selenium/client/javascript_frameworks/prototype.rb +13 -0
  16. data/lib/selenium/client/legacy_driver.rb +1720 -0
  17. data/lib/selenium/client/protocol.rb +104 -0
  18. data/lib/selenium/client/selenium_helper.rb +34 -0
  19. data/lib/selenium/rake/server_task.rb +157 -0
  20. data/lib/selenium/server.rb +248 -0
  21. data/lib/selenium/webdriver.rb +71 -0
  22. data/lib/selenium/webdriver/android.rb +9 -0
  23. data/lib/selenium/webdriver/android/bridge.rb +47 -0
  24. data/lib/selenium/webdriver/chrome.rb +26 -0
  25. data/lib/selenium/webdriver/chrome/bridge.rb +120 -0
  26. data/lib/selenium/webdriver/chrome/profile.rb +90 -0
  27. data/lib/selenium/webdriver/chrome/service.rb +75 -0
  28. data/lib/selenium/webdriver/common.rb +44 -0
  29. data/lib/selenium/webdriver/common/action_builder.rb +352 -0
  30. data/lib/selenium/webdriver/common/alert.rb +30 -0
  31. data/lib/selenium/webdriver/common/bridge_helper.rb +67 -0
  32. data/lib/selenium/webdriver/common/core_ext/base64.rb +9 -0
  33. data/lib/selenium/webdriver/common/core_ext/dir.rb +42 -0
  34. data/lib/selenium/webdriver/common/core_ext/string.rb +5 -0
  35. data/lib/selenium/webdriver/common/driver.rb +301 -0
  36. data/lib/selenium/webdriver/common/driver_extensions/has_browser_connection.rb +17 -0
  37. data/lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb +39 -0
  38. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +25 -0
  39. data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +13 -0
  40. data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +22 -0
  41. data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +19 -0
  42. data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +22 -0
  43. data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +45 -0
  44. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +43 -0
  45. data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +46 -0
  46. data/lib/selenium/webdriver/common/element.rb +293 -0
  47. data/lib/selenium/webdriver/common/error.rb +207 -0
  48. data/lib/selenium/webdriver/common/file_reaper.rb +47 -0
  49. data/lib/selenium/webdriver/common/html5/local_storage.rb +42 -0
  50. data/lib/selenium/webdriver/common/html5/location.rb +0 -0
  51. data/lib/selenium/webdriver/common/html5/session_storage.rb +44 -0
  52. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +42 -0
  53. data/lib/selenium/webdriver/common/json_helper.rb +34 -0
  54. data/lib/selenium/webdriver/common/keyboard.rb +55 -0
  55. data/lib/selenium/webdriver/common/keys.rb +109 -0
  56. data/lib/selenium/webdriver/common/log_entry.rb +29 -0
  57. data/lib/selenium/webdriver/common/logs.rb +23 -0
  58. data/lib/selenium/webdriver/common/mouse.rb +72 -0
  59. data/lib/selenium/webdriver/common/navigation.rb +43 -0
  60. data/lib/selenium/webdriver/common/options.rb +136 -0
  61. data/lib/selenium/webdriver/common/platform.rb +218 -0
  62. data/lib/selenium/webdriver/common/port_prober.rb +42 -0
  63. data/lib/selenium/webdriver/common/profile_helper.rb +67 -0
  64. data/lib/selenium/webdriver/common/proxy.rb +149 -0
  65. data/lib/selenium/webdriver/common/search_context.rb +92 -0
  66. data/lib/selenium/webdriver/common/socket_poller.rb +105 -0
  67. data/lib/selenium/webdriver/common/target_locator.rb +81 -0
  68. data/lib/selenium/webdriver/common/timeouts.rb +38 -0
  69. data/lib/selenium/webdriver/common/touch_action_builder.rb +64 -0
  70. data/lib/selenium/webdriver/common/touch_screen.rb +105 -0
  71. data/lib/selenium/webdriver/common/wait.rb +63 -0
  72. data/lib/selenium/webdriver/common/window.rb +104 -0
  73. data/lib/selenium/webdriver/common/zipper.rb +82 -0
  74. data/lib/selenium/webdriver/firefox.rb +37 -0
  75. data/lib/selenium/webdriver/firefox/binary.rb +158 -0
  76. data/lib/selenium/webdriver/firefox/bridge.rb +70 -0
  77. data/lib/selenium/webdriver/firefox/extension.rb +52 -0
  78. data/lib/selenium/webdriver/firefox/launcher.rb +106 -0
  79. data/lib/selenium/webdriver/firefox/profile.rb +263 -0
  80. data/lib/selenium/webdriver/firefox/profiles_ini.rb +62 -0
  81. data/lib/selenium/webdriver/firefox/socket_lock.rb +61 -0
  82. data/lib/selenium/webdriver/firefox/util.rb +29 -0
  83. data/lib/selenium/webdriver/ie.rb +19 -0
  84. data/lib/selenium/webdriver/ie/bridge.rb +68 -0
  85. data/lib/selenium/webdriver/ie/server.rb +86 -0
  86. data/lib/selenium/webdriver/iphone.rb +9 -0
  87. data/lib/selenium/webdriver/iphone/bridge.rb +45 -0
  88. data/lib/selenium/webdriver/opera.rb +24 -0
  89. data/lib/selenium/webdriver/opera/bridge.rb +112 -0
  90. data/lib/selenium/webdriver/opera/service.rb +49 -0
  91. data/lib/selenium/webdriver/phantomjs.rb +22 -0
  92. data/lib/selenium/webdriver/phantomjs/bridge.rb +59 -0
  93. data/lib/selenium/webdriver/phantomjs/service.rb +90 -0
  94. data/lib/selenium/webdriver/remote.rb +22 -0
  95. data/lib/selenium/webdriver/remote/bridge.rb +644 -0
  96. data/lib/selenium/webdriver/remote/capabilities.rb +267 -0
  97. data/lib/selenium/webdriver/remote/commands.rb +193 -0
  98. data/lib/selenium/webdriver/remote/http/common.rb +74 -0
  99. data/lib/selenium/webdriver/remote/http/curb.rb +79 -0
  100. data/lib/selenium/webdriver/remote/http/default.rb +139 -0
  101. data/lib/selenium/webdriver/remote/http/persistent.rb +38 -0
  102. data/lib/selenium/webdriver/remote/response.rb +97 -0
  103. data/lib/selenium/webdriver/remote/server_error.rb +17 -0
  104. data/lib/selenium/webdriver/safari.rb +46 -0
  105. data/lib/selenium/webdriver/safari/bridge.rb +110 -0
  106. data/lib/selenium/webdriver/safari/browser.rb +20 -0
  107. data/lib/selenium/webdriver/safari/extension.rb +120 -0
  108. data/lib/selenium/webdriver/safari/server.rb +145 -0
  109. data/lib/selenium/webdriver/support.rb +5 -0
  110. data/lib/selenium/webdriver/support/abstract_event_listener.rb +28 -0
  111. data/lib/selenium/webdriver/support/block_event_listener.rb +17 -0
  112. data/lib/selenium/webdriver/support/color.rb +110 -0
  113. data/lib/selenium/webdriver/support/event_firing_bridge.rb +112 -0
  114. data/lib/selenium/webdriver/support/select.rb +293 -0
  115. data/ruby.iml +13 -0
  116. data/spec/integration/selenium/client/api/backward_compatible_api_spec.rb +22 -0
  117. data/spec/integration/selenium/client/api/browser_xpath_library_spec.rb +17 -0
  118. data/spec/integration/selenium/client/api/click_spec.rb +39 -0
  119. data/spec/integration/selenium/client/api/cookie_spec.rb +39 -0
  120. data/spec/integration/selenium/client/api/element_spec.rb +14 -0
  121. data/spec/integration/selenium/client/api/highlight_located_element_spec.rb +19 -0
  122. data/spec/integration/selenium/client/api/retrieve_last_remote_control_logs_spec.rb +33 -0
  123. data/spec/integration/selenium/client/api/screenshot_spec.rb +31 -0
  124. data/spec/integration/selenium/client/api/select_window_spec.rb +46 -0
  125. data/spec/integration/selenium/client/api/start_stop_spec.rb +9 -0
  126. data/spec/integration/selenium/client/api/wait_for_ajax_spec.rb +27 -0
  127. data/spec/integration/selenium/client/api/wait_for_element_spec.rb +56 -0
  128. data/spec/integration/selenium/client/api/wait_for_field_value_spec.rb +52 -0
  129. data/spec/integration/selenium/client/api/wait_for_text_spec.rb +98 -0
  130. data/spec/integration/selenium/client/api/webdriver_backed_spec.rb +21 -0
  131. data/spec/integration/selenium/client/sample-app/public/jquery-1.3.2.js +4376 -0
  132. data/spec/integration/selenium/client/sample-app/public/jquery.html +55 -0
  133. data/spec/integration/selenium/client/sample-app/public/prototype-1.6.0.3.js +4320 -0
  134. data/spec/integration/selenium/client/sample-app/public/prototype.html +59 -0
  135. data/spec/integration/selenium/client/sample-app/sample_app.rb +32 -0
  136. data/spec/integration/selenium/client/spec_helper.rb +139 -0
  137. data/spec/integration/selenium/webdriver/app_cache_spec.rb +47 -0
  138. data/spec/integration/selenium/webdriver/browser_connection_spec.rb +20 -0
  139. data/spec/integration/selenium/webdriver/chrome/driver_spec.rb +28 -0
  140. data/spec/integration/selenium/webdriver/chrome/profile_spec.rb +63 -0
  141. data/spec/integration/selenium/webdriver/driver_spec.rb +266 -0
  142. data/spec/integration/selenium/webdriver/element_spec.rb +191 -0
  143. data/spec/integration/selenium/webdriver/error_spec.rb +30 -0
  144. data/spec/integration/selenium/webdriver/firefox/driver_spec.rb +21 -0
  145. data/spec/integration/selenium/webdriver/firefox/profile_spec.rb +141 -0
  146. data/spec/integration/selenium/webdriver/keyboard_spec.rb +57 -0
  147. data/spec/integration/selenium/webdriver/location_spec.rb +29 -0
  148. data/spec/integration/selenium/webdriver/mouse_spec.rb +57 -0
  149. data/spec/integration/selenium/webdriver/navigation_spec.rb +46 -0
  150. data/spec/integration/selenium/webdriver/opera/driver_spec.rb +47 -0
  151. data/spec/integration/selenium/webdriver/options_spec.rb +77 -0
  152. data/spec/integration/selenium/webdriver/remote/driver_spec.rb +19 -0
  153. data/spec/integration/selenium/webdriver/remote/element_spec.rb +26 -0
  154. data/spec/integration/selenium/webdriver/spec_helper.rb +36 -0
  155. data/spec/integration/selenium/webdriver/spec_support.rb +12 -0
  156. data/spec/integration/selenium/webdriver/spec_support/guards.rb +110 -0
  157. data/spec/integration/selenium/webdriver/spec_support/helpers.rb +51 -0
  158. data/spec/integration/selenium/webdriver/spec_support/rack_server.rb +123 -0
  159. data/spec/integration/selenium/webdriver/spec_support/test_environment.rb +239 -0
  160. data/spec/integration/selenium/webdriver/sql_database_spec.rb +59 -0
  161. data/spec/integration/selenium/webdriver/storage_spec.rb +96 -0
  162. data/spec/integration/selenium/webdriver/target_locator_spec.rb +186 -0
  163. data/spec/integration/selenium/webdriver/timeout_spec.rb +69 -0
  164. data/spec/integration/selenium/webdriver/touch_spec.rb +176 -0
  165. data/spec/integration/selenium/webdriver/window_spec.rb +70 -0
  166. data/spec/integration/selenium/webdriver/zipper_spec.rb +66 -0
  167. data/spec/unit/selenium/client/base_spec.rb +239 -0
  168. data/spec/unit/selenium/client/extensions_spec.rb +174 -0
  169. data/spec/unit/selenium/client/idiomatic_spec.rb +500 -0
  170. data/spec/unit/selenium/client/javascript_expression_builder_spec.rb +79 -0
  171. data/spec/unit/selenium/client/javascript_frameworks/jquery_spec.rb +10 -0
  172. data/spec/unit/selenium/client/javascript_frameworks/prototype_spec.rb +10 -0
  173. data/spec/unit/selenium/client/protocol_spec.rb +124 -0
  174. data/spec/unit/selenium/client/selenium_helper_spec.rb +56 -0
  175. data/spec/unit/selenium/client/spec_helper.rb +24 -0
  176. data/spec/unit/selenium/rake/task_spec.rb +79 -0
  177. data/spec/unit/selenium/server_spec.rb +150 -0
  178. data/spec/unit/selenium/webdriver/action_builder_spec.rb +97 -0
  179. data/spec/unit/selenium/webdriver/android/bridge_spec.rb +43 -0
  180. data/spec/unit/selenium/webdriver/chrome/bridge_spec.rb +137 -0
  181. data/spec/unit/selenium/webdriver/chrome/profile_spec.rb +57 -0
  182. data/spec/unit/selenium/webdriver/chrome/service_spec.rb +44 -0
  183. data/spec/unit/selenium/webdriver/error_spec.rb +41 -0
  184. data/spec/unit/selenium/webdriver/firefox/bridge_spec.rb +47 -0
  185. data/spec/unit/selenium/webdriver/ie/bridge_spec.rb +91 -0
  186. data/spec/unit/selenium/webdriver/iphone/bridge_spec.rb +42 -0
  187. data/spec/unit/selenium/webdriver/log_entry_spec.rb +11 -0
  188. data/spec/unit/selenium/webdriver/opera/bridge_spec.rb +44 -0
  189. data/spec/unit/selenium/webdriver/phantomjs/bridge_spec.rb +55 -0
  190. data/spec/unit/selenium/webdriver/proxy_spec.rb +106 -0
  191. data/spec/unit/selenium/webdriver/remote/bridge_spec.rb +16 -0
  192. data/spec/unit/selenium/webdriver/remote/capabilities_spec.rb +115 -0
  193. data/spec/unit/selenium/webdriver/remote/http/common_spec.rb +24 -0
  194. data/spec/unit/selenium/webdriver/remote/http/default_spec.rb +124 -0
  195. data/spec/unit/selenium/webdriver/search_context_spec.rb +61 -0
  196. data/spec/unit/selenium/webdriver/socket_poller_spec.rb +68 -0
  197. data/spec/unit/selenium/webdriver/spec_helper.rb +27 -0
  198. data/spec/unit/selenium/webdriver/support/color_spec.rb +119 -0
  199. data/spec/unit/selenium/webdriver/support/event_firing_spec.rb +111 -0
  200. data/spec/unit/selenium/webdriver/support/select_spec.rb +290 -0
  201. data/spec/unit/selenium/webdriver/wait_spec.rb +49 -0
  202. metadata +370 -0
@@ -0,0 +1,290 @@
1
+ require File.expand_path("../../spec_helper", __FILE__)
2
+
3
+ module Selenium
4
+ module WebDriver
5
+ module Support
6
+
7
+ describe Select do
8
+ let(:select) {
9
+ double(Element, :tag_name => 'select')
10
+ }
11
+
12
+ let(:multi_select) {
13
+ s = double(Element, :tag_name => 'select')
14
+ s.stub(:attribute).with(:multiple).and_return "multiple"
15
+
16
+ s
17
+ }
18
+
19
+ it 'raises ArgumentError if passed a non-select Element' do
20
+ link = double(Element, :tag_name => "a")
21
+
22
+ lambda {
23
+ Select.new link
24
+ }.should raise_error(ArgumentError)
25
+ end
26
+
27
+ it 'indicates whether a select is multiple correctly' do
28
+ selects = [
29
+ double(Element, :tag_name => "select"),
30
+ double(Element, :tag_name => "select"),
31
+ double(Element, :tag_name => "select"),
32
+ double(Element, :tag_name => "select")
33
+ ]
34
+
35
+ selects[0].stub(:attribute).with(:multiple).and_return("false")
36
+ selects[1].stub(:attribute).with(:multiple).and_return(nil)
37
+ selects[2].stub(:attribute).with(:multiple).and_return("true")
38
+ selects[3].stub(:attribute).with(:multiple).and_return("multiple")
39
+
40
+ Select.new(selects[0]).should_not be_multiple
41
+ Select.new(selects[1]).should_not be_multiple
42
+ Select.new(selects[2]).should be_multiple
43
+ Select.new(selects[3]).should be_multiple
44
+ end
45
+
46
+ it 'returns all options' do
47
+ options = []
48
+
49
+ multi_select.should_receive(:find_elements).
50
+ with(:tag_name, 'option').
51
+ once.
52
+ and_return(options)
53
+
54
+ Select.new(multi_select).options.should eql(options)
55
+ end
56
+
57
+ it 'returns all selected options' do
58
+ bad_option = double(Element, :selected? => false)
59
+ good_option = double(Element, :selected? => true)
60
+
61
+ multi_select.should_receive(:find_elements).
62
+ with(:tag_name, 'option').
63
+ once.
64
+ and_return([bad_option, good_option])
65
+
66
+ opts = Select.new(multi_select).selected_options
67
+
68
+ opts.size.should == 1
69
+ opts.first.should == good_option
70
+ end
71
+
72
+ it 'returns the first selected option' do
73
+ first_option = double(Element, :selected? => true)
74
+ second_option = double(Element, :selected? => true)
75
+
76
+ multi_select.should_receive(:find_elements).
77
+ with(:tag_name, 'option').
78
+ once.
79
+ and_return([first_option, second_option])
80
+
81
+ option = Select.new(multi_select).first_selected_option
82
+ option.should == first_option
83
+ end
84
+
85
+ it 'raises a NoSuchElementError if nothing is selected' do
86
+ option = double(Element, :selected? => false)
87
+
88
+ multi_select.should_receive(:find_elements).
89
+ with(:tag_name, 'option').
90
+ once.
91
+ and_return([option])
92
+
93
+ lambda {
94
+ Select.new(multi_select).first_selected_option
95
+ }.should raise_error(Error::NoSuchElementError)
96
+ end
97
+
98
+ it 'allows options to be selected by visible text' do
99
+ option = double(Element, :selected? => false)
100
+
101
+ multi_select.should_receive(:find_elements).
102
+ with(:xpath, './/option[normalize-space(.) = "fish"]').
103
+ once.
104
+ and_return([option])
105
+
106
+ option.should_receive(:click).once
107
+
108
+ Select.new(multi_select).select_by(:text, 'fish')
109
+ end
110
+
111
+ it 'allows options to be selected by index' do
112
+ first_option = double(Element, :selected? => true)
113
+ second_option = double(Element, :selected? => false)
114
+
115
+ first_option.should_receive(:attribute).with(:index).and_return "0"
116
+ first_option.should_receive(:click).never
117
+
118
+ second_option.should_receive(:attribute).with(:index).and_return '1'
119
+ second_option.should_receive(:click).once
120
+
121
+ multi_select.should_receive(:find_elements).
122
+ with(:tag_name, 'option').
123
+ and_return([first_option, second_option])
124
+
125
+ Select.new(multi_select).select_by(:index, 1)
126
+ end
127
+
128
+ it 'allows options to be selected by returned value' do
129
+ first_option = double(Element, :selected? => false)
130
+ multi_select.should_receive(:find_elements).
131
+ with(:xpath, './/option[@value = "b"]').
132
+ and_return([first_option])
133
+
134
+ first_option.should_receive(:click).once
135
+
136
+ Select.new(multi_select).select_by(:value, 'b')
137
+ end
138
+
139
+ it 'can deselect all when select supports multiple selections' do
140
+ first_option = double(Element, :selected? => true)
141
+ second_option = double(Element, :selected? => false)
142
+
143
+ multi_select.should_receive(:find_elements).
144
+ with(:tag_name, 'option').
145
+ once.
146
+ and_return([first_option, second_option])
147
+
148
+ first_option.should_receive(:click).once
149
+ second_option.should_receive(:click).never
150
+
151
+ Select.new(multi_select).deselect_all
152
+ end
153
+
154
+ it 'can not deselect all when select does not support multiple selections' do
155
+ select.should_receive(:attribute).with(:multiple).and_return nil
156
+
157
+ lambda {
158
+ Select.new(select).deselect_all
159
+ }.should raise_error(Error::UnsupportedOperationError)
160
+ end
161
+
162
+ it 'can deselect options by visible text' do
163
+ first_option = double(Element, :selected? => true)
164
+ second_option = double(Element, :selected? => false)
165
+
166
+ multi_select.should_receive(:find_elements).
167
+ with(:xpath, './/option[normalize-space(.) = "b"]').
168
+ and_return([first_option, second_option])
169
+
170
+ first_option.should_receive(:click).once
171
+ second_option.should_receive(:click).never
172
+
173
+ Select.new(multi_select).deselect_by(:text, 'b')
174
+ end
175
+
176
+ it 'can deselect options by index' do
177
+ first_option = double(Element, :selected? => true)
178
+ second_option = double(Element)
179
+
180
+ multi_select.should_receive(:find_elements).
181
+ with(:tag_name, 'option').
182
+ and_return([first_option, second_option])
183
+
184
+ first_option.should_receive(:attribute).with(:index).and_return("2")
185
+ second_option.should_receive(:attribute).with(:index).and_return("1")
186
+
187
+ first_option.should_receive(:click).once
188
+ second_option.should_receive(:click).never
189
+
190
+ Select.new(multi_select).deselect_by(:index, 2)
191
+ end
192
+
193
+ it 'can deselect options by returned value' do
194
+ first_option = double(Element, :selected? => true)
195
+ second_option = double(Element, :selected? => false)
196
+
197
+ multi_select.should_receive(:find_elements).
198
+ with(:xpath, './/option[@value = "b"]').
199
+ and_return([first_option, second_option])
200
+
201
+ first_option.should_receive(:click).once
202
+ second_option.should_receive(:click).never
203
+
204
+ Select.new(multi_select).deselect_by(:value, 'b')
205
+ end
206
+
207
+ it 'should fall back to slow lookups when "get by visible text fails" and there is a space' do
208
+ first_option = double(Element, :selected? => false, :text => 'foo bar')
209
+ first_option.stub(:to_a => [first_option])
210
+
211
+ xpath1 = './/option[normalize-space(.) = "foo bar"]'
212
+ xpath2 = './/option[contains(., "foo")]'
213
+
214
+ select.should_receive(:attribute).with(:multiple).and_return 'false'
215
+ select.should_receive(:find_elements).with(:xpath, xpath1).once.and_return([])
216
+ select.should_receive(:find_elements).with(:xpath, xpath2).once.and_return([first_option])
217
+
218
+ first_option.should_receive(:click).once
219
+
220
+ Select.new(select).select_by(:text, 'foo bar')
221
+ end
222
+
223
+ it 'should raise NoSuchElementError if there are no selects to select' do
224
+ select.should_receive(:attribute).with(:multiple).and_return('false')
225
+ select.should_receive(:find_elements).at_least(3).times.and_return []
226
+
227
+ s = Select.new select
228
+
229
+ lambda {
230
+ s.select_by :index, 12
231
+ }.should raise_error(Error::NoSuchElementError)
232
+
233
+ lambda {
234
+ s.select_by :value, 'not there'
235
+ }.should raise_error(Error::NoSuchElementError)
236
+
237
+ lambda {
238
+ s.select_by :text, 'also not there'
239
+ }.should raise_error(Error::NoSuchElementError)
240
+ end
241
+
242
+ it 'should raise NoSuchElementError if there are no selects to deselect' do
243
+ select.should_receive(:attribute).with(:multiple).and_return('false')
244
+ select.should_receive(:find_elements).at_least(3).times.and_return []
245
+
246
+ s = Select.new select
247
+
248
+ lambda {
249
+ s.deselect_by :index, 12
250
+ }.should raise_error(Error::NoSuchElementError)
251
+
252
+ lambda {
253
+ s.deselect_by :value, 'not there'
254
+ }.should raise_error(Error::NoSuchElementError)
255
+
256
+ lambda {
257
+ s.deselect_by :text, 'also not there'
258
+ }.should raise_error(Error::NoSuchElementError)
259
+ end
260
+ end # Select
261
+
262
+ describe Select::Escaper do
263
+ it 'converts an unquoted string into one with quotes' do
264
+ Select::Escaper.escape('abc').should == '"abc"'
265
+ Select::Escaper.escape('abc aqewqqw').should == '"abc aqewqqw"'
266
+ Select::Escaper.escape('').should == '""'
267
+ Select::Escaper.escape(' ').should == '" "'
268
+ Select::Escaper.escape(' abc ').should == '" abc "'
269
+ end
270
+
271
+ it 'double quotes a string that contains a single quote' do
272
+ Select::Escaper.escape("f'oo").should == %{"f'oo"}
273
+ end
274
+
275
+ it 'single quotes a string that contains a double quote' do
276
+ Select::Escaper.escape('f"oo').should == %{'f"oo'}
277
+ end
278
+
279
+ it 'provides concatenated strings when string to escape contains both single and double quotes' do
280
+ Select::Escaper.escape(%{f"o'o}).should == %{concat("f", '"', "o'o")}
281
+ end
282
+
283
+ it 'provides concatenated strings when string ends with quote' do
284
+ Select::Escaper.escape(%{'"}).should == %{concat("'", '"')}
285
+ end
286
+ end # Select::Escaper
287
+
288
+ end # Support
289
+ end # WebDriver
290
+ end # Selenium
@@ -0,0 +1,49 @@
1
+ require File.expand_path("../spec_helper", __FILE__)
2
+
3
+ module Selenium
4
+ module WebDriver
5
+ describe Wait do
6
+
7
+ def wait(*args) Wait.new(*args) end
8
+
9
+ it 'should wait until the returned value is true' do
10
+ returned = true
11
+ wait.until { returned = !returned }.should be_true
12
+ end
13
+
14
+ it 'should raise a TimeOutError if the the timer runs out' do
15
+ lambda {
16
+ wait(:timeout => 0.1).until { false }
17
+ }.should raise_error(Error::TimeOutError)
18
+ end
19
+
20
+ it "should silently capture NoSuchElementErrors" do
21
+ called = false
22
+ block = lambda {
23
+ if called
24
+ true
25
+ else
26
+ called = true
27
+ raise Error::NoSuchElementError
28
+ end
29
+ }
30
+
31
+ wait.until(&block).should be_true
32
+ end
33
+
34
+ it "will use the message from any NoSuchElementError raised while waiting" do
35
+ block = lambda { raise Error::NoSuchElementError, "foo" }
36
+
37
+ lambda {
38
+ wait(:timeout => 0.5).until(&block)
39
+ }.should raise_error(Error::TimeOutError, /foo/)
40
+ end
41
+
42
+ it "should let users configure what exceptions to ignore" do
43
+ lambda {
44
+ wait(:ignore => NoMethodError, :timeout => 0.5).until { raise NoMethodError }
45
+ }.should raise_error(Error::TimeOutError, /NoMethodError/)
46
+ end
47
+ end
48
+ end
49
+ end
metadata ADDED
@@ -0,0 +1,370 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: browserstack-webdriver
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - BrowserStack
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: multi_json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: childprocess
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.2.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: websocket
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.4
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.4
55
+ - !ruby/object:Gem::Dependency
56
+ name: zipruby
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.3.6
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.3.6
69
+ - !ruby/object:Gem::Dependency
70
+ name: curb
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 0.8.5
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 0.8.5
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '2.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '2.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rack
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '1.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '1.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: ci_reporter
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 1.6.2
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: 1.6.2
125
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: 1.7.5
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: 1.7.5
139
+ description: Ruby bindings for selenium webdriver which supports keep-alive protocl
140
+ by default thus improving performance of remote tests.
141
+ email: support@browserstack.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - CHANGES
147
+ - README.md
148
+ - build.desc
149
+ - lib/selenium-client.rb
150
+ - lib/selenium-webdriver.rb
151
+ - lib/selenium/client.rb
152
+ - lib/selenium/client/base.rb
153
+ - lib/selenium/client/driver.rb
154
+ - lib/selenium/client/errors.rb
155
+ - lib/selenium/client/extensions.rb
156
+ - lib/selenium/client/idiomatic.rb
157
+ - lib/selenium/client/javascript_expression_builder.rb
158
+ - lib/selenium/client/javascript_frameworks/jquery.rb
159
+ - lib/selenium/client/javascript_frameworks/prototype.rb
160
+ - lib/selenium/client/legacy_driver.rb
161
+ - lib/selenium/client/protocol.rb
162
+ - lib/selenium/client/selenium_helper.rb
163
+ - lib/selenium/rake/server_task.rb
164
+ - lib/selenium/server.rb
165
+ - lib/selenium/webdriver.rb
166
+ - lib/selenium/webdriver/android.rb
167
+ - lib/selenium/webdriver/android/bridge.rb
168
+ - lib/selenium/webdriver/chrome.rb
169
+ - lib/selenium/webdriver/chrome/bridge.rb
170
+ - lib/selenium/webdriver/chrome/profile.rb
171
+ - lib/selenium/webdriver/chrome/service.rb
172
+ - lib/selenium/webdriver/common.rb
173
+ - lib/selenium/webdriver/common/action_builder.rb
174
+ - lib/selenium/webdriver/common/alert.rb
175
+ - lib/selenium/webdriver/common/bridge_helper.rb
176
+ - lib/selenium/webdriver/common/core_ext/base64.rb
177
+ - lib/selenium/webdriver/common/core_ext/dir.rb
178
+ - lib/selenium/webdriver/common/core_ext/string.rb
179
+ - lib/selenium/webdriver/common/driver.rb
180
+ - lib/selenium/webdriver/common/driver_extensions/has_browser_connection.rb
181
+ - lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb
182
+ - lib/selenium/webdriver/common/driver_extensions/has_location.rb
183
+ - lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb
184
+ - lib/selenium/webdriver/common/driver_extensions/has_session_id.rb
185
+ - lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb
186
+ - lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb
187
+ - lib/selenium/webdriver/common/driver_extensions/rotatable.rb
188
+ - lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb
189
+ - lib/selenium/webdriver/common/driver_extensions/uploads_files.rb
190
+ - lib/selenium/webdriver/common/element.rb
191
+ - lib/selenium/webdriver/common/error.rb
192
+ - lib/selenium/webdriver/common/file_reaper.rb
193
+ - lib/selenium/webdriver/common/html5/local_storage.rb
194
+ - lib/selenium/webdriver/common/html5/location.rb
195
+ - lib/selenium/webdriver/common/html5/session_storage.rb
196
+ - lib/selenium/webdriver/common/html5/shared_web_storage.rb
197
+ - lib/selenium/webdriver/common/json_helper.rb
198
+ - lib/selenium/webdriver/common/keyboard.rb
199
+ - lib/selenium/webdriver/common/keys.rb
200
+ - lib/selenium/webdriver/common/log_entry.rb
201
+ - lib/selenium/webdriver/common/logs.rb
202
+ - lib/selenium/webdriver/common/mouse.rb
203
+ - lib/selenium/webdriver/common/navigation.rb
204
+ - lib/selenium/webdriver/common/options.rb
205
+ - lib/selenium/webdriver/common/platform.rb
206
+ - lib/selenium/webdriver/common/port_prober.rb
207
+ - lib/selenium/webdriver/common/profile_helper.rb
208
+ - lib/selenium/webdriver/common/proxy.rb
209
+ - lib/selenium/webdriver/common/search_context.rb
210
+ - lib/selenium/webdriver/common/socket_poller.rb
211
+ - lib/selenium/webdriver/common/target_locator.rb
212
+ - lib/selenium/webdriver/common/timeouts.rb
213
+ - lib/selenium/webdriver/common/touch_action_builder.rb
214
+ - lib/selenium/webdriver/common/touch_screen.rb
215
+ - lib/selenium/webdriver/common/wait.rb
216
+ - lib/selenium/webdriver/common/window.rb
217
+ - lib/selenium/webdriver/common/zipper.rb
218
+ - lib/selenium/webdriver/firefox.rb
219
+ - lib/selenium/webdriver/firefox/binary.rb
220
+ - lib/selenium/webdriver/firefox/bridge.rb
221
+ - lib/selenium/webdriver/firefox/extension.rb
222
+ - lib/selenium/webdriver/firefox/launcher.rb
223
+ - lib/selenium/webdriver/firefox/profile.rb
224
+ - lib/selenium/webdriver/firefox/profiles_ini.rb
225
+ - lib/selenium/webdriver/firefox/socket_lock.rb
226
+ - lib/selenium/webdriver/firefox/util.rb
227
+ - lib/selenium/webdriver/ie.rb
228
+ - lib/selenium/webdriver/ie/bridge.rb
229
+ - lib/selenium/webdriver/ie/server.rb
230
+ - lib/selenium/webdriver/iphone.rb
231
+ - lib/selenium/webdriver/iphone/bridge.rb
232
+ - lib/selenium/webdriver/opera.rb
233
+ - lib/selenium/webdriver/opera/bridge.rb
234
+ - lib/selenium/webdriver/opera/service.rb
235
+ - lib/selenium/webdriver/phantomjs.rb
236
+ - lib/selenium/webdriver/phantomjs/bridge.rb
237
+ - lib/selenium/webdriver/phantomjs/service.rb
238
+ - lib/selenium/webdriver/remote.rb
239
+ - lib/selenium/webdriver/remote/bridge.rb
240
+ - lib/selenium/webdriver/remote/capabilities.rb
241
+ - lib/selenium/webdriver/remote/commands.rb
242
+ - lib/selenium/webdriver/remote/http/common.rb
243
+ - lib/selenium/webdriver/remote/http/curb.rb
244
+ - lib/selenium/webdriver/remote/http/default.rb
245
+ - lib/selenium/webdriver/remote/http/persistent.rb
246
+ - lib/selenium/webdriver/remote/response.rb
247
+ - lib/selenium/webdriver/remote/server_error.rb
248
+ - lib/selenium/webdriver/safari.rb
249
+ - lib/selenium/webdriver/safari/bridge.rb
250
+ - lib/selenium/webdriver/safari/browser.rb
251
+ - lib/selenium/webdriver/safari/extension.rb
252
+ - lib/selenium/webdriver/safari/server.rb
253
+ - lib/selenium/webdriver/support.rb
254
+ - lib/selenium/webdriver/support/abstract_event_listener.rb
255
+ - lib/selenium/webdriver/support/block_event_listener.rb
256
+ - lib/selenium/webdriver/support/color.rb
257
+ - lib/selenium/webdriver/support/event_firing_bridge.rb
258
+ - lib/selenium/webdriver/support/select.rb
259
+ - ruby.iml
260
+ - spec/integration/selenium/client/api/backward_compatible_api_spec.rb
261
+ - spec/integration/selenium/client/api/browser_xpath_library_spec.rb
262
+ - spec/integration/selenium/client/api/click_spec.rb
263
+ - spec/integration/selenium/client/api/cookie_spec.rb
264
+ - spec/integration/selenium/client/api/element_spec.rb
265
+ - spec/integration/selenium/client/api/highlight_located_element_spec.rb
266
+ - spec/integration/selenium/client/api/retrieve_last_remote_control_logs_spec.rb
267
+ - spec/integration/selenium/client/api/screenshot_spec.rb
268
+ - spec/integration/selenium/client/api/select_window_spec.rb
269
+ - spec/integration/selenium/client/api/start_stop_spec.rb
270
+ - spec/integration/selenium/client/api/wait_for_ajax_spec.rb
271
+ - spec/integration/selenium/client/api/wait_for_element_spec.rb
272
+ - spec/integration/selenium/client/api/wait_for_field_value_spec.rb
273
+ - spec/integration/selenium/client/api/wait_for_text_spec.rb
274
+ - spec/integration/selenium/client/api/webdriver_backed_spec.rb
275
+ - spec/integration/selenium/client/sample-app/public/jquery-1.3.2.js
276
+ - spec/integration/selenium/client/sample-app/public/jquery.html
277
+ - spec/integration/selenium/client/sample-app/public/prototype-1.6.0.3.js
278
+ - spec/integration/selenium/client/sample-app/public/prototype.html
279
+ - spec/integration/selenium/client/sample-app/sample_app.rb
280
+ - spec/integration/selenium/client/spec_helper.rb
281
+ - spec/integration/selenium/webdriver/app_cache_spec.rb
282
+ - spec/integration/selenium/webdriver/browser_connection_spec.rb
283
+ - spec/integration/selenium/webdriver/chrome/driver_spec.rb
284
+ - spec/integration/selenium/webdriver/chrome/profile_spec.rb
285
+ - spec/integration/selenium/webdriver/driver_spec.rb
286
+ - spec/integration/selenium/webdriver/element_spec.rb
287
+ - spec/integration/selenium/webdriver/error_spec.rb
288
+ - spec/integration/selenium/webdriver/firefox/driver_spec.rb
289
+ - spec/integration/selenium/webdriver/firefox/profile_spec.rb
290
+ - spec/integration/selenium/webdriver/keyboard_spec.rb
291
+ - spec/integration/selenium/webdriver/location_spec.rb
292
+ - spec/integration/selenium/webdriver/mouse_spec.rb
293
+ - spec/integration/selenium/webdriver/navigation_spec.rb
294
+ - spec/integration/selenium/webdriver/opera/driver_spec.rb
295
+ - spec/integration/selenium/webdriver/options_spec.rb
296
+ - spec/integration/selenium/webdriver/remote/driver_spec.rb
297
+ - spec/integration/selenium/webdriver/remote/element_spec.rb
298
+ - spec/integration/selenium/webdriver/spec_helper.rb
299
+ - spec/integration/selenium/webdriver/spec_support.rb
300
+ - spec/integration/selenium/webdriver/spec_support/guards.rb
301
+ - spec/integration/selenium/webdriver/spec_support/helpers.rb
302
+ - spec/integration/selenium/webdriver/spec_support/rack_server.rb
303
+ - spec/integration/selenium/webdriver/spec_support/test_environment.rb
304
+ - spec/integration/selenium/webdriver/sql_database_spec.rb
305
+ - spec/integration/selenium/webdriver/storage_spec.rb
306
+ - spec/integration/selenium/webdriver/target_locator_spec.rb
307
+ - spec/integration/selenium/webdriver/timeout_spec.rb
308
+ - spec/integration/selenium/webdriver/touch_spec.rb
309
+ - spec/integration/selenium/webdriver/window_spec.rb
310
+ - spec/integration/selenium/webdriver/zipper_spec.rb
311
+ - spec/unit/selenium/client/base_spec.rb
312
+ - spec/unit/selenium/client/extensions_spec.rb
313
+ - spec/unit/selenium/client/idiomatic_spec.rb
314
+ - spec/unit/selenium/client/javascript_expression_builder_spec.rb
315
+ - spec/unit/selenium/client/javascript_frameworks/jquery_spec.rb
316
+ - spec/unit/selenium/client/javascript_frameworks/prototype_spec.rb
317
+ - spec/unit/selenium/client/protocol_spec.rb
318
+ - spec/unit/selenium/client/selenium_helper_spec.rb
319
+ - spec/unit/selenium/client/spec_helper.rb
320
+ - spec/unit/selenium/rake/task_spec.rb
321
+ - spec/unit/selenium/server_spec.rb
322
+ - spec/unit/selenium/webdriver/action_builder_spec.rb
323
+ - spec/unit/selenium/webdriver/android/bridge_spec.rb
324
+ - spec/unit/selenium/webdriver/chrome/bridge_spec.rb
325
+ - spec/unit/selenium/webdriver/chrome/profile_spec.rb
326
+ - spec/unit/selenium/webdriver/chrome/service_spec.rb
327
+ - spec/unit/selenium/webdriver/error_spec.rb
328
+ - spec/unit/selenium/webdriver/firefox/bridge_spec.rb
329
+ - spec/unit/selenium/webdriver/ie/bridge_spec.rb
330
+ - spec/unit/selenium/webdriver/iphone/bridge_spec.rb
331
+ - spec/unit/selenium/webdriver/log_entry_spec.rb
332
+ - spec/unit/selenium/webdriver/opera/bridge_spec.rb
333
+ - spec/unit/selenium/webdriver/phantomjs/bridge_spec.rb
334
+ - spec/unit/selenium/webdriver/proxy_spec.rb
335
+ - spec/unit/selenium/webdriver/remote/bridge_spec.rb
336
+ - spec/unit/selenium/webdriver/remote/capabilities_spec.rb
337
+ - spec/unit/selenium/webdriver/remote/http/common_spec.rb
338
+ - spec/unit/selenium/webdriver/remote/http/default_spec.rb
339
+ - spec/unit/selenium/webdriver/search_context_spec.rb
340
+ - spec/unit/selenium/webdriver/socket_poller_spec.rb
341
+ - spec/unit/selenium/webdriver/spec_helper.rb
342
+ - spec/unit/selenium/webdriver/support/color_spec.rb
343
+ - spec/unit/selenium/webdriver/support/event_firing_spec.rb
344
+ - spec/unit/selenium/webdriver/support/select_spec.rb
345
+ - spec/unit/selenium/webdriver/wait_spec.rb
346
+ homepage: https://github.com/browserstack/selenium-webdriver-ruby
347
+ licenses: []
348
+ metadata: {}
349
+ post_install_message:
350
+ rdoc_options: []
351
+ require_paths:
352
+ - lib
353
+ - test
354
+ required_ruby_version: !ruby/object:Gem::Requirement
355
+ requirements:
356
+ - - '>='
357
+ - !ruby/object:Gem::Version
358
+ version: '0'
359
+ required_rubygems_version: !ruby/object:Gem::Requirement
360
+ requirements:
361
+ - - '>='
362
+ - !ruby/object:Gem::Version
363
+ version: '0'
364
+ requirements: []
365
+ rubyforge_project:
366
+ rubygems_version: 2.1.10
367
+ signing_key:
368
+ specification_version: 4
369
+ summary: Ruby bindings for selenium webdriver with support for keep-alive
370
+ test_files: []