watir 6.7.3 → 6.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/CHANGES.md +11 -0
  4. data/lib/watir.rb +4 -1
  5. data/lib/watir/adjacent.rb +1 -1
  6. data/lib/watir/browser.rb +5 -3
  7. data/lib/watir/capabilities.rb +1 -0
  8. data/lib/watir/container.rb +1 -1
  9. data/lib/watir/elements/element.rb +31 -98
  10. data/lib/watir/elements/file_field.rb +1 -1
  11. data/lib/watir/elements/iframe.rb +1 -1
  12. data/lib/watir/elements/image.rb +1 -5
  13. data/lib/watir/elements/input.rb +15 -0
  14. data/lib/watir/elements/radio.rb +17 -0
  15. data/lib/watir/elements/select.rb +67 -20
  16. data/lib/watir/js_execution.rb +141 -0
  17. data/lib/watir/js_snippets.rb +16 -0
  18. data/lib/watir/js_snippets/backgroundColor.js +7 -0
  19. data/lib/watir/{atoms → js_snippets}/fireEvent.js +2 -0
  20. data/lib/watir/js_snippets/focus.js +3 -0
  21. data/lib/watir/{atoms → js_snippets}/getInnerHtml.js +1 -0
  22. data/lib/watir/js_snippets/getInnerText.js +19 -0
  23. data/lib/watir/{atoms → js_snippets}/getOuterHtml.js +2 -0
  24. data/lib/watir/js_snippets/getTextContent.js +19 -0
  25. data/lib/watir/js_snippets/isImageLoaded.js +3 -0
  26. data/lib/watir/js_snippets/selectOptionsLabel.js +10 -0
  27. data/lib/watir/js_snippets/selectOptionsText.js +10 -0
  28. data/lib/watir/js_snippets/selectOptionsValue.js +10 -0
  29. data/lib/watir/{atoms → js_snippets}/selectText.js +3 -0
  30. data/lib/watir/js_snippets/selectedOptions.js +11 -0
  31. data/lib/watir/js_snippets/setValue.js +3 -0
  32. data/lib/watir/locators/element/locator.rb +24 -10
  33. data/lib/watir/radio_set.rb +231 -0
  34. data/lib/watir/user_editable.rb +16 -2
  35. data/lib/watirspec/remote_server.rb +2 -1
  36. data/spec/browser_spec.rb +8 -2
  37. data/spec/spec_helper.rb +1 -0
  38. data/spec/watirspec/elements/div_spec.rb +22 -0
  39. data/spec/watirspec/elements/divs_spec.rb +1 -1
  40. data/spec/watirspec/elements/element_spec.rb +24 -7
  41. data/spec/watirspec/elements/labels_spec.rb +1 -1
  42. data/spec/watirspec/elements/radio_spec.rb +17 -3
  43. data/spec/watirspec/elements/radios_spec.rb +1 -1
  44. data/spec/watirspec/elements/select_list_spec.rb +167 -65
  45. data/spec/watirspec/elements/text_field_spec.rb +36 -0
  46. data/spec/watirspec/html/forms_with_input_elements.html +4 -2
  47. data/spec/watirspec/html/non_control_elements.html +1 -1
  48. data/spec/watirspec/radio_set_spec.rb +340 -0
  49. data/spec/watirspec_helper.rb +14 -1
  50. data/support/doctest_helper.rb +11 -8
  51. data/watir.gemspec +2 -2
  52. metadata +30 -11
  53. data/lib/watir/atoms.rb +0 -22
  54. data/lib/watir/atoms/README +0 -3
  55. data/lib/watir/extensions/select_text.rb +0 -11
@@ -301,4 +301,40 @@ describe "TextField" do
301
301
  expect { browser.text_field(id: "no_such_id").set('secret') }.to raise_unknown_object_exception
302
302
  end
303
303
  end
