watir 6.5.0 → 6.6.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 +58 -21
- data/CHANGES.md +11 -0
- data/Rakefile +3 -5
- data/lib/watir.rb +14 -2
- data/lib/watir/adjacent.rb +20 -27
- data/lib/watir/alert.rb +1 -1
- data/lib/watir/attribute_helper.rb +1 -1
- data/lib/watir/browser.rb +6 -3
- data/lib/watir/capabilities.rb +95 -0
- data/lib/watir/cookies.rb +5 -6
- data/lib/watir/element_collection.rb +17 -0
- data/lib/watir/elements/element.rb +12 -15
- data/lib/watir/elements/iframe.rb +1 -1
- data/lib/watir/elements/option.rb +5 -6
- data/lib/watir/elements/select.rb +52 -36
- data/lib/watir/legacy_wait.rb +2 -2
- data/lib/watir/locators/button/selector_builder.rb +10 -7
- data/lib/watir/locators/element/locator.rb +2 -2
- data/lib/watir/locators/element/selector_builder.rb +10 -4
- data/lib/watir/locators/element/selector_builder/xpath.rb +22 -3
- data/lib/watir/logger.rb +109 -0
- data/lib/watir/wait.rb +6 -6
- data/lib/watirspec.rb +1 -1
- data/lib/watirspec/guards.rb +4 -4
- data/lib/watirspec/implementation.rb +13 -5
- data/lib/watirspec/remote_server.rb +38 -0
- data/lib/watirspec/runner.rb +2 -2
- data/lib/watirspec/server.rb +1 -1
- data/spec/browser_spec.rb +101 -17
- data/spec/element_locator_spec.rb +1 -1
- data/spec/element_spec.rb +1 -1
- data/spec/logger_spec.rb +46 -0
- data/spec/watirspec/adjacent_spec.rb +45 -0
- data/spec/watirspec/after_hooks_spec.rb +45 -40
- data/spec/watirspec/alert_spec.rb +20 -14
- data/spec/watirspec/browser_spec.rb +71 -77
- data/spec/watirspec/cookies_spec.rb +13 -16
- data/spec/watirspec/drag_and_drop_spec.rb +6 -6
- data/spec/watirspec/elements/button_spec.rb +14 -7
- data/spec/watirspec/elements/collections_spec.rb +18 -1
- data/spec/watirspec/elements/dd_spec.rb +4 -2
- data/spec/watirspec/elements/del_spec.rb +12 -10
- data/spec/watirspec/elements/div_spec.rb +17 -13
- data/spec/watirspec/elements/dl_spec.rb +4 -2
- data/spec/watirspec/elements/form_spec.rb +8 -6
- data/spec/watirspec/elements/frame_spec.rb +27 -19
- data/spec/watirspec/elements/iframe_spec.rb +28 -17
- data/spec/watirspec/elements/ins_spec.rb +12 -10
- data/spec/watirspec/elements/option_spec.rb +17 -33
- data/spec/watirspec/elements/select_list_spec.rb +111 -97
- data/spec/watirspec/elements/span_spec.rb +12 -10
- data/spec/watirspec/elements/table_spec.rb +13 -11
- data/spec/watirspec/elements/tbody_spec.rb +13 -11
- data/spec/watirspec/elements/td_spec.rb +6 -4
- data/spec/watirspec/elements/text_field_spec.rb +19 -17
- data/spec/watirspec/elements/tr_spec.rb +12 -8
- data/spec/watirspec/html/javascript/helpers.js +2 -2
- data/spec/watirspec/html/nested_elements.html +5 -5
- data/spec/watirspec/relaxed_locate_spec.rb +13 -19
- data/spec/watirspec/wait_spec.rb +279 -301
- data/spec/watirspec/window_switching_spec.rb +190 -174
- data/spec/watirspec_helper.rb +64 -122
- data/support/doctest_helper.rb +4 -0
- data/watir.gemspec +2 -2
- metadata +15 -4
data/spec/watirspec_helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'watirspec'
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
class
|
4
|
+
class LocalConfig
|
5
5
|
def initialize(imp)
|
6
6
|
@imp = imp
|
7
7
|
end
|
@@ -10,68 +10,30 @@ class ImplementationConfig
|
|
10
10
|
@browser ||= (ENV['WATIR_BROWSER'] || :chrome).to_sym
|
11
11
|
end
|
12
12
|
|
13
|
-
def remote_browser
|
14
|
-
@remote_browser ||= (ENV['REMOTE_BROWSER'] || :chrome).to_sym
|
15
|
-
end
|
16
|
-
|
17
13
|
def configure
|
18
14
|
set_webdriver
|
19
|
-
start_remote_server if remote? && !ENV["REMOTE_SERVER_URL"]
|
20
15
|
set_browser_args
|
21
16
|
set_guard_proc
|
22
17
|
end
|
23
18
|
|
24
19
|
private
|
25
20
|
|
26
|
-
def start_remote_server
|
27
|
-
require 'selenium/server'
|
28
|
-
|
29
|
-
@server ||= Selenium::Server.new(remote_server_jar,
|
30
|
-
port: Selenium::WebDriver::PortProber.above(4444),
|
31
|
-
log: !!$DEBUG,
|
32
|
-
background: true,
|
33
|
-
timeout: 60)
|
34
|
-
|
35
|
-
@server.start
|
36
|
-
at_exit { @server.stop }
|
37
|
-
end
|
38
|
-
|
39
|
-
def remote_server_jar
|
40
|
-
if ENV['LOCAL_SELENIUM']
|
41
|
-
local = File.expand_path('../selenium/buck-out/gen/java/server/src/org/openqa/grid/selenium/selenium.jar')
|
42
|
-
end
|
43
|
-
|
44
|
-
if File.exist?(ENV['REMOTE_SERVER_BINARY'] || '')
|
45
|
-
ENV['REMOTE_SERVER_BINARY']
|
46
|
-
elsif ENV['LOCAL_SELENIUM'] && File.exists?(local)
|
47
|
-
local
|
48
|
-
elsif !Dir.glob('*selenium*.jar').empty?
|
49
|
-
Dir.glob('*selenium*.jar').first
|
50
|
-
else
|
51
|
-
Selenium::Server.download :latest
|
52
|
-
end
|
53
|
-
rescue SocketError
|
54
|
-
# not connected to internet
|
55
|
-
raise Watir::Exception::Error, "unable to find or download selenium-server-standalone jar"
|
56
|
-
end
|
57
|
-
|
58
21
|
def set_webdriver
|
59
22
|
@imp.name = :webdriver
|
60
23
|
@imp.browser_class = Watir::Browser
|
61
24
|
end
|
62
25
|
|
63
26
|
def set_browser_args
|
64
|
-
args =
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
remote_args
|
27
|
+
args = create_args
|
28
|
+
@imp.browser_args = [browser, args]
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_args
|
32
|
+
method = "#{browser}_args".to_sym
|
33
|
+
args = if private_methods.include?(method)
|
34
|
+
send method
|
73
35
|
else
|
74
|
-
{
|
36
|
+
{}
|
75
37
|
end
|
76
38
|
|
77
39
|
if ENV['SELECTOR_STATS']
|
@@ -80,120 +42,100 @@ class ImplementationConfig
|
|
80
42
|
at_exit { listener.report }
|
81
43
|
end
|
82
44
|
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
def ie?
|
87
|
-
[:internet_explorer].include? browser
|
45
|
+
args
|
88
46
|
end
|
89
47
|
|
90
|
-
def
|
91
|
-
|
92
|
-
end
|
48
|
+
def set_guard_proc
|
49
|
+
matching_guards = add_guards
|
93
50
|
|
94
|
-
|
95
|
-
|
51
|
+
@imp.guard_proc = lambda { |args|
|
52
|
+
args.any? { |arg| matching_guards.include?(arg) }
|
53
|
+
}
|
96
54
|
end
|
97
55
|
|
98
|
-
def
|
56
|
+
def add_guards
|
99
57
|
matching_guards = [:webdriver]
|
100
58
|
|
101
|
-
|
102
|
-
|
103
|
-
matching_guards << :remote
|
104
|
-
matching_guards << [:remote, matching_browser]
|
105
|
-
matching_guards << [:remote, :ff_legacy] if @ff_legacy
|
106
|
-
else
|
107
|
-
matching_browser = browser
|
108
|
-
end
|
109
|
-
|
110
|
-
matching_guards << :ff_legacy if @ff_legacy
|
111
|
-
matching_guards << matching_browser
|
112
|
-
matching_guards << [matching_browser, Selenium::WebDriver::Platform.os]
|
59
|
+
matching_guards << browser
|
60
|
+
matching_guards << [browser, Selenium::WebDriver::Platform.os]
|
113
61
|
matching_guards << :relaxed_locate if Watir.relaxed_locate?
|
114
62
|
matching_guards << :not_relaxed_locate unless Watir.relaxed_locate?
|
63
|
+
if @imp.browser_args.last[:headless]
|
64
|
+
matching_guards << :headless
|
65
|
+
end
|
115
66
|
|
116
67
|
if !Selenium::WebDriver::Platform.linux? || ENV['DESKTOP_SESSION']
|
117
68
|
# some specs (i.e. Window#maximize) needs a window manager on linux
|
118
69
|
matching_guards << :window_manager
|
119
70
|
end
|
120
|
-
|
121
|
-
@imp.guard_proc = lambda { |args|
|
122
|
-
args.any? { |arg| matching_guards.include?(arg) }
|
123
|
-
}
|
71
|
+
matching_guards
|
124
72
|
end
|
125
73
|
|
126
74
|
def firefox_args
|
127
|
-
|
128
|
-
Selenium::WebDriver::Firefox::Binary.path = path if path
|
129
|
-
{desired_capabilities: Selenium::WebDriver::Remote::Capabilities.firefox}
|
75
|
+
ENV['FIREFOX_BINARY'] ? {options: {binary: ENV['FIREFOX_BINARY']}} : {}
|
130
76
|
end
|
131
77
|
|
132
|
-
def
|
133
|
-
|
134
|
-
@ff_legacy = true
|
135
|
-
caps = Selenium::WebDriver::Remote::Capabilities.firefox(marionette: false)
|
136
|
-
path = ENV['FF_LEGACY_BINARY']
|
137
|
-
Selenium::WebDriver::Firefox::Binary.path = path if path
|
138
|
-
{desired_capabilities: caps}
|
78
|
+
def safari_args
|
79
|
+
{technology_preview: true}
|
139
80
|
end
|
140
81
|
|
141
82
|
def chrome_args
|
142
|
-
opts = {args: ["--disable-translate"]
|
143
|
-
|
144
|
-
|
145
|
-
if url = ENV['WATIR_CHROME_SERVER']
|
146
|
-
opts[:url] = url
|
147
|
-
end
|
148
|
-
|
149
|
-
if driver = ENV['WATIR_CHROME_DRIVER']
|
150
|
-
Selenium::WebDriver::Chrome.driver_path = driver
|
151
|
-
end
|
152
|
-
|
153
|
-
if path = ENV['WATIR_CHROME_BINARY']
|
154
|
-
Selenium::WebDriver::Chrome.path = path
|
155
|
-
end
|
156
|
-
|
83
|
+
opts = {args: ["--disable-translate"]}
|
84
|
+
opts[:headless] = true if ENV['HEADLESS'] == 'true'
|
85
|
+
opts[:options] = {binary: ENV['CHROME_BINARY']} if ENV['CHROME_BINARY']
|
157
86
|
opts
|
158
87
|
end
|
159
88
|
|
160
|
-
def remote_args
|
161
|
-
url = ENV["REMOTE_SERVER_URL"] || "http://127.0.0.1:#{@server.port}/wd/hub"
|
162
|
-
opts = {}
|
163
|
-
if remote_browser == :ff_legacy
|
164
|
-
path = ENV['FF_LEGACY_BINARY']
|
165
|
-
opts[:firefox_binary] = path if path
|
166
|
-
@remote_browser = :firefox
|
167
|
-
@ff_legacy = true
|
168
|
-
opts[:marionette] = false
|
169
|
-
elsif remote_browser == :firefox
|
170
|
-
path = ENV['FIREFOX_BINARY']
|
171
|
-
opts[:firefox_binary] = path if path
|
172
|
-
end
|
173
|
-
|
174
|
-
caps = Selenium::WebDriver::Remote::Capabilities.send(remote_browser, opts)
|
175
|
-
{url: url, desired_capabilities: caps}
|
176
|
-
end
|
177
|
-
|
178
89
|
class SelectorListener < Selenium::WebDriver::Support::AbstractEventListener
|
179
90
|
def initialize
|
180
91
|
@counts = Hash.new(0)
|
181
92
|
end
|
182
93
|
|
183
|
-
def before_find(how,
|
94
|
+
def before_find(how, _what, _driver)
|
184
95
|
@counts[how] += 1
|
185
96
|
end
|
186
97
|
|
187
98
|
def report
|
188
99
|
total = @counts.values.inject(0) { |mem, var| mem + var }
|
189
|
-
|
100
|
+
str = "Selenium selector stats: \n"
|
190
101
|
@counts.each do |how, count|
|
191
|
-
|
102
|
+
str << "\t#{how.to_s.ljust(20)}: #{count * 100 / total} (#{count})\n"
|
192
103
|
end
|
104
|
+
Watir.logger.warn str
|
193
105
|
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
class RemoteConfig < LocalConfig
|
110
|
+
def configure
|
111
|
+
@url = ENV["REMOTE_SERVER_URL"] || begin
|
112
|
+
require 'watirspec/remote_server'
|
194
113
|
|
114
|
+
remote_server = WatirSpec::RemoteServer.new
|
115
|
+
remote_server.start
|
116
|
+
remote_server.server.webdriver_url
|
117
|
+
end
|
118
|
+
super
|
195
119
|
end
|
120
|
+
|
121
|
+
private
|
122
|
+
|
123
|
+
def add_guards
|
124
|
+
matching_guards = super
|
125
|
+
matching_guards << :remote
|
126
|
+
matching_guards << [:remote, browser]
|
127
|
+
matching_guards
|
128
|
+
end
|
129
|
+
|
130
|
+
def create_args
|
131
|
+
super.merge(url: @url)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
if ENV["REMOTE_SERVER_URL"] || ENV["USE_REMOTE"]
|
136
|
+
RemoteConfig.new(WatirSpec.implementation).configure
|
137
|
+
else
|
138
|
+
LocalConfig.new(WatirSpec.implementation).configure
|
196
139
|
end
|
197
140
|
|
198
|
-
ImplementationConfig.new(WatirSpec.implementation).configure
|
199
141
|
WatirSpec.run!
|
data/support/doctest_helper.rb
CHANGED
data/watir.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'watir'
|
5
|
-
s.version = '6.
|
5
|
+
s.version = '6.6.0'
|
6
6
|
s.platform = Gem::Platform::RUBY
|
7
7
|
s.authors = ['Alex Rodionov', 'Titus Fortner']
|
8
8
|
s.email = ['p0deje@gmail.com', 'titusfortner@gmail.com']
|
@@ -21,7 +21,7 @@ It facilitates the writing of automated tests by mimicing the behavior of a user
|
|
21
21
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
22
|
s.require_paths = ['lib']
|
23
23
|
|
24
|
-
s.add_dependency 'selenium-webdriver', '~> 3.
|
24
|
+
s.add_dependency 'selenium-webdriver', '~> 3.4', '>= 3.4.1'
|
25
25
|
|
26
26
|
s.add_development_dependency 'rspec', '~> 3.0'
|
27
27
|
s.add_development_dependency 'yard', '> 0.8.2.1'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Rodionov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-08-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: selenium-webdriver
|
@@ -17,14 +17,20 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '3.
|
20
|
+
version: '3.4'
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 3.4.1
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
28
|
- - "~>"
|
26
29
|
- !ruby/object:Gem::Version
|
27
|
-
version: '3.
|
30
|
+
version: '3.4'
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.4.1
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
35
|
name: rspec
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,6 +218,7 @@ files:
|
|
212
218
|
- lib/watir/atoms/selectText.js
|
213
219
|
- lib/watir/attribute_helper.rb
|
214
220
|
- lib/watir/browser.rb
|
221
|
+
- lib/watir/capabilities.rb
|
215
222
|
- lib/watir/cell_container.rb
|
216
223
|
- lib/watir/container.rb
|
217
224
|
- lib/watir/cookies.rb
|
@@ -281,6 +288,7 @@ files:
|
|
281
288
|
- lib/watir/locators/text_field/selector_builder.rb
|
282
289
|
- lib/watir/locators/text_field/selector_builder/xpath.rb
|
283
290
|
- lib/watir/locators/text_field/validator.rb
|
291
|
+
- lib/watir/logger.rb
|
284
292
|
- lib/watir/row_container.rb
|
285
293
|
- lib/watir/screenshot.rb
|
286
294
|
- lib/watir/user_editable.rb
|
@@ -292,6 +300,7 @@ files:
|
|
292
300
|
- lib/watirspec/guards.rb
|
293
301
|
- lib/watirspec/implementation.rb
|
294
302
|
- lib/watirspec/rake_tasks.rb
|
303
|
+
- lib/watirspec/remote_server.rb
|
295
304
|
- lib/watirspec/runner.rb
|
296
305
|
- lib/watirspec/server.rb
|
297
306
|
- lib/watirspec/server/app.rb
|
@@ -303,6 +312,7 @@ files:
|
|
303
312
|
- spec/implementation_spec.rb
|
304
313
|
- spec/input_spec.rb
|
305
314
|
- spec/locator_spec_helper.rb
|
315
|
+
- spec/logger_spec.rb
|
306
316
|
- spec/spec_helper.rb
|
307
317
|
- spec/special_chars_spec.rb
|
308
318
|
- spec/watirspec/adjacent_spec.rb
|
@@ -494,6 +504,7 @@ test_files:
|
|
494
504
|
- spec/implementation_spec.rb
|
495
505
|
- spec/input_spec.rb
|
496
506
|
- spec/locator_spec_helper.rb
|
507
|
+
- spec/logger_spec.rb
|
497
508
|
- spec/spec_helper.rb
|
498
509
|
- spec/special_chars_spec.rb
|
499
510
|
- spec/watirspec/adjacent_spec.rb
|