watir 7.0.0.beta4 → 7.0.0.beta5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84196be031b435273f620aea6539dfb373602174b861fe624faf8591b3a803b6
4
- data.tar.gz: 934de2c077de5657f76fdbc7dc4f6c8c4b9408f278b644b9e01b5c5b7f8d401b
3
+ metadata.gz: af4906be1ae9d2713b91037006f964eddcac08ccb7a3cc341752132dea109b0f
4
+ data.tar.gz: 52ece209164c1ff75eeaec71efe8c70f03dd27f4fb1c791761e77c9ac600b333
5
5
  SHA512:
6
- metadata.gz: 8f51aeb6d0f69bf20150a689b4e29ba5fb6217abd735e9a18c9917ce60dab6810a3d43b10581ae19fb85b23e7231a1cd541fdfd255cc17a80a58c78f308973a6
7
- data.tar.gz: 5130d9bc13f3ac40b247756d009813c6cb99584e6744a1f883b3beede4a51099a778549e6e9a15f273784aed5fe1849ac384161947e38dfc770deef0b051ec45
6
+ metadata.gz: 5623e2ac22fd67b0c7f147333ed0c0e8ce3b87cf66ecb8d40a3f85672ce647d480bfe0114986a83d1a0bdc59510ad2d164c046769eea5c44a12252b3578a4d23
7
+ data.tar.gz: 9e95f5db40c379040dabb329c64dc4032c9c290193c3804e401cbfaabecec9550fa524c50e6483a9b597240a99f542549c1b823d91c99128dbab16b44f1c4d39
data/CHANGES.md CHANGED
@@ -1,3 +1,9 @@
1
+ ### 7.0.0.beta5 (2021-08-02)
2
+
3
+ * Add support for passing in Proxy and proxy Hash to Capabilities (#933)
4
+ * Trigger change event when setting values on date and date-time fields (#938)
5
+ * Allow user to obtain Capabilities instance from Browser instance
6
+
1
7
  ### 7.0.0.beta4 (2021-05-29)
2
8
 
3
9
  * Fix Bug in using negative class names within a collection (#934)
data/lib/watir/browser.rb CHANGED
@@ -12,7 +12,7 @@ module Watir
12
12
  include Scrolling
13
13
 
14
14
  attr_writer :default_context, :original_window, :locator_namespace, :timer
15
- attr_reader :driver, :after_hooks
15
+ attr_reader :driver, :after_hooks, :capabilities
16
16
  alias wd driver # ensures duck typing with Watir::Element
17
17
 
18
18
  class << self
@@ -42,8 +42,8 @@ module Watir
42
42
  def initialize(browser = :chrome, *args)
43
43
  case browser
44
44
  when ::Symbol, String
45
- selenium_args = Capabilities.new(browser, *args).to_args
46
- @driver = Selenium::WebDriver.for(*selenium_args)
45
+ @capabilities = Capabilities.new(browser, *args)
46
+ @driver = Selenium::WebDriver.for(*@capabilities.to_args)
47
47
  when Selenium::WebDriver::Driver
48
48
  @driver = browser
49
49
  else
@@ -74,12 +74,26 @@ module Watir
74
74
  end
75
75
 
76
76
  options.unhandled_prompt_behavior ||= :ignore
77
+ process_proxy_options(options)
77
78
  browser_specific_options(options)
78
79
  raise ArgumentError, "#{@options} are unrecognized arguments for Browser constructor" unless @options.empty?
79
80
 
80
81
  vendor_caps << options
81
82
  end
82
83
 
84
+ def process_proxy_options(options)
85
+ proxy = @options.delete(:proxy)
86
+ return if proxy.nil?
87
+
88
+ proxy &&= Selenium::WebDriver::Proxy.new(proxy) if proxy.is_a?(Hash)
89
+
90
+ unless proxy.is_a?(Selenium::WebDriver::Proxy)
91
+ raise TypeError, "#{proxy} needs to be Selenium Proxy or Hash instance"
92
+ end
93
+
94
+ options.proxy = proxy
95
+ end
96
+
83
97
  def process_vendor_capabilities(opts)
84
98
  return [] unless opts.is_a? Hash
85
99
 
@@ -11,7 +11,10 @@ module Watir
11
11
  raise ArgumentError, message unless [Date, ::Time].include?(date.class)
12
12
 
13
13
  date_string = date.strftime('%Y-%m-%d')
14
- element_call(:wait_for_writable) { execute_js(:setValue, @element, date_string) }
14
+ element_call(:wait_for_writable) do
15
+ execute_js(:setValue, @element, date_string)
16
+ execute_js(:fireEvent, @element, :change)
17
+ end
15
18
  end
16
19
  alias set set!
17
20
  alias value= set
@@ -11,7 +11,10 @@ module Watir
11
11
  raise ArgumentError, message unless [DateTime, ::Time].include?(date.class)
12
12
 
13
13
  date_time_string = date.strftime('%Y-%m-%dT%H:%M')
14
- element_call(:wait_for_writable) { execute_js(:setValue, @element, date_time_string) }
14
+ element_call(:wait_for_writable) do
15
+ execute_js(:setValue, @element, date_time_string)
16
+ execute_js(:fireEvent, @element, :change)
17
+ end
15
18
  end
16
19
  alias set set!
17
20
  alias value= set
data/lib/watir/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Watir
2
- VERSION = '7.0.0.beta4'.freeze
2
+ VERSION = '7.0.0.beta5'.freeze
3
3
  end
@@ -20,14 +20,10 @@ module WatirSpec
20
20
  private
21
21
 
22
22
  def jar
23
- if ENV['LOCAL_SELENIUM']
24
- local = File.expand_path('../selenium/buck-out/gen/java/server/src/org/openqa/grid/selenium/selenium.jar')
25
- end
26
-
27
23
  if File.exist?(ENV['REMOTE_SERVER_BINARY'] || '')
28
24
  ENV['REMOTE_SERVER_BINARY']
29
- elsif ENV['LOCAL_SELENIUM'] && File.exist?(local)
30
- local
25
+ elsif ENV['LOCAL_SELENIUM']
26
+ File.expand_path('../selenium/bazel-bin/java/server/src/org/openqa/selenium/grid/selenium_server_deploy.jar')
31
27
  elsif !Dir.glob('*selenium*.jar').empty?
32
28
  Dir.glob('*selenium*.jar').first
33
29
  else
@@ -39,6 +39,7 @@ describe Watir::Capabilities do
39
39
  # :listener
40
40
  # :service (Built from Hash)
41
41
  # :http_client (Generated or Built from Hash)
42
+ # :proxy (Built from Hash and added to :options)
42
43
  # :options (Generated or Built from Hash)
43
44
  # :capabilities (incompatible with options)
44
45
 
@@ -74,7 +75,7 @@ describe Watir::Capabilities do
74
75
  expect(args.last).not_to include(:service)
75
76
  end
76
77
 
77
- context 'service' do
78
+ describe 'service' do
78
79
  it 'uses provided service' do
79
80
  halt_service(browser_symbol)
80
81
 
@@ -106,7 +107,7 @@ describe Watir::Capabilities do
106
107
  end
107
108
  end
108
109
 
109
- context 'http_client' do
110
+ describe 'http_client' do
110
111
  it 'uses default HTTP Client' do
111
112
  capabilities = Watir::Capabilities.new(browser_symbol)
112
113
  args = capabilities.to_args
@@ -153,7 +154,7 @@ describe Watir::Capabilities do
153
154
  }.to raise_exception(ArgumentError, ':capabilities and :options are not both allowed')
154
155
  end
155
156
 
156
- context 'timeout options' do
157
+ describe 'timeout options' do
157
158
  it 'accepts page load and script timeouts in seconds' do
158
159
  options = {page_load_timeout: 11,
159
160
  script_timeout: 12}
@@ -203,6 +204,63 @@ describe Watir::Capabilities do
203
204
  actual_options = args.last[:capabilities].first
204
205
  expect(actual_options.unhandled_prompt_behavior).to eq :accept_and_notify
205
206
  end
207
+
208
+ describe 'proxy' do
209
+ it 'adds Selenium Proxy to empty Options' do
210
+ proxy = Selenium::WebDriver::Proxy.new(http: '127.0.0.1:8080', ssl: '127.0.0.1:443')
211
+ capabilities = Watir::Capabilities.new(browser_symbol, proxy: proxy)
212
+ args = capabilities.to_args
213
+ proxy = args.last[:capabilities].first.proxy
214
+
215
+ expect(proxy).to be_a Selenium::WebDriver::Proxy
216
+ expect(proxy.type).to eq(:manual)
217
+ expect(proxy.http).to eq('127.0.0.1:8080')
218
+ expect(proxy.ssl).to eq('127.0.0.1:443')
219
+ end
220
+
221
+ it 'builds a Proxy from Hash for Options' do
222
+ proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
223
+ capabilities = Watir::Capabilities.new(browser_symbol, proxy: proxy)
224
+ args = capabilities.to_args
225
+ proxy = args.last[:capabilities].first.proxy
226
+
227
+ expect(proxy).to be_a Selenium::WebDriver::Proxy
228
+ expect(proxy.type).to eq(:manual)
229
+ expect(proxy.http).to eq('127.0.0.1:8080')
230
+ expect(proxy.ssl).to eq('127.0.0.1:443')
231
+ end
232
+
233
+ it 'builds a Proxy from Hash and adds to Options' do
234
+ proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
235
+ options = {unhandled_prompt_behavior: :accept,
236
+ page_load_strategy: :eager}
237
+
238
+ capabilities = Watir::Capabilities.new(browser_symbol, options: options, proxy: proxy)
239
+ args = capabilities.to_args
240
+ actual_options = args.last[:capabilities].first
241
+
242
+ expect(actual_options.proxy).to be_a Selenium::WebDriver::Proxy
243
+ expect(actual_options.proxy.type).to eq(:manual)
244
+ expect(actual_options.proxy.http).to eq('127.0.0.1:8080')
245
+ expect(actual_options.proxy.ssl).to eq('127.0.0.1:443')
246
+ expect(actual_options.unhandled_prompt_behavior).to eq :accept
247
+ expect(actual_options.page_load_strategy).to eq :eager
248
+ end
249
+ end
250
+
251
+ it 'errors on bad proxy key' do
252
+ proxy = {bad_key: 'foo'}
253
+ capabilities = Watir::Capabilities.new(browser_symbol, proxy: proxy)
254
+
255
+ expect { capabilities.to_args }.to raise_error(ArgumentError, /unknown option/)
256
+ end
257
+
258
+ it 'errors on bad proxy object' do
259
+ capabilities = Watir::Capabilities.new(browser_symbol, proxy: 7)
260
+ expect {
261
+ capabilities.to_args
262
+ }.to raise_exception(TypeError, '7 needs to be Selenium Proxy or Hash instance')
263
+ end
206
264
  end
207
265
 
208
266
  # Options:
@@ -210,6 +268,7 @@ describe Watir::Capabilities do
210
268
  # :service (Errors)
211
269
  # :listener
212
270
  # :http_client (Generated or Built from Hash)
271
+ # :proxy (Built from Hash and added to :options)
213
272
  # :options (Generated or Built from Hash)
214
273
  # :capabilities (incompatible with options)
215
274
 
@@ -266,6 +325,34 @@ describe Watir::Capabilities do
266
325
  expect(actual_options.browser_name).to eq 'chrome'
267
326
  end
268
327
 
328
+ it 'accepts proxy object' do
329
+ proxy = Selenium::WebDriver::Proxy.new(http: '127.0.0.1:8080', ssl: '127.0.0.1:443')
330
+ capabilities = Watir::Capabilities.new(:chrome,
331
+ url: 'https://example.com/wd/hub',
332
+ proxy: proxy)
333
+ args = capabilities.to_args
334
+ expect(args.first).to eq :remote
335
+ proxy = args.last[:capabilities].first.proxy
336
+ expect(proxy).to be_a Selenium::WebDriver::Proxy
337
+ expect(proxy.type).to eq(:manual)
338
+ expect(proxy.http).to eq('127.0.0.1:8080')
339
+ expect(proxy.ssl).to eq('127.0.0.1:443')
340
+ end
341
+
342
+ it 'accepts proxy Hash' do
343
+ proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
344
+ capabilities = Watir::Capabilities.new(:chrome,
345
+ url: 'https://example.com/wd/hub',
346
+ proxy: proxy)
347
+ args = capabilities.to_args
348
+ expect(args.first).to eq :remote
349
+ proxy = args.last[:capabilities].first.proxy
350
+ expect(proxy).to be_a Selenium::WebDriver::Proxy
351
+ expect(proxy.type).to eq(:manual)
352
+ expect(proxy.http).to eq('127.0.0.1:8080')
353
+ expect(proxy.ssl).to eq('127.0.0.1:443')
354
+ end
355
+
269
356
  it 'accepts options object' do
270
357
  capabilities = Watir::Capabilities.new(:chrome,
271
358
  url: 'https://example.com/wd/hub',
@@ -316,11 +403,13 @@ describe Watir::Capabilities do
316
403
  expect(actual_capabilities.browser_name).to eq 'chrome'
317
404
  end
318
405
 
319
- it 'accepts http client & options objects' do
406
+ it 'accepts http client & proxy & options objects' do
320
407
  client = Watir::HttpClient.new
408
+ proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
321
409
  options = Selenium::WebDriver::Chrome::Options.new(prefs: {foo: 'bar'})
322
410
  caps = Watir::Capabilities.new(:chrome,
323
411
  url: 'https://example.com/wd/hub',
412
+ proxy: proxy,
324
413
  options: options,
325
414
  http_client: client)
326
415
 
@@ -330,6 +419,11 @@ describe Watir::Capabilities do
330
419
  actual_options = args.last[:capabilities].first
331
420
  expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)
332
421
  expect(actual_options.prefs).to eq(foo: 'bar')
422
+ proxy = args.last[:capabilities].first.proxy
423
+ expect(proxy).to be_a Selenium::WebDriver::Proxy
424
+ expect(proxy.type).to eq(:manual)
425
+ expect(proxy.http).to eq('127.0.0.1:8080')
426
+ expect(proxy.ssl).to eq('127.0.0.1:443')
333
427
  end
334
428
 
335
429
  it 'raises exception when both options & capabilities defined' do
data/watir.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
26
26
  s.require_paths = ['lib']
27
27
 
28
- s.add_dependency 'selenium-webdriver', '>= 4.0.0.beta2'
28
+ s.add_dependency 'selenium-webdriver', '>= 4.0.0.beta4'
29
29
  s.add_runtime_dependency 'regexp_parser', '>= 1.2', '< 3'
30
30
 
31
31
  s.add_development_dependency 'activesupport', '~> 4.0', '>= 4.1.11' # for pluralization during code generation
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: 7.0.0.beta4
4
+ version: 7.0.0.beta5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Rodionov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-05-30 00:00:00.000000000 Z
13
+ date: 2021-08-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: selenium-webdriver
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: 4.0.0.beta2
21
+ version: 4.0.0.beta4
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: 4.0.0.beta2
28
+ version: 4.0.0.beta4
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: regexp_parser
31
31
  requirement: !ruby/object:Gem::Requirement