304
+
305
+ describe "#set!" do
306
+ it "sets the value of the element" do
307
+ browser.text_field(id: 'new_user_email').set!('Bye Cruel World')
308
+ expect(browser.text_field(id: "new_user_email").value).to eq 'Bye Cruel World'
309
+ end
310
+
311
+ it "sets the value of a textarea element" do
312
+ browser.textarea(id: 'delete_user_comment').set!('Hello Cruel World')
313
+ expect(browser.textarea(id: "delete_user_comment").value).to eq 'Hello Cruel World'
314
+ end
315
+
316
+ it "fires events" do
317
+ browser.text_field(id: "new_user_username").set!("Hello World")
318
+ expect(browser.span(id: "current_length").text).to eq "11"
319
+ end
320
+
321
+ it "sets the value of a password field" do
322
+ browser.text_field(name: 'new_user_password').set!('secret')
323
+ expect(browser.text_field(name: 'new_user_password').value).to eq 'secret'
324
+ end
325
+
326
+ it "sets the value when accessed through the enclosing Form" do
327
+ browser.form(id: 'new_user').text_field(name: 'new_user_password').set!('secret')
328
+ expect(browser.form(id: 'new_user').text_field(name: 'new_user_password').value).to eq 'secret'
329
+ end
330
+
331
+ it "is able to set multi-byte characters" do
332
+ browser.text_field(name: "new_user_occupation").set!("ijij")
333
+ expect(browser.text_field(name: "new_user_occupation").value).to eq "ijij"
334
+ end
335
+
336
+ it "raises UnknownObjectException if the text field doesn't exist" do
337
+ expect { browser.text_field(id: "no_such_id").set!('secret') }.to raise_unknown_object_exception
338
+ end
339
+ end
304
340
  end
@@ -49,8 +49,8 @@
49
49
  <label for="new_user_languages">Languages</label>
50
50
  <select name="new_user_languages" id="new_user_languages" multiple="multiple" onchange="WatirSpec.addMessage('changed language');">
51
51
  <option id="danish" value="1">Danish</option>
52
- <option selected="selected" value="2">English</option>
53
- <option selected="selected" value="3">Norwegian</option>
52
+ <option selected="selected" value="2" label="EN">English</option>
53
+ <option selected="selected" value="3" label="NO">Norwegian</option>
54
54
  <option value="4" disabled>Russian</option>
55
55
  <option>Swedish</option>
56
56
  </select> <br />
@@ -115,6 +115,8 @@
115
115
  <label for="new_user_newsletter_probably">Probably</label>
116
116
  <input type="radio" name="new_user_newsletter" id="new_user_newsletter_nah" value="nah" disabled="disabled" />
117
117
  <label for="new_user_newsletter_nah">Nah</label>
118
+ <input type="radio" id="new_user_newsletter_none" value="none" disabled="disabled" />
119
+ <label for="new_user_newsletter_none">None</label>
118
120
  </fieldset>
119
121
  <fieldset>
120
122
  <legend>Actions</legend>
@@ -110,7 +110,7 @@
110
110
  <span class="footer" onclick="this.innerHTML = 'This is a footer with text set by Javascript.'">This is a footer.</span>
111
111
  </div>
112
112
  <a href="strip_space ">Space should be stripped from href</a>
113
- <div id="hidden" style="display: none;">Not shown</div>
113
+ <div id="shown"><div id="hidden" style="display: none;">Not shown</div><div>Not hidden</div></div>
114
114
  </div>
115
115
 
116
116
  <div id="messages"></div>
