watir 6.0.3 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/CHANGES.md +8 -0
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/lib/watir/after_hooks.rb +2 -2
- data/lib/watir/attribute_helper.rb +1 -1
- data/lib/watir/browser.rb +1 -1
- data/lib/watir/element_collection.rb +2 -2
- data/lib/watir/elements/element.rb +4 -6
- data/lib/watir/elements/html_elements.rb +51 -51
- data/lib/watir/elements/image.rb +1 -1
- data/lib/watir/elements/select.rb +22 -79
- data/lib/watir/elements/svg_elements.rb +56 -56
- data/lib/watir/elements/table.rb +1 -1
- data/lib/watir/elements/table_section.rb +1 -1
- data/lib/watir/generator/base/visitor.rb +1 -1
- data/lib/watir/legacy_wait.rb +2 -2
- data/lib/watir/locators/element/locator.rb +8 -5
- data/lib/watir/locators/element/selector_builder.rb +2 -2
- data/lib/watir/wait.rb +18 -18
- data/lib/watir/wait/timer.rb +1 -1
- data/lib/watir/window.rb +4 -4
- data/lib/watirspec.rb +4 -7
- data/lib/watirspec/guards.rb +3 -1
- data/lib/watirspec/implementation.rb +8 -0
- data/spec/browser_spec.rb +4 -4
- data/spec/element_locator_spec.rb +4 -3
- data/spec/element_spec.rb +1 -1
- data/spec/watirspec/element_hidden_spec.rb +11 -1
- data/spec/watirspec/elements/select_list_spec.rb +4 -4
- data/spec/watirspec/html/wait.html +14 -0
- data/spec/watirspec/relaxed_locate_spec.rb +4 -0
- data/spec/watirspec/support/raise_exception_matchers.rb +2 -1
- data/spec/watirspec/wait_spec.rb +77 -1
- data/watir.gemspec +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97b12fa8cee06abcdffeeefdb6a8455ad6abfdb2
|
4
|
+
data.tar.gz: 661c429b9dcf2eb4fe1ee856a7938c93ff3582d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69f706e5998202121957302950f0c71e14359032160924f066474c680f766635de7018f8eb470d6171e7993593c88beb883f1092ebe8fe3014d4d720e29d5cf9
|
7
|
+
data.tar.gz: d85aec3e1d158e6fd19ba5f176ce7711d762e7f2748faa686e4de8e28a8a687271efe711feee5fd2ac4e3fa26b6ded54c2cbfbdd46bd76695d443370a3ea8793
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
### 6.1.0 (2017-01-04)
|
2
|
+
|
3
|
+
* Add Ruby 2.4.0 support (thanks Robert MacCracken)
|
4
|
+
* Implement polling interval parameter for wait methods
|
5
|
+
* Implement visible locator for element collections
|
6
|
+
* Implement automatic waiting for selecting options in a select list
|
7
|
+
* Fix bug allowing `StaleElementReferenceError` in `#wait_while_present` calls
|
8
|
+
|
1
9
|
### 6.0.3 (2016-12-22)
|
2
10
|
|
3
11
|
* No notable changes, only includes fixes for WatirSpec
|
data/LICENSE
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
(the MIT License)
|
2
2
|
|
3
3
|
Copyright (c) 2009-2015 Jari Bakken
|
4
|
-
Copyright (c) 2015-
|
4
|
+
Copyright (c) 2015-2017 Alex Rodionov, Titus Fortner
|
5
5
|
|
6
6
|
Permission is hereby granted, free of charge, to any person obtaining
|
7
7
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
data/lib/watir/after_hooks.rb
CHANGED
@@ -109,7 +109,7 @@ module Watir
|
|
109
109
|
# browser.after_hooks.length
|
110
110
|
# #=> 1
|
111
111
|
#
|
112
|
-
# @return [
|
112
|
+
# @return [Integer]
|
113
113
|
#
|
114
114
|
|
115
115
|
def length
|
@@ -120,7 +120,7 @@ module Watir
|
|
120
120
|
#
|
121
121
|
# Gets the after hook at the given index.
|
122
122
|
#
|
123
|
-
# @param [
|
123
|
+
# @param [Integer] index
|
124
124
|
# @return [#call]
|
125
125
|
#
|
126
126
|
|
data/lib/watir/browser.rb
CHANGED
@@ -31,7 +31,7 @@ module Watir
|
|
31
31
|
#
|
32
32
|
# Returns number of elements in collection.
|
33
33
|
#
|
34
|
-
# @return [
|
34
|
+
# @return [Integer]
|
35
35
|
#
|
36
36
|
|
37
37
|
def length
|
@@ -45,7 +45,7 @@ module Watir
|
|
45
45
|
# Also note that because of Watir's lazy loading, this will return an Element
|
46
46
|
# instance even if the index is out of bounds.
|
47
47
|
#
|
48
|
-
# @param [
|
48
|
+
# @param [Integer] idx Index of wanted element, 0-indexed
|
49
49
|
# @return [Watir::Element] Returns an instance of a Watir::Element subclass
|
50
50
|
#
|
51
51
|
|
@@ -201,8 +201,8 @@ module Watir
|
|
201
201
|
# @example
|
202
202
|
# browser.div(id: "draggable").drag_and_drop_by 100, -200
|
203
203
|
#
|
204
|
-
# @param [
|
205
|
-
# @param [
|
204
|
+
# @param [Integer] right_by
|
205
|
+
# @param [Integer] down_by
|
206
206
|
#
|
207
207
|
|
208
208
|
def drag_and_drop_by(right_by, down_by)
|
@@ -382,8 +382,7 @@ module Watir
|
|
382
382
|
#
|
383
383
|
|
384
384
|
def visible?
|
385
|
-
assert_exists
|
386
|
-
@element.displayed?
|
385
|
+
element_call(:assert_exists) { @element.displayed? }
|
387
386
|
end
|
388
387
|
|
389
388
|
#
|
@@ -394,8 +393,7 @@ module Watir
|
|
394
393
|
#
|
395
394
|
|
396
395
|
def enabled?
|
397
|
-
assert_exists
|
398
|
-
@element.enabled?
|
396
|
+
element_call(:assert_exists) { @element.enabled? }
|
399
397
|
end
|
400
398
|
|
401
399
|
#
|
@@ -14,7 +14,7 @@ module Watir
|
|
14
14
|
attribute(String, :properties, :properties)
|
15
15
|
attribute(String, :item_value, :itemValue)
|
16
16
|
attribute("Boolean", :hidden?, :hidden)
|
17
|
-
attribute(
|
17
|
+
attribute(Integer, :tab_index, :tabIndex)
|
18
18
|
attribute(String, :access_key, :accessKey)
|
19
19
|
attribute(String, :access_key_label, :accessKeyLabel)
|
20
20
|
attribute("Boolean", :draggable?, :draggable)
|
@@ -134,12 +134,12 @@ module Watir
|
|
134
134
|
attribute(String, :bg_color, :bgColor)
|
135
135
|
attribute(String, :direction, :direction)
|
136
136
|
attribute(String, :height, :height)
|
137
|
-
attribute(
|
138
|
-
attribute(
|
139
|
-
attribute(
|
140
|
-
attribute(
|
137
|
+
attribute(Integer, :hspace, :hspace)
|
138
|
+
attribute(Integer, :loop, :loop)
|
139
|
+
attribute(Integer, :scroll_amount, :scrollAmount)
|
140
|
+
attribute(Integer, :scroll_delay, :scrollDelay)
|
141
141
|
attribute("Boolean", :true_speed?, :trueSpeed)
|
142
|
-
attribute(
|
142
|
+
attribute(Integer, :vspace, :vspace)
|
143
143
|
attribute(String, :width, :width)
|
144
144
|
attribute(String, :onbounce, :onbounce)
|
145
145
|
attribute(String, :onfinish, :onfinish)
|
@@ -155,18 +155,18 @@ module Watir
|
|
155
155
|
attribute(String, :code, :code)
|
156
156
|
attribute(String, :code_base, :codeBase)
|
157
157
|
attribute(String, :height, :height)
|
158
|
-
attribute(
|
158
|
+
attribute(Integer, :hspace, :hspace)
|
159
159
|
attribute(String, :name, :name)
|
160
160
|
attribute(String, :object, :object)
|
161
|
-
attribute(
|
161
|
+
attribute(Integer, :vspace, :vspace)
|
162
162
|
attribute(String, :width, :width)
|
163
163
|
end
|
164
164
|
class AppletCollection < ElementCollection
|
165
165
|
end
|
166
166
|
|
167
167
|
class Canvas < HTMLElement
|
168
|
-
attribute(
|
169
|
-
attribute(
|
168
|
+
attribute(Integer, :width, :width)
|
169
|
+
attribute(Integer, :height, :height)
|
170
170
|
end
|
171
171
|
class CanvasCollection < ElementCollection
|
172
172
|
end
|
@@ -298,13 +298,13 @@ module Watir
|
|
298
298
|
class TextArea < HTMLElement
|
299
299
|
attribute(String, :autocomplete, :autocomplete)
|
300
300
|
attribute("Boolean", :autofocus?, :autofocus)
|
301
|
-
attribute(
|
301
|
+
attribute(Integer, :cols, :cols)
|
302
302
|
attribute(String, :dir_name, :dirName)
|
303
303
|
attribute("Boolean", :disabled?, :disabled)
|
304
304
|
attribute(String, :form, :form)
|
305
305
|
attribute(String, :input_mode, :inputMode)
|
306
|
-
attribute(
|
307
|
-
attribute(
|
306
|
+
attribute(Integer, :max_length, :maxLength)
|
307
|
+
attribute(Integer, :min_length, :minLength)
|
308
308
|
attribute(String, :name, :name)
|
309
309
|
attribute(String, :placeholder, :placeholder)
|
310
310
|
attribute("Boolean", :read_only?, :readOnly)
|
@@ -313,13 +313,13 @@ module Watir
|
|
313
313
|
attribute(String, :type, :type)
|
314
314
|
attribute(String, :default_value, :defaultValue)
|
315
315
|
attribute(String, :value, :value)
|
316
|
-
attribute(
|
316
|
+
attribute(Integer, :text_length, :textLength)
|
317
317
|
attribute("Boolean", :will_validate?, :willValidate)
|
318
318
|
attribute(String, :validity, :validity)
|
319
319
|
attribute(String, :validation_message, :validationMessage)
|
320
320
|
attribute(String, :labels, :labels)
|
321
|
-
attribute(
|
322
|
-
attribute(
|
321
|
+
attribute(Integer, :selection_start, :selectionStart)
|
322
|
+
attribute(Integer, :selection_end, :selectionEnd)
|
323
323
|
attribute(String, :selection_direction, :selectionDirection)
|
324
324
|
end
|
325
325
|
class TextAreaCollection < ElementCollection
|
@@ -332,7 +332,7 @@ module Watir
|
|
332
332
|
attribute("Boolean", :default_selected?, :defaultSelected)
|
333
333
|
attribute("Boolean", :selected?, :selected)
|
334
334
|
attribute(String, :value, :value)
|
335
|
-
attribute(
|
335
|
+
attribute(Integer, :index, :index)
|
336
336
|
end
|
337
337
|
class OptionCollection < ElementCollection
|
338
338
|
end
|
@@ -358,12 +358,12 @@ module Watir
|
|
358
358
|
attribute("Boolean", :multiple?, :multiple)
|
359
359
|
attribute(String, :name, :name)
|
360
360
|
attribute("Boolean", :required?, :required)
|
361
|
-
attribute(
|
361
|
+
attribute(Integer, :size, :size)
|
362
362
|
attribute(String, :type, :type)
|
363
363
|
attribute(String, :options, :options)
|
364
|
-
attribute(
|
364
|
+
attribute(Integer, :length, :length)
|
365
365
|
attribute(String, :selected_options, :selectedOptions)
|
366
|
-
attribute(
|
366
|
+
attribute(Integer, :selected_index, :selectedIndex)
|
367
367
|
attribute(String, :value, :value)
|
368
368
|
attribute("Boolean", :will_validate?, :willValidate)
|
369
369
|
attribute(String, :validity, :validity)
|
@@ -410,21 +410,21 @@ module Watir
|
|
410
410
|
attribute(String, :form_method, :formMethod)
|
411
411
|
attribute("Boolean", :form_no_validate?, :formNoValidate)
|
412
412
|
attribute(String, :form_target, :formTarget)
|
413
|
-
attribute(
|
413
|
+
attribute(Integer, :height, :height)
|
414
414
|
attribute("Boolean", :indeterminate?, :indeterminate)
|
415
415
|
attribute(String, :input_mode, :inputMode)
|
416
416
|
attribute(String, :list, :list)
|
417
417
|
attribute(String, :max, :max)
|
418
|
-
attribute(
|
418
|
+
attribute(Integer, :max_length, :maxLength)
|
419
419
|
attribute(String, :min, :min)
|
420
|
-
attribute(
|
420
|
+
attribute(Integer, :min_length, :minLength)
|
421
421
|
attribute("Boolean", :multiple?, :multiple)
|
422
422
|
attribute(String, :name, :name)
|
423
423
|
attribute(String, :pattern, :pattern)
|
424
424
|
attribute(String, :placeholder, :placeholder)
|
425
425
|
attribute("Boolean", :read_only?, :readOnly)
|
426
426
|
attribute("Boolean", :required?, :required)
|
427
|
-
attribute(
|
427
|
+
attribute(Integer, :size, :size)
|
428
428
|
attribute(String, :src, :src)
|
429
429
|
attribute(String, :step, :step)
|
430
430
|
attribute(String, :type, :type)
|
@@ -434,13 +434,13 @@ module Watir
|
|
434
434
|
attribute(Float, :value_as_number, :valueAsNumber)
|
435
435
|
attribute(Float, :value_low, :valueLow)
|
436
436
|
attribute(Float, :value_high, :valueHigh)
|
437
|
-
attribute(
|
437
|
+
attribute(Integer, :width, :width)
|
438
438
|
attribute("Boolean", :will_validate?, :willValidate)
|
439
439
|
attribute(String, :validity, :validity)
|
440
440
|
attribute(String, :validation_message, :validationMessage)
|
441
441
|
attribute(String, :labels, :labels)
|
442
|
-
attribute(
|
443
|
-
attribute(
|
442
|
+
attribute(Integer, :selection_start, :selectionStart)
|
443
|
+
attribute(Integer, :selection_end, :selectionEnd)
|
444
444
|
attribute(String, :selection_direction, :selectionDirection)
|
445
445
|
attribute(String, :align, :align)
|
446
446
|
attribute(String, :use_map, :useMap)
|
@@ -466,16 +466,16 @@ module Watir
|
|
466
466
|
attribute(String, :name, :name)
|
467
467
|
attribute("Boolean", :no_validate?, :noValidate)
|
468
468
|
attribute(String, :target, :target)
|
469
|
-
attribute(
|
469
|
+
attribute(Integer, :length, :length)
|
470
470
|
end
|
471
471
|
class FormCollection < ElementCollection
|
472
472
|
end
|
473
473
|
|
474
474
|
class TableCell < HTMLElement
|
475
|
-
attribute(
|
476
|
-
attribute(
|
475
|
+
attribute(Integer, :col_span, :colSpan)
|
476
|
+
attribute(Integer, :row_span, :rowSpan)
|
477
477
|
attribute(String, :headers, :headers)
|
478
|
-
attribute(
|
478
|
+
attribute(Integer, :cell_index, :cellIndex)
|
479
479
|
attribute(String, :align, :align)
|
480
480
|
attribute(String, :axis, :axis)
|
481
481
|
attribute(String, :height, :height)
|
@@ -504,8 +504,8 @@ module Watir
|
|
504
504
|
end
|
505
505
|
|
506
506
|
class TableRow < HTMLElement
|
507
|
-
attribute(
|
508
|
-
attribute(
|
507
|
+
attribute(Integer, :row_index, :rowIndex)
|
508
|
+
attribute(Integer, :section_row_index, :sectionRowIndex)
|
509
509
|
attribute(String, :align, :align)
|
510
510
|
attribute(String, :ch, :ch)
|
511
511
|
attribute(String, :ch_off, :chOff)
|
@@ -589,10 +589,10 @@ module Watir
|
|
589
589
|
attribute(String, :src_object, :srcObject)
|
590
590
|
attribute(String, :current_src, :currentSrc)
|
591
591
|
attribute(String, :cross_origin, :crossOrigin)
|
592
|
-
attribute(
|
592
|
+
attribute(Integer, :network_state, :networkState)
|
593
593
|
attribute(String, :preload, :preload)
|
594
594
|
attribute(String, :buffered, :buffered)
|
595
|
-
attribute(
|
595
|
+
attribute(Integer, :ready_state, :readyState)
|
596
596
|
attribute("Boolean", :seeking?, :seeking)
|
597
597
|
attribute(Float, :current_time, :currentTime)
|
598
598
|
attribute(Float, :duration, :duration)
|
@@ -623,10 +623,10 @@ module Watir
|
|
623
623
|
end
|
624
624
|
|
625
625
|
class Video < Media
|
626
|
-
attribute(
|
627
|
-
attribute(
|
628
|
-
attribute(
|
629
|
-
attribute(
|
626
|
+
attribute(Integer, :width, :width)
|
627
|
+
attribute(Integer, :height, :height)
|
628
|
+
attribute(Integer, :video_width, :videoWidth)
|
629
|
+
attribute(Integer, :video_height, :videoHeight)
|
630
630
|
attribute(String, :poster, :poster)
|
631
631
|
end
|
632
632
|
class VideoCollection < ElementCollection
|
@@ -638,7 +638,7 @@ module Watir
|
|
638
638
|
attribute(String, :srclang, :srclang)
|
639
639
|
attribute(String, :label, :label)
|
640
640
|
attribute("Boolean", :default?, :default)
|
641
|
-
attribute(
|
641
|
+
attribute(Integer, :ready_state, :readyState)
|
642
642
|
attribute(String, :track, :track)
|
643
643
|
end
|
644
644
|
class TrackCollection < ElementCollection
|
@@ -671,9 +671,9 @@ module Watir
|
|
671
671
|
attribute(String, :archive, :archive)
|
672
672
|
attribute(String, :code, :code)
|
673
673
|
attribute("Boolean", :declare?, :declare)
|
674
|
-
attribute(
|
674
|
+
attribute(Integer, :hspace, :hspace)
|
675
675
|
attribute(String, :standby, :standby)
|
676
|
-
attribute(
|
676
|
+
attribute(Integer, :vspace, :vspace)
|
677
677
|
attribute(String, :code_base, :codeBase)
|
678
678
|
attribute(String, :code_type, :codeType)
|
679
679
|
attribute(String, :border, :border)
|
@@ -721,17 +721,17 @@ module Watir
|
|
721
721
|
attribute(String, :cross_origin, :crossOrigin)
|
722
722
|
attribute(String, :use_map, :useMap)
|
723
723
|
attribute("Boolean", :map?, :isMap)
|
724
|
-
attribute(
|
725
|
-
attribute(
|
726
|
-
attribute(
|
727
|
-
attribute(
|
724
|
+
attribute(Integer, :width, :width)
|
725
|
+
attribute(Integer, :height, :height)
|
726
|
+
attribute(Integer, :natural_width, :naturalWidth)
|
727
|
+
attribute(Integer, :natural_height, :naturalHeight)
|
728
728
|
attribute("Boolean", :complete?, :complete)
|
729
729
|
attribute(String, :current_src, :currentSrc)
|
730
730
|
attribute(String, :name, :name)
|
731
731
|
attribute(String, :lowsrc, :lowsrc)
|
732
732
|
attribute(String, :align, :align)
|
733
|
-
attribute(
|
734
|
-
attribute(
|
733
|
+
attribute(Integer, :hspace, :hspace)
|
734
|
+
attribute(Integer, :vspace, :vspace)
|
735
735
|
attribute(String, :long_desc, :longDesc)
|
736
736
|
attribute(String, :border, :border)
|
737
737
|
end
|
@@ -813,7 +813,7 @@ module Watir
|
|
813
813
|
end
|
814
814
|
|
815
815
|
class LI < HTMLElement
|
816
|
-
attribute(
|
816
|
+
attribute(Integer, :value, :value)
|
817
817
|
attribute(String, :type, :type)
|
818
818
|
end
|
819
819
|
class LICollection < ElementCollection
|
@@ -828,7 +828,7 @@ module Watir
|
|
828
828
|
|
829
829
|
class OList < HTMLElement
|
830
830
|
attribute("Boolean", :reversed?, :reversed)
|
831
|
-
attribute(
|
831
|
+
attribute(Integer, :start, :start)
|
832
832
|
attribute(String, :type, :type)
|
833
833
|
attribute("Boolean", :compact?, :compact)
|
834
834
|
end
|
@@ -842,7 +842,7 @@ module Watir
|
|
842
842
|
end
|
843
843
|
|
844
844
|
class Pre < HTMLElement
|
845
|
-
attribute(
|
845
|
+
attribute(Integer, :width, :width)
|
846
846
|
end
|
847
847
|
class PreCollection < ElementCollection
|
848
848
|
end
|
data/lib/watir/elements/image.rb
CHANGED
@@ -20,9 +20,8 @@ module Watir
|
|
20
20
|
# @return [Watir::OptionCollection]
|
21
21
|
#
|
22
22
|
|
23
|
-
def options
|
24
|
-
wait_for_exists
|
25
|
-
super
|
23
|
+
def options(*)
|
24
|
+
element_call(:wait_for_exists) { super }
|
26
25
|
end
|
27
26
|
|
28
27
|
#
|
@@ -119,85 +118,36 @@ module Watir
|
|
119
118
|
private
|
120
119
|
|
121
120
|
def select_by(how, str_or_rx)
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
xpath = option_xpath_for(how, string)
|
134
|
-
|
135
|
-
if multiple?
|
136
|
-
elements = element_call do
|
137
|
-
@element.find_elements(:xpath, xpath)
|
121
|
+
found = nil
|
122
|
+
begin
|
123
|
+
Wait.until do
|
124
|
+
case str_or_rx
|
125
|
+
when String, Numeric, Regexp
|
126
|
+
found = options(how => str_or_rx)
|
127
|
+
found = options(label: str_or_rx) if found.to_a.empty?
|
128
|
+
else
|
129
|
+
raise TypeError, "expected String or Regexp, got #{str_or_rx.inspect}:#{str_or_rx.class}"
|
130
|
+
end
|
131
|
+
!found.to_a.empty?
|
138
132
|
end
|
139
|
-
|
140
|
-
|
141
|
-
elements.each { |e| click_option(e) unless e.selected? }
|
142
|
-
elements.first.text
|
143
|
-
else
|
144
|
-
begin
|
145
|
-
e = element_call do
|
146
|
-
@element.find_element(:xpath, xpath)
|
147
|
-
end
|
148
|
-
rescue Selenium::WebDriver::Error::NoSuchElementError
|
149
|
-
no_value_found(string)
|
150
|
-
end
|
151
|
-
|
152
|
-
click_option(e) unless e.selected?
|
153
|
-
safe_text(e)
|
133
|
+
rescue Wait::TimeoutError
|
134
|
+
no_value_found(str_or_rx)
|
154
135
|
end
|
136
|
+
select_matching(found)
|
155
137
|
end
|
156
138
|
|
157
|
-
def
|
158
|
-
elements =
|
159
|
-
|
160
|
-
|
161
|
-
no_value_found(nil, "no options in select list") if elements.empty?
|
162
|
-
|
163
|
-
if multiple?
|
164
|
-
found = elements.select do |e|
|
165
|
-
next unless matches_regexp?(how, e, exp)
|
166
|
-
click_option(e) unless e.selected?
|
167
|
-
true
|
168
|
-
end
|
169
|
-
|
170
|
-
no_value_found(exp) if found.empty?
|
171
|
-
|
172
|
-
found.first.text
|
173
|
-
else
|
174
|
-
element = elements.find { |e| matches_regexp?(how, e, exp) }
|
175
|
-
no_value_found(exp) unless element
|
176
|
-
|
177
|
-
click_option(element) unless element.selected?
|
178
|
-
safe_text(element)
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
def option_xpath_for(how, string)
|
183
|
-
string = XpathSupport.escape string
|
184
|
-
|
185
|
-
case how
|
186
|
-
when :text
|
187
|
-
".//option[normalize-space()=#{string} or @label=#{string}]"
|
188
|
-
when :value
|
189
|
-
".//option[@value=#{string}]"
|
190
|
-
else
|
191
|
-
raise Error, "unknown how: #{how.inspect}"
|
192
|
-
end
|
139
|
+
def select_matching(elements)
|
140
|
+
elements = [elements.first] unless multiple?
|
141
|
+
elements.each { |e| click_option(e) unless e.selected? }
|
142
|
+
elements.first.exist? ? elements.first.text : ''
|
193
143
|
end
|
194
144
|
|
195
145
|
def matches_regexp?(how, element, exp)
|
196
146
|
case how
|
197
147
|
when :text
|
198
|
-
element.text =~ exp || element.
|
148
|
+
element.text =~ exp || element.label =~ exp
|
199
149
|
when :value
|
200
|
-
element.
|
150
|
+
element.value =~ exp
|
201
151
|
else
|
202
152
|
raise Error, "unknown how: #{how.inspect}"
|
203
153
|
end
|
@@ -208,13 +158,6 @@ module Watir
|
|
208
158
|
element.click
|
209
159
|
end
|
210
160
|
|
211
|
-
def safe_text(element)
|
212
|
-
element.text
|
213
|
-
rescue Selenium::WebDriver::Error::StaleElementReferenceError, Selenium::WebDriver::Error::UnhandledAlertError
|
214
|
-
# guard for scenario where selecting the element changes the page, making our element obsolete
|
215
|
-
''
|
216
|
-
end
|
217
|
-
|
218
161
|
def no_value_found(arg, msg = nil)
|
219
162
|
raise NoValueFoundException, msg || "#{arg.inspect} not found in select list"
|
220
163
|
end
|