watir 6.11.0 → 6.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGES.md +17 -0
- data/lib/watir.rb +5 -14
- data/lib/watir/adjacent.rb +2 -2
- data/lib/watir/alert.rb +1 -1
- data/lib/watir/browser.rb +11 -2
- data/lib/watir/capabilities.rb +8 -3
- data/lib/watir/container.rb +4 -1
- data/lib/watir/element_collection.rb +24 -10
- data/lib/watir/elements/element.rb +19 -9
- data/lib/watir/elements/select.rb +3 -2
- data/lib/watir/js_execution.rb +20 -9
- data/lib/watir/legacy_wait.rb +3 -2
- data/lib/watir/locators.rb +6 -6
- data/lib/watir/locators/element/locator.rb +42 -18
- data/lib/watir/locators/element/selector_builder/xpath.rb +5 -1
- data/lib/watir/logger.rb +24 -11
- data/lib/watir/screenshot.rb +9 -2
- data/lib/watir/wait.rb +36 -16
- data/lib/watirspec.rb +2 -1
- data/lib/watirspec/guards.rb +1 -1
- data/lib/watirspec/runner.rb +8 -2
- data/lib/watirspec/server.rb +1 -1
- data/spec/{container_spec.rb → unit/container_spec.rb} +4 -2
- data/spec/{element_locator_spec.rb → unit/element_locator_spec.rb} +30 -5
- data/spec/unit/logger_spec.rb +78 -0
- data/spec/unit/unit_helper.rb +6 -0
- data/spec/unit/wait_spec.rb +95 -0
- data/spec/watirspec/alert_spec.rb +1 -8
- data/spec/watirspec/browser_spec.rb +241 -0
- data/spec/{click_spec.rb → watirspec/click_spec.rb} +0 -0
- data/spec/watirspec/elements/checkbox_spec.rb +1 -1
- data/spec/watirspec/elements/del_spec.rb +1 -1
- data/spec/watirspec/elements/div_spec.rb +19 -8
- data/spec/watirspec/elements/divs_spec.rb +12 -0
- data/spec/watirspec/elements/dt_spec.rb +2 -2
- data/spec/watirspec/elements/element_spec.rb +220 -9
- data/spec/watirspec/elements/hn_spec.rb +1 -1
- data/spec/watirspec/elements/hns_spec.rb +1 -1
- data/spec/{input_spec.rb → watirspec/elements/input_spec.rb} +0 -0
- data/spec/watirspec/elements/ins_spec.rb +1 -1
- data/spec/watirspec/elements/labels_spec.rb +1 -1
- data/spec/watirspec/elements/li_spec.rb +1 -1
- data/spec/watirspec/elements/link_spec.rb +1 -2
- data/spec/watirspec/elements/ol_spec.rb +2 -4
- data/spec/watirspec/elements/p_spec.rb +1 -1
- data/spec/watirspec/elements/pre_spec.rb +1 -1
- data/spec/watirspec/elements/select_list_spec.rb +2 -4
- data/spec/watirspec/elements/span_spec.rb +2 -3
- data/spec/watirspec/elements/strong_spec.rb +1 -1
- data/spec/watirspec/elements/table_spec.rb +2 -6
- data/spec/watirspec/elements/td_spec.rb +1 -2
- data/spec/watirspec/elements/text_field_spec.rb +11 -0
- data/spec/watirspec/elements/text_fields_spec.rb +1 -1
- data/spec/watirspec/elements/ul_spec.rb +1 -2
- data/spec/watirspec/html/forms_with_input_elements.html +2 -1
- data/spec/watirspec/html/wait.html +12 -0
- data/spec/watirspec/relaxed_locate_spec.rb +28 -27
- data/spec/{special_chars_spec.rb → watirspec/special_chars_spec.rb} +0 -0
- data/spec/watirspec/support/rspec_matchers.rb +88 -0
- data/spec/watirspec/wait_spec.rb +5 -104
- data/spec/watirspec/window_switching_spec.rb +1 -1
- data/watir.gemspec +1 -1
- metadata +21 -21
- data/spec/browser_spec.rb +0 -280
- data/spec/element_spec.rb +0 -150
- data/spec/logger_spec.rb +0 -46
- data/spec/watirspec/support/raise_exception_matchers.rb +0 -36
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: ea86da9b066569e766ab50f2f0657d7bc77501ab
|
|
4
|
+
data.tar.gz: 07ad7bd26a6dc2b01b998fe64ef5254289541dc1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4814e526875cba217e35219544f3322baecd947df1e00cb347224bf544cdc806bcd51768ca6394130f792b575010240dbcaba141468760aab448cfcd9e14228e
|
|
7
|
+
data.tar.gz: a6fc636ad8301a955430501f5d293094b4028337a80ef9b2c7a6dfdc634f4482dab0c7c84216651f8a8037b5c0f310be06467e359a43707a0477eb6e64bf1c89
|
data/CHANGES.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
### 6.12.0 (2018-07-24)
|
|
2
|
+
|
|
3
|
+
* Allow elements to be located with attributes that have underscores (thanks John Fitisoff)
|
|
4
|
+
* Get array of elements from an Element Collection using a Range (#738)
|
|
5
|
+
* Deprecate using `#present?` or `#visible?` to determine if an element is stale
|
|
6
|
+
* Allow getting element attribute values with a Symbol
|
|
7
|
+
* Add new functionality to `#flash` (thanks Gijs Paulides)
|
|
8
|
+
* Fix bug preventing text_field from waiting until present (#675)
|
|
9
|
+
* Fix bug allowing `StaleElementReferenceError` during element location
|
|
10
|
+
* Add support for Wait methods to receive `Proc` as message values
|
|
11
|
+
* Add support to ignore specific warnings logged by Watir
|
|
12
|
+
* Deprecate locating elements by ordered parameters
|
|
13
|
+
* Changed scope for locator namespacing (Thanks Aleksandar)
|
|
14
|
+
* Deprecate current implementation of `#visible?`
|
|
15
|
+
* Update logic `#wait_while_present` and `#wait_until_present`
|
|
16
|
+
* Deprecate `#wait_while_present` and `#wait_until_present` for non-Element classes
|
|
17
|
+
|
|
1
18
|
### 6.11.0 (2018-05-18)
|
|
2
19
|
|
|
3
20
|
* Improve lazy loading of element collections
|
data/lib/watir.rb
CHANGED
|
@@ -24,7 +24,7 @@ module Watir
|
|
|
24
24
|
|
|
25
25
|
class << self
|
|
26
26
|
|
|
27
|
-
attr_writer :relaxed_locate, :always_locate, :default_timeout, :prefer_css
|
|
27
|
+
attr_writer :relaxed_locate, :always_locate, :default_timeout, :prefer_css
|
|
28
28
|
|
|
29
29
|
#
|
|
30
30
|
# Whether or not Watir should wait for an element to be found or present
|
|
@@ -46,11 +46,12 @@ module Watir
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def always_locate_message
|
|
49
|
-
|
|
49
|
+
msg = <<-EOS.gsub("\n", " ")
|
|
50
50
|
Watir#always_locate is deprecated; elements are always cached and will always
|
|
51
51
|
be re-located if they go stale before use.
|
|
52
52
|
Use Element#stale? or Element#wait_until(&:stale?) if needed for flow control.
|
|
53
53
|
EOS
|
|
54
|
+
Watir.logger.warn msg, ids: [:always_locate, :deprecations]
|
|
54
55
|
end
|
|
55
56
|
|
|
56
57
|
#
|
|
@@ -63,11 +64,12 @@ Use Element#stale? or Element#wait_until(&:stale?) if needed for flow control.
|
|
|
63
64
|
end
|
|
64
65
|
|
|
65
66
|
def prefer_css_message
|
|
66
|
-
|
|
67
|
+
msg = <<-EOS.gsub("\n", " ")
|
|
67
68
|
Watir#prefer_css is deprecated; all elements that can not be passed directly
|
|
68
69
|
as Selenium locators will be translated to XPath. To continue using CSS Selectors
|
|
69
70
|
require the watir_css gem - https://github.com/watir/watir_css
|
|
70
71
|
EOS
|
|
72
|
+
Watir.logger.warn msg, ids: [:prefer_css, :deprecations]
|
|
71
73
|
end
|
|
72
74
|
|
|
73
75
|
#
|
|
@@ -78,15 +80,6 @@ require the watir_css gem - https://github.com/watir/watir_css
|
|
|
78
80
|
@default_timeout ||= 30
|
|
79
81
|
end
|
|
80
82
|
|
|
81
|
-
#
|
|
82
|
-
# Whether the locators should be used from a different namespace.
|
|
83
|
-
# Defaults to Watir::Locators.
|
|
84
|
-
#
|
|
85
|
-
|
|
86
|
-
def locator_namespace
|
|
87
|
-
@locator_namespace ||= Watir::Locators
|
|
88
|
-
end
|
|
89
|
-
|
|
90
83
|
#
|
|
91
84
|
# @api private
|
|
92
85
|
#
|
|
@@ -156,5 +149,3 @@ require 'watir/elements/input'
|
|
|
156
149
|
require 'watir/radio_set'
|
|
157
150
|
|
|
158
151
|
require 'watir/aliases'
|
|
159
|
-
|
|
160
|
-
Watir.tag_to_class.freeze
|
data/lib/watir/adjacent.rb
CHANGED
|
@@ -58,7 +58,7 @@ module Watir
|
|
|
58
58
|
#
|
|
59
59
|
# @example
|
|
60
60
|
# browser.text_field(name: "new_user_first_name").following_siblings.size
|
|
61
|
-
# #=>
|
|
61
|
+
# #=> 53
|
|
62
62
|
#
|
|
63
63
|
|
|
64
64
|
def following_siblings(opt = {})
|
|
@@ -73,7 +73,7 @@ module Watir
|
|
|
73
73
|
#
|
|
74
74
|
# @example
|
|
75
75
|
# browser.text_field(name: "new_user_first_name").siblings.size
|
|
76
|
-
# #=>
|
|
76
|
+
# #=> 57
|
|
77
77
|
#
|
|
78
78
|
|
|
79
79
|
def siblings(opt = {})
|
data/lib/watir/alert.rb
CHANGED
|
@@ -110,7 +110,7 @@ module Watir
|
|
|
110
110
|
message = "This code has slept for the duration of the default timeout "
|
|
111
111
|
message << "waiting for an Alert to exist. If the test is still passing, "
|
|
112
112
|
message << "consider using Alert#exists? instead of rescuing UnknownObjectException"
|
|
113
|
-
Watir.logger.warn message
|
|
113
|
+
Watir.logger.warn message, ids: [:wait_for_alert]
|
|
114
114
|
end
|
|
115
115
|
raise Exception::UnknownObjectException, 'unable to locate alert'
|
|
116
116
|
end
|
data/lib/watir/browser.rb
CHANGED
|
@@ -9,7 +9,7 @@ module Watir
|
|
|
9
9
|
include HasWindow
|
|
10
10
|
include Waitable
|
|
11
11
|
|
|
12
|
-
attr_writer :default_context, :original_window
|
|
12
|
+
attr_writer :default_context, :original_window, :locator_namespace
|
|
13
13
|
attr_reader :driver
|
|
14
14
|
attr_reader :after_hooks
|
|
15
15
|
alias_method :wd, :driver # ensures duck typing with Watir::Element
|
|
@@ -290,7 +290,7 @@ module Watir
|
|
|
290
290
|
#
|
|
291
291
|
|
|
292
292
|
def screenshot
|
|
293
|
-
Screenshot.new
|
|
293
|
+
Screenshot.new self
|
|
294
294
|
end
|
|
295
295
|
|
|
296
296
|
#
|
|
@@ -326,6 +326,15 @@ module Watir
|
|
|
326
326
|
self
|
|
327
327
|
end
|
|
328
328
|
|
|
329
|
+
#
|
|
330
|
+
# Whether the locators should be used from a different namespace.
|
|
331
|
+
# Defaults to Watir::Locators.
|
|
332
|
+
#
|
|
333
|
+
|
|
334
|
+
def locator_namespace
|
|
335
|
+
@locator_namespace ||= Watir::Locators
|
|
336
|
+
end
|
|
337
|
+
|
|
329
338
|
private
|
|
330
339
|
|
|
331
340
|
def wrap_elements_in(scope, obj)
|
data/lib/watir/capabilities.rb
CHANGED
|
@@ -50,7 +50,8 @@ module Watir
|
|
|
50
50
|
|
|
51
51
|
%i(open_timeout read_timeout client_timeout).each do |t|
|
|
52
52
|
next if http_client.nil? || !respond_to?(t)
|
|
53
|
-
Watir.logger.warn "You can now pass #{t} value directly into Watir::Browser opt without needing to use :http_client"
|
|
53
|
+
Watir.logger.warn "You can now pass #{t} value directly into Watir::Browser opt without needing to use :http_client",
|
|
54
|
+
ids: [:http_client, :use_capabilities]
|
|
54
55
|
end
|
|
55
56
|
|
|
56
57
|
http_client ||= Selenium::WebDriver::Remote::Http::Default.new
|
|
@@ -81,7 +82,10 @@ module Watir
|
|
|
81
82
|
profile = @options.delete(:profile)
|
|
82
83
|
if browser_options.is_a? Selenium::WebDriver::Firefox::Options
|
|
83
84
|
@selenium_opts[:options] = browser_options
|
|
84
|
-
|
|
85
|
+
if profile
|
|
86
|
+
Watir.logger.deprecate 'Initializing Browser with both :profile and :option', ':profile as a key inside :option',
|
|
87
|
+
ids: [:firefox_profile]
|
|
88
|
+
end
|
|
85
89
|
end
|
|
86
90
|
if @options.delete(:headless)
|
|
87
91
|
browser_options ||= {}
|
|
@@ -111,7 +115,8 @@ module Watir
|
|
|
111
115
|
caps = @options.delete(:desired_capabilities)
|
|
112
116
|
|
|
113
117
|
if caps
|
|
114
|
-
Watir.logger.warn 'You can now pass values directly into Watir::Browser opt without needing to use :desired_capabilities'
|
|
118
|
+
Watir.logger.warn 'You can now pass values directly into Watir::Browser opt without needing to use :desired_capabilities',
|
|
119
|
+
ids: [:use_capabilities]
|
|
115
120
|
@selenium_opts.merge!(@options)
|
|
116
121
|
else
|
|
117
122
|
caps = Selenium::WebDriver::Remote::Capabilities.send @browser, @options
|
data/lib/watir/container.rb
CHANGED
|
@@ -36,6 +36,9 @@ module Watir
|
|
|
36
36
|
def extract_selector(selectors)
|
|
37
37
|
case selectors.size
|
|
38
38
|
when 2
|
|
39
|
+
Watir.logger.deprecate "Using ordered parameters to locate elements (:#{selectors.first}, #{selectors.last.inspect})",
|
|
40
|
+
"{#{selectors.first}: #{selectors.last.inspect}}",
|
|
41
|
+
ids: [:selector_parameters]
|
|
39
42
|
return { selectors[0] => selectors[1] }
|
|
40
43
|
when 1
|
|
41
44
|
obj = selectors.first
|
|
@@ -44,7 +47,7 @@ module Watir
|
|
|
44
47
|
return {}
|
|
45
48
|
end
|
|
46
49
|
|
|
47
|
-
raise ArgumentError, "expected Hash
|
|
50
|
+
raise ArgumentError, "expected Hash, got #{selectors.inspect}"
|
|
48
51
|
end
|
|
49
52
|
|
|
50
53
|
end # Container
|
|
@@ -35,20 +35,24 @@ module Watir
|
|
|
35
35
|
alias_method :empty?, :none?
|
|
36
36
|
|
|
37
37
|
#
|
|
38
|
-
# Get the element at the given index.
|
|
38
|
+
# Get the element at the given index or range.
|
|
39
39
|
#
|
|
40
40
|
# Any call to an ElementCollection including an adjacent selector
|
|
41
41
|
# can not be lazy loaded because it must store correct type
|
|
42
42
|
#
|
|
43
|
-
#
|
|
44
|
-
#
|
|
43
|
+
# Ranges can not be lazy loaded
|
|
44
|
+
#
|
|
45
|
+
# @param [Integer, Range] value Index (0-based) or Range of desired element(s)
|
|
46
|
+
# @return [Watir::Element, Watir::ElementCollection] Returns an instance of a Watir::Element subclass
|
|
45
47
|
#
|
|
46
48
|
|
|
47
|
-
def [](
|
|
48
|
-
if
|
|
49
|
-
to_a[
|
|
49
|
+
def [](value)
|
|
50
|
+
if value.is_a?(Range)
|
|
51
|
+
to_a[value]
|
|
52
|
+
elsif @selector.key? :adjacent
|
|
53
|
+
to_a[value] || element_class.new(@query_scope, {invalid_locator: true})
|
|
50
54
|
else
|
|
51
|
-
element_class.new(@query_scope, @selector.merge(index:
|
|
55
|
+
element_class.new(@query_scope, @selector.merge(index: value))
|
|
52
56
|
end
|
|
53
57
|
end
|
|
54
58
|
|
|
@@ -87,9 +91,9 @@ module Watir
|
|
|
87
91
|
tag_name = element.tag_name.to_sym
|
|
88
92
|
hash[tag_name] ||= 0
|
|
89
93
|
hash[tag_name] += 1
|
|
90
|
-
Watir.
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
Watir.element_class_for(tag_name).new(@query_scope, @selector.merge(element: e,
|
|
95
|
+
tag_name: tag_name,
|
|
96
|
+
index: hash[tag_name] - 1))
|
|
93
97
|
else
|
|
94
98
|
element
|
|
95
99
|
end
|
|
@@ -107,6 +111,16 @@ module Watir
|
|
|
107
111
|
self
|
|
108
112
|
end
|
|
109
113
|
|
|
114
|
+
#
|
|
115
|
+
# Returns browser.
|
|
116
|
+
#
|
|
117
|
+
# @return [Watir::Browser]
|
|
118
|
+
#
|
|
119
|
+
|
|
120
|
+
def browser
|
|
121
|
+
@query_scope.browser
|
|
122
|
+
end
|
|
123
|
+
|
|
110
124
|
#
|
|
111
125
|
# Returns true if two element collections are equal.
|
|
112
126
|
#
|
|
@@ -262,11 +262,12 @@ module Watir
|
|
|
262
262
|
# browser.a(id: "link_2").attribute_value "title"
|
|
263
263
|
# #=> "link_title_2"
|
|
264
264
|
#
|
|
265
|
-
# @param [String] attribute_name
|
|
265
|
+
# @param [String, ::Symbol] attribute_name
|
|
266
266
|
# @return [String, nil]
|
|
267
267
|
#
|
|
268
268
|
|
|
269
269
|
def attribute_value(attribute_name)
|
|
270
|
+
attribute_name = attribute_name.to_s.tr('_', '-') if attribute_name.is_a?(::Symbol)
|
|
270
271
|
element_call { @element.attribute attribute_name }
|
|
271
272
|
end
|
|
272
273
|
alias_method :attribute, :attribute_value
|
|
@@ -402,9 +403,13 @@ module Watir
|
|
|
402
403
|
#
|
|
403
404
|
|
|
404
405
|
def visible?
|
|
406
|
+
Watir.logger.warn "#visible? behavior will be changing slightly, consider switching to #present? (more details: http://watir.com/element-existentialism/)",
|
|
407
|
+
ids: [:visible_element]
|
|
405
408
|
assert_exists
|
|
406
409
|
@element.displayed?
|
|
407
410
|
rescue Selenium::WebDriver::Error::StaleElementReferenceError
|
|
411
|
+
Watir.logger.deprecate "Checking `#visible? == false` to determine a stale element", "`#stale? == true`",
|
|
412
|
+
ids: [:stale_visible]
|
|
408
413
|
reset!
|
|
409
414
|
raise unknown_exception
|
|
410
415
|
end
|
|
@@ -429,7 +434,13 @@ module Watir
|
|
|
429
434
|
#
|
|
430
435
|
|
|
431
436
|
def present?
|
|
432
|
-
|
|
437
|
+
assert_exists
|
|
438
|
+
@element.displayed?
|
|
439
|
+
rescue Selenium::WebDriver::Error::StaleElementReferenceError
|
|
440
|
+
Watir.logger.deprecate "Checking `#present? == false` to determine a stale element", "`#stale? == true`",
|
|
441
|
+
ids: [:stale_present]
|
|
442
|
+
reset!
|
|
443
|
+
false
|
|
433
444
|
rescue UnknownObjectException, UnknownFrameException
|
|
434
445
|
false
|
|
435
446
|
end
|
|
@@ -534,8 +545,8 @@ module Watir
|
|
|
534
545
|
end
|
|
535
546
|
|
|
536
547
|
def wait_for_present
|
|
537
|
-
|
|
538
|
-
return if
|
|
548
|
+
p = present?
|
|
549
|
+
return p if !Watir.relaxed_locate? || p
|
|
539
550
|
|
|
540
551
|
begin
|
|
541
552
|
@query_scope.wait_for_present unless @query_scope.is_a? Browser
|
|
@@ -555,8 +566,7 @@ module Watir
|
|
|
555
566
|
begin
|
|
556
567
|
wait_until(&:enabled?)
|
|
557
568
|
rescue Watir::Wait::TimeoutError
|
|
558
|
-
|
|
559
|
-
raise ObjectDisabledException, message
|
|
569
|
+
raise_disabled
|
|
560
570
|
end
|
|
561
571
|
end
|
|
562
572
|
|
|
@@ -609,7 +619,7 @@ module Watir
|
|
|
609
619
|
end
|
|
610
620
|
|
|
611
621
|
def raise_disabled
|
|
612
|
-
message = "element present
|
|
622
|
+
message = "element present, but timed out after #{Watir.default_timeout} seconds, waiting for #{inspect} to be enabled"
|
|
613
623
|
raise ObjectDisabledException, message
|
|
614
624
|
end
|
|
615
625
|
|
|
@@ -663,11 +673,11 @@ module Watir
|
|
|
663
673
|
retry
|
|
664
674
|
rescue Selenium::WebDriver::Error::ElementNotVisibleError, Selenium::WebDriver::Error::ElementNotInteractableError
|
|
665
675
|
raise_present unless Wait.timer.remaining_time > 0
|
|
666
|
-
raise_present unless
|
|
676
|
+
raise_present unless %i[wait_for_present wait_for_enabled wait_for_writable].include?(precondition)
|
|
667
677
|
retry
|
|
668
678
|
rescue Selenium::WebDriver::Error::InvalidElementStateError
|
|
669
679
|
raise_disabled unless Wait.timer.remaining_time > 0
|
|
670
|
-
raise_disabled unless
|
|
680
|
+
raise_disabled unless %i[wait_for_present wait_for_enabled wait_for_writable].include?(precondition)
|
|
671
681
|
retry
|
|
672
682
|
rescue Selenium::WebDriver::Error::NoSuchWindowError
|
|
673
683
|
raise Exception::NoMatchingWindowFoundException, "browser window was closed"
|
|
@@ -94,7 +94,7 @@ module Watir
|
|
|
94
94
|
#
|
|
95
95
|
|
|
96
96
|
def select_value(str_or_rx)
|
|
97
|
-
Watir.logger.deprecate '#select_value', "#select"
|
|
97
|
+
Watir.logger.deprecate '#select_value', "#select", ids: [:select_value]
|
|
98
98
|
select_by str_or_rx
|
|
99
99
|
end
|
|
100
100
|
|
|
@@ -157,7 +157,8 @@ module Watir
|
|
|
157
157
|
found = find_options(:value, str_or_rx)
|
|
158
158
|
|
|
159
159
|
if found && found.size > 1
|
|
160
|
-
Watir.logger.deprecate "Selecting Multiple Options with #select", "#select_all"
|
|
160
|
+
Watir.logger.deprecate "Selecting Multiple Options with #select", "#select_all",
|
|
161
|
+
ids: [:select_by]
|
|
161
162
|
end
|
|
162
163
|
return select_matching(found) if found && found.any?
|
|
163
164
|
raise NoValueFoundException, "#{str_or_rx.inspect} not found in select list"
|
data/lib/watir/js_execution.rb
CHANGED
|
@@ -33,29 +33,40 @@ module Watir
|
|
|
33
33
|
# browser.li(id: 'non_link_1').flash
|
|
34
34
|
# browser.li(id: 'non_link_1').flash(color: "green", flashes: 3, delay: 0.05)
|
|
35
35
|
# browser.li(id: 'non_link_1').flash(color: "yellow")
|
|
36
|
+
# browser.li(id: 'non_link_1').flash(color: ["yellow", "green"])
|
|
36
37
|
# browser.li(id: 'non_link_1').flash(flashes: 4)
|
|
37
38
|
# browser.li(id: 'non_link_1').flash(delay: 0.1)
|
|
39
|
+
# browser.li(id: 'non_link_1').flash(:fast)
|
|
40
|
+
# browser.li(id: 'non_link_1').flash(:slow)
|
|
41
|
+
# browser.li(id: 'non_link_1').flash(:rainbow)
|
|
38
42
|
#
|
|
39
|
-
# @param [
|
|
43
|
+
# @param [Symbol] preset :fast, :slow, :long or :rainbow for pre-set values
|
|
44
|
+
# @param [String/Array] color what 'color' or [colors] to flash with
|
|
40
45
|
# @param [Integer] flashes number of times element should be flashed
|
|
41
46
|
# @param [Integer, Float] delay how long to wait between flashes
|
|
42
47
|
#
|
|
43
48
|
# @return [Watir::Element]
|
|
44
49
|
#
|
|
45
50
|
|
|
46
|
-
def flash(color: 'red', flashes:
|
|
47
|
-
|
|
51
|
+
def flash(preset = :default, color: 'red', flashes: 10, delay: 0.1)
|
|
52
|
+
presets = {
|
|
53
|
+
fast: { delay: 0.04 },
|
|
54
|
+
slow: { delay: 0.2 },
|
|
55
|
+
long: { flashes: 5, delay: 0.5 },
|
|
56
|
+
rainbow: { flashes: 5, color: %w(red orange yellow green blue indigo violet) }
|
|
57
|
+
}
|
|
58
|
+
return self.flash(presets[preset]) unless presets[preset].nil?
|
|
59
|
+
|
|
60
|
+
background_color = original_color = style("background-color")
|
|
48
61
|
background_color = 'white' if background_color.empty?
|
|
49
|
-
|
|
50
|
-
element_color = 'white' if element_color.empty?
|
|
62
|
+
colors = Array(color).push(background_color)
|
|
51
63
|
|
|
52
|
-
(
|
|
53
|
-
|
|
54
|
-
element_call { execute_js(:backgroundColor, @element, nextcolor) }
|
|
64
|
+
(colors * flashes).each do |next_color|
|
|
65
|
+
element_call { execute_js(:backgroundColor, @element, next_color) }
|
|
55
66
|
sleep(delay)
|
|
56
67
|
end
|
|
57
68
|
|
|
58
|
-
element_call { execute_js(:backgroundColor, @element,
|
|
69
|
+
element_call { execute_js(:backgroundColor, @element, original_color) }
|
|
59
70
|
|
|
60
71
|
self
|
|
61
72
|
end
|
data/lib/watir/legacy_wait.rb
CHANGED
|
@@ -83,7 +83,7 @@ module Watir
|
|
|
83
83
|
def when_present(timeout = nil)
|
|
84
84
|
warning = '#when_present has been deprecated and is unlikely to be needed; '
|
|
85
85
|
warning << 'replace this with #wait_until_present if a wait is still needed'
|
|
86
|
-
Watir.logger.warn warning
|
|
86
|
+
Watir.logger.warn warning, ids: [:when_present, :deprecations]
|
|
87
87
|
|
|
88
88
|
timeout ||= Watir.default_timeout
|
|
89
89
|
message = "waiting for #{selector_string} to become present"
|
|
@@ -109,7 +109,8 @@ module Watir
|
|
|
109
109
|
#
|
|
110
110
|
|
|
111
111
|
def when_enabled(timeout = nil)
|
|
112
|
-
Watir.logger.warn '#when_enabled has been deprecated and is unlikely to be needed'
|
|
112
|
+
Watir.logger.warn '#when_enabled has been deprecated and is unlikely to be needed',
|
|
113
|
+
ids: [:when_enabled, :deprecations]
|
|
113
114
|
|
|
114
115
|
timeout ||= Watir.default_timeout
|
|
115
116
|
message = "waiting for #{selector_string} to become enabled"
|
data/lib/watir/locators.rb
CHANGED
|
@@ -26,23 +26,23 @@ module Watir
|
|
|
26
26
|
module Locators
|
|
27
27
|
module ClassHelpers
|
|
28
28
|
def locator_class
|
|
29
|
-
class_from_string("#{
|
|
29
|
+
class_from_string("#{browser.locator_namespace}::#{element_class_name}::Locator") ||
|
|
30
30
|
class_from_string("Watir::Locators::#{element_class_name}::Locator") ||
|
|
31
|
-
class_from_string("#{
|
|
31
|
+
class_from_string("#{browser.locator_namespace}::Element::Locator") ||
|
|
32
32
|
Watir::Locators::Element::Locator
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def element_validator_class
|
|
36
|
-
class_from_string("#{
|
|
36
|
+
class_from_string("#{browser.locator_namespace}::#{element_class_name}::Validator") ||
|
|
37
37
|
class_from_string("Watir::Locators::#{element_class_name}::Validator") ||
|
|
38
|
-
class_from_string("#{
|
|
38
|
+
class_from_string("#{browser.locator_namespace}::Element::Validator") ||
|
|
39
39
|
Watir::Locators::Element::Validator
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def selector_builder_class
|
|
43
|
-
class_from_string("#{
|
|
43
|
+
class_from_string("#{browser.locator_namespace}::#{element_class_name}::SelectorBuilder") ||
|
|
44
44
|
class_from_string("Watir::Locators::#{element_class_name}::SelectorBuilder") ||
|
|
45
|
-
class_from_string("#{
|
|
45
|
+
class_from_string("#{browser.locator_namespace}::Element::SelectorBuilder") ||
|
|
46
46
|
Watir::Locators::Element::SelectorBuilder
|
|
47
47
|
end
|
|
48
48
|
|