@@ -0,0 +1,340 @@
1
+ require "watirspec_helper"
2
+
3
+ describe "RadioSet" do
4
+
5
+ before :each do
6
+ browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
7
+ end
8
+
9
+ # Exists method
10
+ describe "#exists?" do
11
+ it "returns true if matches any radio_set button" do
12
+ expect(browser.radio_set(id: "new_user_newsletter_yes")).to exist
13
+ expect(browser.radio_set(id: /new_user_newsletter_yes/)).to exist
14
+ expect(browser.radio_set(name: "new_user_newsletter")).to exist
15
+ expect(browser.radio_set(name: /new_user_newsletter/)).to exist
16
+ expect(browser.radio_set(value: "yes")).to exist
17
+ expect(browser.radio_set(value: /yes/)).to exist
18
+ expect(browser.radio_set(class: "huge")).to exist
19
+ expect(browser.radio_set(class: /huge/)).to exist
20
+ expect(browser.radio_set(index: 0)).to exist
21
+ expect(browser.radio_set(xpath: "//input[@id='new_user_newsletter_yes']")).to exist
22
+ end
23
+
24
+ it "returns false if no radio button exists" do
25
+ expect(browser.radio_set(id: "no_such_id")).to_not exist
26
+ expect(browser.radio_set(id: /no_such_id/)).to_not exist
27
+ expect(browser.radio_set(name: "no_such_name")).to_not exist
28
+ expect(browser.radio_set(name: /no_such_name/)).to_not exist
29
+ expect(browser.radio_set(value: "no_such_value")).to_not exist
30
+ expect(browser.radio_set(value: /no_such_value/)).to_not exist
31
+ expect(browser.radio_set(text: "no_such_text")).to_not exist
32
+ expect(browser.radio_set(text: /no_such_text/)).to_not exist
33
+ expect(browser.radio_set(class: "no_such_class")).to_not exist
34
+ expect(browser.radio_set(class: /no_such_class/)).to_not exist
35
+ expect(browser.radio_set(index: 1337)).to_not exist
36
+ expect(browser.radio_set(xpath: "input[@id='no_such_id']")).to_not exist
37
+ end
38
+
39
+ it "returns the first radio set if given no args" do
40
+ expect(browser.radio_set).to exist
41
+ end
42
+
43
+ it "raises TypeError when 'what' argument is invalid" do
44
+ expect { browser.radio_set(id: 3.14).exists? }.to raise_error(TypeError)
45
+ end
46
+
47
+ it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
48
+ expect { browser.radio_set(no_such_how: 'some_value').exists? }.to raise_error(Watir::Exception::MissingWayOfFindingObjectException)
49
+ end
50
+ end
51
+
52
+ # Attribute methods
53
+ describe "#name" do
54
+ it "returns the name attribute if the radio exists" do
55
+ expect(browser.radio_set(id: 'new_user_newsletter_yes').name).to eq "new_user_newsletter"
56
+ end
57
+
58
+ it "returns an empty string if the radio exists and there is not name" do
59
+ expect(browser.radio_set(id: 'new_user_newsletter_absolutely').name).to eq ""
60
+ end
61
+
62
+ it "raises UnknownObjectException if the radio doesn't exist" do
63
+ expect { browser.radio_set(index: 1337).name }.to raise_unknown_object_exception
64
+ end
65
+ end
66
+
67
+ context "without name specified" do
68
+ it "Finds specified radio" do
69
+ expect(browser.radio_set(id: 'new_user_newsletter_absolutely').count).to eq 1
70
+ expect(browser.radio_set(id: 'new_user_newsletter_absolutely').radios.size).to eq 1
71
+ expect(browser.radio_set(id: 'new_user_newsletter_absolutely').radio(value: 'absolutely').exist?).to be true
72
+ end
73
+ end
74
+
75
+ describe "#type" do
76
+ it "returns the type attribute if the radio set exists" do
77
+ expect(browser.radio_set.type).to eq "radio"
78
+ end
79
+
80
+ it "raises UnknownObjectException if the radio doesn't exist" do
81
+ expect { browser.radio_set(index: 1337).type }.to raise_unknown_object_exception
82
+ end
83
+ end
84
+
85
+ describe "#value" do
86
+ it "returns the value attributes of the selected radio button" do
87
+ expect(browser.radio_set(id: 'new_user_newsletter_yes').value).to eq 'yes'
88
+ end
89
+
90
+ it "raises UnknownObjectException if the radio doesn't exist" do
91
+ expect { browser.radio_set(index: 1337).value }.to raise_unknown_object_exception
92
+ end
93
+ end
94
+
95
+ describe "#text" do
96
+ it "returns the text of the selected radio button" do
97
+ expect(browser.radio_set(id: 'new_user_newsletter_yes').text).to eq 'Yes'
98
+ end
99
+
100
+ it "raises UnknownObjectException if the radio set doesn't exist" do
101
+ expect { browser.radio_set(index: 1337).text }.to raise_unknown_object_exception
102
+ end
103
+ end
104
+
105
+ describe "#respond_to?" do
106
+ it "returns true for all attribute methods" do
107
+ expect(browser.radio_set(index: 0)).to_not respond_to(:class_name)
108
+ expect(browser.radio_set(index: 0)).to_not respond_to(:id)
109
+ expect(browser.radio_set(index: 0)).to respond_to(:name)
110
+ expect(browser.radio_set(index: 0)).to_not respond_to(:title)
111
+ expect(browser.radio_set(index: 0)).to respond_to(:type)
112
+ expect(browser.radio_set(index: 0)).to respond_to(:value)
113
+ expect(browser.radio_set(index: 0)).to respond_to(:text)
114
+ expect(browser.radio_set(index: 0)).to_not respond_to(:clear)
115
+ end
116
+ end
117
+
118
+ # Access methods
119
+ describe "#enabled?" do
120
+ it "returns true if any radio button in the set is enabled" do
121
+ expect(browser.radio_set(id: "new_user_newsletter_nah")).to be_enabled
122
+ expect(browser.radio_set(xpath: "//input[@id='new_user_newsletter_nah']")).to be_enabled
123
+ end
124
+
125
+ it "returns false if all radio buttons are disabled" do
126
+ expect(browser.radio_set(id: "new_user_newsletter_none")).to_not be_enabled
127
+ expect(browser.radio_set(xpath: "//input[@id='new_user_newsletter_none']")).to_not be_enabled
128
+ end
129
+
130
+ it "raises UnknownObjectException if the radio button doesn't exist" do
131
+ expect { browser.radio_set(id: "no_such_id").enabled? }.to raise_unknown_object_exception
132
+ expect { browser.radio_set(xpath: "//input[@id='no_such_id']").enabled? }.to raise_unknown_object_exception
133
+ end
134
+ end
135
+
136
+ describe "#disabled?" do
137
+ it "returns false if the any radio button in the set is enabled" do
138
+ expect(browser.radio_set(id: "new_user_newsletter_nah")).to_not be_disabled
139
+ expect(browser.radio_set(xpath: "//input[@id='new_user_newsletter_nah']")).to_not be_disabled
140
+ end
141
+
142
+ it "returns true if all radio buttons are disabled" do
143
+ expect(browser.radio_set(id: "new_user_newsletter_none")).to be_disabled
144
+ expect(browser.radio_set(xpath: "//input[@id='new_user_newsletter_none']")).to be_disabled
145
+ end
146
+
147
+ it "should raise UnknownObjectException when the radio set does not exist" do
148
+ expect { browser.radio_set(index: 1337).disabled? }.to raise_unknown_object_exception
149
+ end
150
+ end
151
+
152
+ # Other
153
+ describe "#radio" do
154
+ it "returns first instance of Radio if no arguments specified" do
155
+ radio = browser.radio_set(id: 'new_user_newsletter_yes').radio
156
+ expect(radio).to be_instance_of(Watir::Radio)
157
+ expect(radio.value).to eq "yes"
158
+ end
159
+
160
+ it "returns provided instance of Radio if element has no name" do
161
+ radio = browser.radio_set(id: 'new_user_newsletter_absolutely').radio
162
+ expect(radio).to be_instance_of(Watir::Radio)
163
+ expect(radio.value).to eq "absolutely"
164
+ end
165
+
166
+ it "returns an instance of Radio matching the provided value" do
167
+ radio = browser.radio_set(id: 'new_user_newsletter_yes').radio(id: 'new_user_newsletter_no')
168
+ expect(radio).to be_instance_of(Watir::Radio)
169
+ expect(radio.value).to eq "no"
170
+ end
171
+
172
+ it "does not exist when using bad locator" do
173
+ radio = browser.radio_set(id: 'new_user_newsletter_yes').radio(id: 'new_user_newsletter_not_there')
174
+ expect(radio).to_not exist
175
+ end
176
+
177
+ it "raises Unknown Object Exception if it specifies the wrong name" do
178
+ radio_set = browser.radio_set(id: 'new_user_newsletter_yes')
179
+ expect { radio_set.radio(name: '') }.to raise_unknown_object_exception
180
+ expect { radio_set.radio(name: 'foo') }.to raise_unknown_object_exception
181
+ end
182
+ end
183
+
184
+ describe "#radios" do
185
+ it "returns array of all radios in the set if no arguments specified" do
186
+ radios = browser.radio_set(id: 'new_user_newsletter_yes').radios
187
+ expect(radios).to be_instance_of(Watir::RadioCollection)
188
+ values = %w[yes no certainly nah nah]
189
+ expect(radios.map(&:value)).to match_array values
190
+ end
191
+
192
+ it "returns RadioCollection matching the provided value" do
193
+ radios = browser.radio_set(id: 'new_user_newsletter_yes').radios(id: /new_user_newsletter_n/)
194
+ expect(radios).to be_instance_of(Watir::RadioCollection)
195
+ expect(radios.map(&:value)).to eq %w[no nah]
196
+ end
197
+
198
+ it "returns provided instance of Radio if element has no name" do
199
+ radios = browser.radio_set(id: 'new_user_newsletter_absolutely').radios
200
+ expect(radios).to be_instance_of(Watir::RadioCollection)
201
+ expect(radios.size).to eq 1
202
+ expect(radios.first.value).to eq "absolutely"
203
+ end
204
+
205
+ it "returns empty collection if specified radio does not exist" do
206
+ radios = browser.radio_set(id: 'new_user_newsletter_yes').radios(id: 'new_user_newsletter_not_there')
207
+ expect(radios).to be_empty
208
+ end
209
+
210
+ it "raises empty collection if it specifies the wrong name" do
211
+ radio_set = browser.radio_set(id: 'new_user_newsletter_yes')
212
+ expect { radio_set.radios(name: '') }.to raise_unknown_object_exception
213
+ end
214
+ end
215
+
216
+
217
+ describe "#selected" do
218
+ it "should raise UnknownObjectException if the radio set doesn't exist" do
219
+ expect { browser.radio_set(name: 'no_such_name').selected }.to raise_unknown_object_exception
220
+ end
221
+
222
+ it "gets the currently selected radio" do
223
+ expect(browser.radio_set(id: 'new_user_newsletter_no').selected.text).to eq 'Yes'
224
+ expect(browser.radio_set(id: 'new_user_newsletter_no').selected.value).to eq 'yes'
225
+ end
226
+ end
227
+
228
+ describe "#include?" do
229
+ it "returns true if the given radio exists by text" do
230
+ expect(browser.radio_set(id: 'new_user_newsletter_no')).to include('Yes')
231
+ end
232
+
233
+ it "returns false if the given option doesn't exist" do
234
+ expect(browser.radio_set(id: 'new_user_newsletter_no')).to_not include('Mother')
235
+ end
236
+ end
237
+
238
+ describe "#selected?" do
239
+ it "returns true if the given option is selected by text" do
240
+ browser.radio_set(id: 'new_user_newsletter_yes').select('No')
241
+ expect(browser.radio_set(id: 'new_user_newsletter_yes')).to be_selected('No')
242
+ end
243
+
244
+ it "returns false if the given option is not selected by text" do
245
+ expect(browser.radio_set(id: 'new_user_newsletter_yes')).to_not be_selected('Probably')
246
+ end
247
+
248
+ it "raises UnknownObjectException if the radio button doesn't exist" do
249
+ expect { browser.radio_set(id: 'new_user_newsletter_yes').selected?('missing_option') }.to raise_unknown_object_exception
250
+ end
251
+ end
252
+
253
+ describe "#select" do
254
+ context "when interacting with radios" do
255
+ it "selects radio text by String" do
256
+ browser.radio_set(id: 'new_user_newsletter_yes').select("Probably")
257
+ expect(browser.radio_set(id: 'new_user_newsletter_yes').selected.text).to eq 'Probably'
258
+ end
259
+
260
+ it "selects radio text by Regexp" do
261
+ browser.radio_set(id: 'new_user_newsletter_yes').select(/Prob/)
262
+ expect(browser.radio_set(id: 'new_user_newsletter_yes').selected.text).to eq 'Probably'
263
+ end
264
+
265
+ it "selects the radio text when given an Xpath" do
266
+ browser.radio_set(xpath: "//input[@id='new_user_newsletter_no']").select("Probably")
267
+ expect(browser.radio_set(xpath: "//input[@id='new_user_newsletter_no']").selected.text).to eq 'Probably'
268
+ end
269
+
270
+ it "selects radio value by string" do
271
+ browser.radio_set(id: 'new_user_newsletter_yes').select("no")
272
+ expect(browser.radio_set(id: 'new_user_newsletter_yes').selected.text).to eq 'No'
273
+ end
274
+
275
+ it "selects radio value by regexp" do
276
+ browser.radio_set(id: 'new_user_newsletter_yes').select(/nah/)
277
+ expect(browser.radio_set(id: 'new_user_newsletter_yes').selected.text).to eq 'Probably'
278
+ end
279
+ end
280
+
281
+ it "returns the value selected" do
282
+ expect(browser.radio_set(id: 'new_user_newsletter_yes').select("no")).to eq "no"
283
+ end
284
+
285
+ it "fires onchange event when selecting a radio" do
286
+ browser.radio_set(id: 'new_user_newsletter_yes').radio(value: 'certainly').set
287
+ expect(messages).to eq ["changed: new_user_newsletter"]
288
+
289
+ browser.radio_set(id: 'new_user_newsletter_yes').radio(value: 'certainly').set
290
+ expect(messages).to eq ["changed: new_user_newsletter"] # no event fired here - didn't change
291
+
292
+ browser.radio_set(id: 'new_user_newsletter_yes').radio(value: 'yes').set
293
+ browser.radio_set(id: 'new_user_newsletter_yes').radio(value: 'certainly').set
294
+ expect(messages).to eq ["changed: new_user_newsletter", "clicked: new_user_newsletter_yes", "changed: new_user_newsletter"]
295
+ end
296
+
297
+ it "doesn't fire onchange event when selecting an already selected radio" do
298
+ browser.radio_set(id: 'new_user_newsletter_yes').radio(value: 'no').set
299
+
300
+ browser.radio_set(id: 'new_user_newsletter_yes').radio(value: 'no').set
301
+ expect(messages.size).to eq 1
302
+
303
+ browser.radio_set(id: 'new_user_newsletter_yes').radio(value: 'no').set
304
+ expect(messages.size).to eq 1
305
+ end
306
+ end
307
+
308
+ describe "#eql?" do
309
+ it 'returns true when located by any radio button' do
310
+ rs = browser.radio_set(id: "new_user_newsletter_yes")
311
+ expect(browser.radio_set(id: /new_user_newsletter_no/)).to eql rs
312
+ expect(browser.radio_set(name: "new_user_newsletter", index: 2)).to eql rs
313
+ expect(browser.radio_set(name: /new_user_newsletter/)).to eql rs
314
+ expect(browser.radio_set(value: "yes")).to eql rs
315
+ expect(browser.radio_set(value: /yes/)).to eql rs
316
+ expect(browser.radio_set(class: "huge")).to eql rs
317
+ expect(browser.radio_set(class: /huge/)).to eql rs
318
+ expect(browser.radio_set(index: 0)).to eql rs
319
+ expect(browser.radio_set(xpath: "//input[@id='new_user_newsletter_probably']")).to eql rs
320
+ end
321
+ end
322
+
323
+ it "returns the text of the selected radio" do
324
+ expect(browser.radio_set(id: 'new_user_newsletter_yes').select("No")).to eq "No"
325
+ end
326
+
327
+ it "raises UnknownObjectException if the radio doesn't exist" do
328
+ expect { browser.radio_set(id: 'new_user_newsletter_yes').select("missing_option") }.to raise_unknown_object_exception
329
+ expect { browser.radio_set(id: 'new_user_newsletter_yes').select(/missing_option/) }.to raise_unknown_object_exception
330
+ end
331
+
332
+ it "raises ObjectDisabledException if the option is disabled" do
333
+ expect { browser.radio_set(id: 'new_user_newsletter_none').select("None") }.to raise_object_disabled_exception
334
+ end
335
+
336
+ it "raises a TypeError if argument is not a String, Regexp or Numeric" do
337
+ expect { browser.radio_set(id: 'new_user_newsletter_yes').select([]) }.to raise_error(TypeError)
338
+ end
339
+
340
+ end
@@ -14,10 +14,20 @@ class LocalConfig
14
14
  set_webdriver
