watir 6.16.5 → 6.19.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/actions/enable-safari/action.yml +11 -0
- data/.github/actions/install-chrome/action.yml +11 -0
- data/.github/workflows/linux.yml +61 -0
- data/.github/workflows/mac.yml +55 -0
- data/.github/workflows/unit.yml +37 -0
- data/.github/workflows/windows.yml +39 -0
- data/.rubocop.yml +32 -107
- data/.rubocop_todo.yml +36 -0
- data/CHANGES.md +52 -0
- data/Gemfile +3 -1
- data/LICENSE +2 -2
- data/README.md +9 -10
- data/Rakefile +4 -4
- data/lib/watir/adjacent.rb +8 -10
- data/lib/watir/after_hooks.rb +4 -4
- data/lib/watir/alert.rb +1 -0
- data/lib/watir/attribute_helper.rb +2 -0
- data/lib/watir/browser.rb +7 -3
- data/lib/watir/capabilities.rb +245 -97
- data/lib/watir/cookies.rb +3 -1
- data/lib/watir/element_collection.rb +21 -6
- data/lib/watir/elements/element.rb +66 -53
- data/lib/watir/elements/file_field.rb +1 -0
- data/lib/watir/elements/html_elements.rb +0 -1
- data/lib/watir/elements/iframe.rb +4 -3
- data/lib/watir/elements/link.rb +0 -9
- data/lib/watir/elements/radio.rb +1 -1
- data/lib/watir/elements/select.rb +22 -7
- data/lib/watir/generator/base/spec_extractor.rb +4 -4
- data/lib/watir/generator/html/generator.rb +1 -1
- data/lib/watir/has_window.rb +17 -15
- data/lib/watir/http_client.rb +17 -0
- data/lib/watir/js_execution.rb +3 -3
- data/lib/watir/js_snippets.rb +2 -2
- data/lib/watir/legacy_wait.rb +1 -1
- data/lib/watir/locators/element/selector_builder/xpath.rb +50 -15
- data/lib/watir/locators/element/selector_builder.rb +12 -13
- data/lib/watir/locators/text_field/selector_builder/xpath.rb +3 -1
- data/lib/watir/locators.rb +1 -3
- data/lib/watir/logger.rb +7 -20
- data/lib/watir/radio_set.rb +2 -2
- data/lib/watir/user_editable.rb +6 -2
- data/lib/watir/version.rb +1 -1
- data/lib/watir/wait/timer.rb +1 -1
- data/lib/watir/wait.rb +2 -0
- data/lib/watir/window.rb +8 -4
- data/lib/watir/window_collection.rb +114 -0
- data/lib/watir-webdriver.rb +1 -1
- data/lib/watir.rb +3 -1
- data/lib/watirspec/guards.rb +1 -1
- data/lib/watirspec/implementation.rb +3 -5
- data/lib/watirspec/rake_tasks.rb +2 -0
- data/lib/watirspec/runner.rb +6 -2
- data/lib/watirspec/server.rb +1 -1
- data/lib/watirspec.rb +2 -1
- data/spec/spec_helper.rb +2 -7
- data/spec/unit/capabilities_spec.rb +1234 -18
- data/spec/unit/container_spec.rb +1 -1
- data/spec/unit/logger_spec.rb +5 -7
- data/spec/unit/match_elements/element_spec.rb +17 -15
- data/spec/unit/selector_builder/button_spec.rb +16 -15
- data/spec/unit/selector_builder/element_spec.rb +58 -9
- data/spec/unit/selector_builder/text_field_spec.rb +14 -14
- data/spec/unit/unit_helper.rb +2 -4
- data/spec/watirspec/after_hooks_spec.rb +58 -68
- data/spec/watirspec/alert_spec.rb +69 -79
- data/spec/watirspec/browser_spec.rb +51 -48
- data/spec/watirspec/cookies_spec.rb +52 -37
- data/spec/watirspec/drag_and_drop_spec.rb +14 -38
- data/spec/watirspec/elements/button_spec.rb +2 -0
- data/spec/watirspec/elements/buttons_spec.rb +1 -1
- data/spec/watirspec/elements/checkbox_spec.rb +8 -4
- data/spec/watirspec/elements/date_field_spec.rb +18 -9
- data/spec/watirspec/elements/date_time_field_spec.rb +3 -4
- data/spec/watirspec/elements/div_spec.rb +62 -54
- data/spec/watirspec/elements/element_spec.rb +73 -88
- data/spec/watirspec/elements/elements_spec.rb +12 -3
- data/spec/watirspec/elements/filefield_spec.rb +25 -50
- data/spec/watirspec/elements/form_spec.rb +6 -8
- data/spec/watirspec/elements/frame_spec.rb +10 -13
- data/spec/watirspec/elements/iframe_spec.rb +12 -9
- data/spec/watirspec/elements/iframes_spec.rb +2 -2
- data/spec/watirspec/elements/link_spec.rb +23 -12
- data/spec/watirspec/elements/links_spec.rb +11 -3
- data/spec/watirspec/elements/option_spec.rb +15 -17
- data/spec/watirspec/elements/select_list_spec.rb +222 -117
- data/spec/watirspec/elements/text_field_spec.rb +8 -4
- data/spec/watirspec/elements/tr_spec.rb +0 -9
- data/spec/watirspec/html/forms_with_input_elements.html +1 -0
- data/spec/watirspec/html/iframes.html +3 -0
- data/spec/watirspec/html/non_control_elements.html +4 -4
- data/spec/watirspec/html/right_click.html +12 -0
- data/spec/watirspec/html/special_chars.html +3 -0
- data/spec/watirspec/html/wait.html +6 -6
- data/spec/watirspec/html/window_switching.html +10 -0
- data/spec/watirspec/legacy_wait_spec.rb +216 -0
- data/spec/watirspec/special_chars_spec.rb +10 -0
- data/spec/watirspec/support/rspec_matchers.rb +33 -14
- data/spec/watirspec/user_editable_spec.rb +1 -1
- data/spec/watirspec/wait_spec.rb +257 -305
- data/spec/watirspec/window_switching_spec.rb +347 -211
- data/spec/watirspec_helper.rb +17 -20
- data/support/doctest_helper.rb +0 -2
- data/watir.gemspec +6 -7
- metadata +37 -26
- data/.travis.yml +0 -84
- data/appveyor.yml +0 -12
- data/lib/watir/elements/area.rb +0 -10
- data/spec/watirspec/relaxed_locate_spec.rb +0 -113
@@ -6,11 +6,10 @@ module Watir
|
|
6
6
|
attr_reader :custom_attributes, :built
|
7
7
|
|
8
8
|
WILDCARD_ATTRIBUTE = /^(aria|data)_(.+)$/.freeze
|
9
|
-
INTEGER_CLASS = Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.4') ? Fixnum : Integer
|
10
9
|
VALID_WHATS = Hash.new([String, Regexp, TrueClass, FalseClass]).merge(adjacent: [::Symbol],
|
11
10
|
xpath: [String],
|
12
11
|
css: [String],
|
13
|
-
index: [
|
12
|
+
index: [Integer],
|
14
13
|
visible: [TrueClass, FalseClass],
|
15
14
|
tag_name: [String, Regexp, ::Symbol],
|
16
15
|
visible_text: [String, Regexp],
|
@@ -53,11 +52,7 @@ module Watir
|
|
53
52
|
if @selector.key?(:class) || @selector.key?(:class_name)
|
54
53
|
classes = ([@selector[:class]].flatten + [@selector.delete(:class_name)].flatten).compact
|
55
54
|
|
56
|
-
classes
|
57
|
-
next unless class_name.is_a?(String) && class_name.strip.include?(' ')
|
58
|
-
|
59
|
-
deprecate_class_array(class_name)
|
60
|
-
end
|
55
|
+
deprecate_class_array(classes)
|
61
56
|
|
62
57
|
@selector[:class] = classes
|
63
58
|
end
|
@@ -83,11 +78,15 @@ module Watir
|
|
83
78
|
scope_invalid_locators.empty?
|
84
79
|
end
|
85
80
|
|
86
|
-
def deprecate_class_array(
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
81
|
+
def deprecate_class_array(class_array)
|
82
|
+
class_array.each do |class_name|
|
83
|
+
next unless class_name.is_a?(String) && class_name.strip.include?(' ')
|
84
|
+
|
85
|
+
dep = "Using the :class locator to locate multiple classes with a String value (i.e. \"#{class_name}\")"
|
86
|
+
Watir.logger.deprecate dep,
|
87
|
+
"Array (e.g. #{class_name.split})",
|
88
|
+
ids: [:class_array]
|
89
|
+
end
|
91
90
|
end
|
92
91
|
|
93
92
|
def check_type(how, what)
|
@@ -143,7 +142,7 @@ module Watir
|
|
143
142
|
|
144
143
|
# Extensions implement this method when creating a different selector builder
|
145
144
|
def implementation_class
|
146
|
-
|
145
|
+
Watir.const_get("#{self.class.name}::XPath")
|
147
146
|
end
|
148
147
|
|
149
148
|
def build_wd_selector(selector)
|
@@ -36,7 +36,9 @@ module Watir
|
|
36
36
|
|
37
37
|
def negative_type_text
|
38
38
|
Watir::TextField::NON_TEXT_TYPES.map { |type|
|
39
|
-
|
39
|
+
lhs = lhs_for(:type, downcase: true)
|
40
|
+
rhs = SelectorBuilder::XpathSupport.downcase(SelectorBuilder::XpathSupport.escape(type))
|
41
|
+
"#{lhs}!=#{rhs}"
|
40
42
|
}.join(' and ')
|
41
43
|
end
|
42
44
|
end
|
data/lib/watir/locators.rb
CHANGED
data/lib/watir/logger.rb
CHANGED
@@ -2,7 +2,7 @@ require 'forwardable'
|
|
2
2
|
require 'logger'
|
3
3
|
|
4
4
|
# Code adapted from Selenium Implementation
|
5
|
-
# https://github.com/SeleniumHQ/selenium/blob/
|
5
|
+
# https://github.com/SeleniumHQ/selenium/blob/trunk/rb/lib/selenium/webdriver/common/logger.rb
|
6
6
|
|
7
7
|
module Watir
|
8
8
|
#
|
@@ -25,7 +25,7 @@ module Watir
|
|
25
25
|
:warn?,
|
26
26
|
:error, :error?,
|
27
27
|
:fatal, :fatal?,
|
28
|
-
:level
|
28
|
+
:level, :level=
|
29
29
|
|
30
30
|
def initialize(progname = 'Watir')
|
31
31
|
@logger = create_logger($stdout)
|
@@ -34,8 +34,7 @@ module Watir
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def ignore(ids)
|
37
|
-
|
38
|
-
@ignored.concat ids.map(&:to_s)
|
37
|
+
@ignored.concat Array(ids).map(&:to_s)
|
39
38
|
end
|
40
39
|
|
41
40
|
def output=(io)
|
@@ -51,22 +50,6 @@ module Watir
|
|
51
50
|
@logger.warn(msg, &block) unless (@ignored & ids).any?
|
52
51
|
end
|
53
52
|
|
54
|
-
#
|
55
|
-
# For Ruby < 2.4 compatibility
|
56
|
-
# Based on https://github.com/ruby/ruby/blob/ruby_2_3/lib/logger.rb#L250
|
57
|
-
#
|
58
|
-
|
59
|
-
def level=(severity)
|
60
|
-
if severity.is_a?(Integer)
|
61
|
-
@logger.level = severity
|
62
|
-
else
|
63
|
-
levels = %w[debug info warn error fatal unknown]
|
64
|
-
raise ArgumentError, "invalid log level: #{severity}" unless levels.include? severity.to_s.downcase
|
65
|
-
|
66
|
-
@logger.level = severity.to_s.upcase
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
53
|
#
|
71
54
|
# Returns IO object used by logger internally.
|
72
55
|
#
|
@@ -96,6 +79,10 @@ module Watir
|
|
96
79
|
warn "[DEPRECATION] #{msg}#{old} is deprecated. Use #{new} instead#{ref_msg}"
|
97
80
|
end
|
98
81
|
|
82
|
+
def selenium=(val)
|
83
|
+
Selenium::WebDriver.logger.level = val
|
84
|
+
end
|
85
|
+
|
99
86
|
private
|
100
87
|
|
101
88
|
def create_logger(output)
|
data/lib/watir/radio_set.rb
CHANGED
@@ -4,7 +4,7 @@ module Watir
|
|
4
4
|
include Exception
|
5
5
|
include Enumerable
|
6
6
|
|
7
|
-
delegate %i[exists? present? visible? browser] => :source
|
7
|
+
delegate %i[exist? exists? present? visible? browser] => :source
|
8
8
|
|
9
9
|
attr_reader :source, :frame
|
10
10
|
|
@@ -201,7 +201,7 @@ module Watir
|
|
201
201
|
end
|
202
202
|
alias eql? ==
|
203
203
|
|
204
|
-
#
|
204
|
+
# Delegating to Private Methods
|
205
205
|
%i[assert_exists element_call].each do |method|
|
206
206
|
define_method(method) do |*args, &blk|
|
207
207
|
source.send(method, *args, &blk)
|
data/lib/watir/user_editable.rb
CHANGED
@@ -21,13 +21,17 @@ module Watir
|
|
21
21
|
# @param [String, Symbol] args
|
22
22
|
#
|
23
23
|
|
24
|
+
def content_editable
|
25
|
+
defined?(@content_editable) && content_editable?
|
26
|
+
end
|
27
|
+
|
24
28
|
def set!(*args)
|
25
29
|
msg = '#set! does not support special keys, use #set instead'
|
26
30
|
raise ArgumentError, msg if args.any? { |v| v.is_a?(::Symbol) }
|
27
31
|
|
28
32
|
input_value = args.join
|
29
33
|
set input_value[0]
|
30
|
-
return content_editable_set!(*args) if
|
34
|
+
return content_editable_set!(*args) if content_editable
|
31
35
|
|
32
36
|
element_call { execute_js(:setValue, @element, input_value[0..-2]) }
|
33
37
|
append(input_value[-1])
|
@@ -43,7 +47,7 @@ module Watir
|
|
43
47
|
#
|
44
48
|
|
45
49
|
def append(*args)
|
46
|
-
raise NotImplementedError, '#append method is not supported with contenteditable element' if
|
50
|
+
raise NotImplementedError, '#append method is not supported with contenteditable element' if content_editable
|
47
51
|
|
48
52
|
send_keys(*args)
|
49
53
|
end
|
data/lib/watir/version.rb
CHANGED
data/lib/watir/wait/timer.rb
CHANGED
data/lib/watir/wait.rb
CHANGED
data/lib/watir/window.rb
CHANGED
@@ -6,7 +6,7 @@ module Watir
|
|
6
6
|
|
7
7
|
attr_reader :browser
|
8
8
|
|
9
|
-
def initialize(browser, selector)
|
9
|
+
def initialize(browser, selector = {})
|
10
10
|
@browser = browser
|
11
11
|
@driver = browser.driver
|
12
12
|
@selector = selector
|
@@ -16,7 +16,7 @@ module Watir
|
|
16
16
|
elsif selector.key? :handle
|
17
17
|
@handle = selector.delete :handle
|
18
18
|
else
|
19
|
-
return if selector.keys.all? { |k| %i[title url index].include? k }
|
19
|
+
return if selector.keys.all? { |k| %i[title url index element].include? k }
|
20
20
|
|
21
21
|
raise ArgumentError, "invalid window selector: #{selector_string}"
|
22
22
|
end
|
@@ -207,6 +207,9 @@ module Watir
|
|
207
207
|
if @selector.empty?
|
208
208
|
nil
|
209
209
|
elsif @selector.key?(:index)
|
210
|
+
Watir.logger.deprecate 'Using :index as a selector for Window', ':title or :url or :element',
|
211
|
+
reference: 'http://watir.com/guides/windows/#locating-by-index-is-no-longer-supported',
|
212
|
+
ids: [:window_index]
|
210
213
|
@driver.window_handles[Integer(@selector[:index])]
|
211
214
|
else
|
212
215
|
@driver.window_handles.find { |wh| matches?(wh) }
|
@@ -230,10 +233,11 @@ module Watir
|
|
230
233
|
@driver.switch_to.window(handle) do
|
231
234
|
matches_title = @selector[:title].nil? || @browser.title =~ /#{@selector[:title]}/
|
232
235
|
matches_url = @selector[:url].nil? || @browser.url =~ /#{@selector[:url]}/
|
236
|
+
matches_element = @selector[:element].nil? || @selector[:element].exists?
|
233
237
|
|
234
|
-
matches_title && matches_url
|
238
|
+
matches_title && matches_url && matches_element
|
235
239
|
end
|
236
|
-
rescue Selenium::WebDriver::Error::NoSuchWindowError
|
240
|
+
rescue Selenium::WebDriver::Error::NoSuchWindowError
|
237
241
|
# the window may disappear while we're iterating.
|
238
242
|
false
|
239
243
|
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
module Watir
|
2
|
+
class WindowCollection
|
3
|
+
include Enumerable
|
4
|
+
include Waitable
|
5
|
+
|
6
|
+
def initialize(browser, selector = {})
|
7
|
+
unless selector.keys.all? { |k| %i[title url element].include? k }
|
8
|
+
raise ArgumentError, "invalid window selector: #{selector.inspect}"
|
9
|
+
end
|
10
|
+
|
11
|
+
@browser = browser
|
12
|
+
@selector = selector
|
13
|
+
end
|
14
|
+
|
15
|
+
#
|
16
|
+
# Yields each window in collection.
|
17
|
+
#
|
18
|
+
# @yieldparam [Watir::Window]
|
19
|
+
#
|
20
|
+
|
21
|
+
def each(&blk)
|
22
|
+
reset!
|
23
|
+
window_list.each(&blk)
|
24
|
+
end
|
25
|
+
|
26
|
+
alias length count
|
27
|
+
alias size count
|
28
|
+
alias empty? none?
|
29
|
+
|
30
|
+
#
|
31
|
+
# First window of the collection
|
32
|
+
#
|
33
|
+
# @note windows in a collection are not ordered so this is not reliably
|
34
|
+
# @deprecated use Browser#switch_window or a better Window locator
|
35
|
+
# @return [Watir::Window] Returns an instance of a Watir::Window
|
36
|
+
#
|
37
|
+
|
38
|
+
def first
|
39
|
+
self[0]
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# Last window of the collection
|
44
|
+
#
|
45
|
+
# @note windows in a collection are not ordered so this is not reliably
|
46
|
+
# @deprecated use Browser#switch_window or a better Window locator
|
47
|
+
# @return [Watir::Window] Returns an instance of a Watir::Window
|
48
|
+
#
|
49
|
+
|
50
|
+
def last
|
51
|
+
self[-1]
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# Get the window at the given index or range.
|
56
|
+
#
|
57
|
+
# @note windows in a collection are not ordered so this is not reliably
|
58
|
+
# @deprecated use Browser#switch_window or a better Window locator
|
59
|
+
# @param [Integer, Range] value Index (0-based) or Range of desired window(s)
|
60
|
+
# @return [Watir::Window] Returns an instance of a Watir::Window
|
61
|
+
#
|
62
|
+
|
63
|
+
def [](value)
|
64
|
+
old = 'using indexing with windows'
|
65
|
+
new = 'Browser#switch_window or Browser#window with :title, :url or :element selectors'
|
66
|
+
reference = 'http://watir.com/window_indexes'
|
67
|
+
Watir.logger.deprecate old, new, reference: reference, ids: [:window_index]
|
68
|
+
|
69
|
+
window_list[value]
|
70
|
+
end
|
71
|
+
|
72
|
+
def ==(other)
|
73
|
+
window_list == other.send(:window_list)
|
74
|
+
end
|
75
|
+
alias eql? ==
|
76
|
+
|
77
|
+
def reset!
|
78
|
+
@window_list = nil
|
79
|
+
end
|
80
|
+
|
81
|
+
def to_a
|
82
|
+
old = 'WindowCollection#to_a to interact with indexed windows'
|
83
|
+
new = 'Enumerable methods to iterate over windows'
|
84
|
+
reference = 'http://watir.com/window_indexes'
|
85
|
+
Watir.logger.deprecate old, new, reference: reference, ids: [:window_index]
|
86
|
+
|
87
|
+
window_list
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def window_list
|
93
|
+
@window_list ||= begin
|
94
|
+
handles = @browser.driver.window_handles.select { |wh| matches?(wh) }
|
95
|
+
handles.map { |wh| Window.new(@browser, handle: wh) }
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# NOTE: This is the exact same code from `Window#matches?`
|
100
|
+
# TODO: Move this code into a separate WindowLocator class
|
101
|
+
def matches?(handle)
|
102
|
+
@selector.empty? || @browser.driver.switch_to.window(handle) do
|
103
|
+
matches_title = @selector[:title].nil? || @browser.title =~ /#{@selector[:title]}/
|
104
|
+
matches_url = @selector[:url].nil? || @browser.url =~ /#{@selector[:url]}/
|
105
|
+
matches_element = @selector[:element].nil? || @selector[:element].exists?
|
106
|
+
|
107
|
+
matches_title && matches_url && matches_element
|
108
|
+
end
|
109
|
+
rescue Selenium::WebDriver::Error::NoSuchWindowError
|
110
|
+
# the window may disappear while we're iterating.
|
111
|
+
false
|
112
|
+
end
|
113
|
+
end # Window
|
114
|
+
end # Watir
|
data/lib/watir-webdriver.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
require 'watir'
|
2
|
-
warn Kernel.caller.first
|
2
|
+
warn "#{Kernel.caller.first}: `require 'watir-webdriver'` is deprecated. Please, use `require 'watir'`."
|
data/lib/watir.rb
CHANGED
@@ -6,6 +6,7 @@ require 'watir/legacy_wait'
|
|
6
6
|
require 'watir/wait'
|
7
7
|
require 'watir/exception'
|
8
8
|
require 'watir/window'
|
9
|
+
require 'watir/window_collection'
|
9
10
|
require 'watir/has_window'
|
10
11
|
require 'watir/adjacent'
|
11
12
|
require 'watir/js_execution'
|
@@ -13,12 +14,14 @@ require 'watir/alert'
|
|
13
14
|
require 'watir/js_snippets'
|
14
15
|
require 'watir/container'
|
15
16
|
require 'watir/cookies'
|
17
|
+
require 'watir/http_client'
|
16
18
|
require 'watir/capabilities'
|
17
19
|
require 'watir/navigation'
|
18
20
|
require 'watir/browser'
|
19
21
|
require 'watir/screenshot'
|
20
22
|
require 'watir/after_hooks'
|
21
23
|
require 'watir/logger'
|
24
|
+
require 'watir/version'
|
22
25
|
|
23
26
|
module Watir
|
24
27
|
@relaxed_locate = true
|
@@ -114,7 +117,6 @@ require 'watir/elements/element'
|
|
114
117
|
require 'watir/elements/html_elements'
|
115
118
|
require 'watir/elements/svg_elements'
|
116
119
|
|
117
|
-
require 'watir/elements/area'
|
118
120
|
require 'watir/elements/button'
|
119
121
|
require 'watir/elements/cell'
|
120
122
|
require 'watir/elements/checkbox'
|
data/lib/watirspec/guards.rb
CHANGED
@@ -17,7 +17,7 @@ module WatirSpec
|
|
17
17
|
"\tnone."
|
18
18
|
else
|
19
19
|
gs.each do |guard|
|
20
|
-
guard[:data][:file] = guard[:data][:file][%r{
|
20
|
+
guard[:data][:file] = guard[:data][:file][%r{/spec/(.*):}, 1]
|
21
21
|
guard_name = "#{guard[:name]}:".ljust(15)
|
22
22
|
str << " \t#{guard_name} #{guard[:data].inspect}\n"
|
23
23
|
end
|
@@ -1,16 +1,14 @@
|
|
1
1
|
module WatirSpec
|
2
2
|
class Implementation
|
3
3
|
attr_writer :name, :guard_proc, :browser_class
|
4
|
-
attr_accessor :browser_args
|
4
|
+
attr_accessor :browser_args, :driver_info
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@guard_proc = nil
|
8
8
|
end
|
9
9
|
|
10
|
-
def initialize_copy(
|
11
|
-
|
12
|
-
# Backward compatibility < Ruby 2.4
|
13
|
-
@browser_args = browser_args.map { |arg| arg.is_a?(Symbol) ? arg : arg.dup }
|
10
|
+
def initialize_copy(_orig)
|
11
|
+
@browser_args = browser_args.map(&:dup)
|
14
12
|
end
|
15
13
|
|
16
14
|
def browser_class
|
data/lib/watirspec/rake_tasks.rb
CHANGED
data/lib/watirspec/runner.rb
CHANGED
@@ -10,6 +10,10 @@ module WatirSpec
|
|
10
10
|
def messages
|
11
11
|
browser.div(id: 'messages').divs.map(&:text)
|
12
12
|
end
|
13
|
+
|
14
|
+
def event_log
|
15
|
+
browser.div(id: 'log').wait_until(&:present?).ps.map(&:text)
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
19
|
module_function
|
@@ -29,7 +33,7 @@ module WatirSpec
|
|
29
33
|
end
|
30
34
|
|
31
35
|
def execute_if_necessary
|
32
|
-
execute if !@executed && @execute
|
36
|
+
execute if (!defined?(@executed) || !@executed) && @execute
|
33
37
|
end
|
34
38
|
|
35
39
|
def configure
|
@@ -41,7 +45,7 @@ module WatirSpec
|
|
41
45
|
config.include(MessagesHelper)
|
42
46
|
|
43
47
|
config.before(:suite) { $browser = WatirSpec.new_browser }
|
44
|
-
config.after(:suite) { $browser
|
48
|
+
config.after(:suite) { $browser&.close }
|
45
49
|
end
|
46
50
|
end
|
47
51
|
|
data/lib/watirspec/server.rb
CHANGED
data/lib/watirspec.rb
CHANGED
@@ -31,7 +31,7 @@ module WatirSpec
|
|
31
31
|
|
32
32
|
def load_support
|
33
33
|
root = File.expand_path('../spec/watirspec', __dir__)
|
34
|
-
Dir.glob("#{root}/support/**/*.rb").each do |file|
|
34
|
+
Dir.glob("#{root}/support/**/*.rb").sort.each do |file|
|
35
35
|
require file
|
36
36
|
end
|
37
37
|
end
|
@@ -77,6 +77,7 @@ module WatirSpec
|
|
77
77
|
|
78
78
|
info << caps.browser_name.to_s
|
79
79
|
info << caps.version.to_s
|
80
|
+
info << @implementation.driver_info
|
80
81
|
|
81
82
|
Watir.logger.warn "running watirspec against #{info.join ' '} using:\n#{WatirSpec.implementation.inspect_args}",
|
82
83
|
ids: [:browser_info]
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
3
|
|
4
|
-
if ENV['
|
4
|
+
if ENV['GITHUB_ACTIONS'] || ENV['COVERAGE']
|
5
5
|
require 'coveralls'
|
6
6
|
require 'simplecov'
|
7
7
|
require 'simplecov-console'
|
@@ -19,11 +19,10 @@ if ENV['TRAVIS'] || ENV['COVERAGE']
|
|
19
19
|
end
|
20
20
|
|
21
21
|
require 'watir'
|
22
|
-
require 'webdrivers'
|
23
22
|
require 'locator_spec_helper'
|
24
23
|
require 'rspec'
|
25
24
|
|
26
|
-
if ENV['
|
25
|
+
if ENV['GITHUB_ACTIONS']
|
27
26
|
require 'rspec/retry'
|
28
27
|
RSpec.configure do |config|
|
29
28
|
config.verbose_retry = true
|
@@ -36,7 +35,3 @@ end
|
|
36
35
|
SELENIUM_SELECTORS = %i[css tag_name xpath link_text partial_link_text link].freeze
|
37
36
|
|
38
37
|
Watir.relaxed_locate = false if ENV['RELAXED_LOCATE'] == 'false'
|
39
|
-
|
40
|
-
ENV['DISPLAY'] = ':99.0' if ENV['TRAVIS']
|
41
|
-
|
42
|
-
raise 'DISPLAY not set' if Selenium::WebDriver::Platform.linux? && ENV['DISPLAY'].nil?
|