15
15
  set_browser_args
16
16
  set_guard_proc
17
+ load_webdrivers
17
18
  end
18
19
 
19
20
  private
20
21
 
22
+ def load_webdrivers
23
+ case browser
24
+ when :chrome
25
+ Webdrivers::Chromedriver.update
26
+ when :firefox
27
+ Webdrivers::Geckodriver.update
28
+ end
29
+ end
30
+
21
31
  def set_webdriver
22
32
  @imp.name = :webdriver
23
33
  @imp.browser_class = Watir::Browser
@@ -115,11 +125,14 @@ end
115
125
 
116
126
  class RemoteConfig < LocalConfig
117
127
  def configure
128
+ load_webdrivers
118
129
  @url = ENV["REMOTE_SERVER_URL"] || begin
119
130
  require 'watirspec/remote_server'
120
131
 
121
132
  remote_server = WatirSpec::RemoteServer.new
122
- remote_server.start
133
+ args = ["-Dwebdriver.chrome.driver=#{Webdrivers::Chromedriver.send :binary}",
134
+ "-Dwebdriver.gecko.driver=#{Webdrivers::Geckodriver.send :binary}"]
135
+ remote_server.start(4444, args: args)
123
136
  remote_server.server.webdriver_url
124
137
  end
125
138
  super
@@ -1,5 +1,6 @@
1
1
  require 'watir'
2
2
  require 'watirspec'
3
+ require 'webdrivers'
3
4
 
4
5
  #
5
6
  # 1. If example does not start browser, start new one, reuse until example
@@ -63,18 +64,20 @@ YARD::Doctest.configure do |doctest|
63
64
  end
64
65
  end
65
66
 
66
- doctest.before('Watir::List') do
67
- browser.goto WatirSpec.url_for('non_control_elements.html')
67
+ %w[Watir::JSExecution Watir::List].each do |name|
68
+ doctest.before(name) do
69
+ browser.goto WatirSpec.url_for('non_control_elements.html')
70
+ end
68
71
  end
69
72
 
70
- doctest.before('Watir::Table') do
71
- browser.goto WatirSpec.url_for('tables.html')
73
+ %w[fire_event].each do |name|
74
+ doctest.before("Watir::JSExecution##{name}") do
75
+ browser.goto WatirSpec.url_for('forms_with_input_elements.html')
76
+ end
72
77
  end
73
78
 
74
- %w[inner_html outer_html html].each do |name|
75
- doctest.before("Watir::Element##{name}") do
76
- browser.goto WatirSpec.url_for('inner_outer.html')
77
- end
79
+ doctest.before('Watir::Table') do
80
+ browser.goto WatirSpec.url_for('tables.html')
78
81
  end
79
82
 
80
83
  %w[Watir::HasWindow Watir::Window#== Watir::Window#use].each do |name|