selenium-webdriver 2.52.0 → 2.53.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/CHANGES +14 -0
  2. data/Gemfile.lock +53 -0
  3. data/lib/selenium/webdriver.rb +1 -3
  4. data/lib/selenium/webdriver/chrome/profile.rb +2 -2
  5. data/lib/selenium/webdriver/chrome/service.rb +8 -5
  6. data/lib/selenium/webdriver/common.rb +0 -1
  7. data/lib/selenium/webdriver/common/alert.rb +7 -1
  8. data/lib/selenium/webdriver/common/element.rb +1 -1
  9. data/lib/selenium/webdriver/common/error.rb +1 -1
  10. data/lib/selenium/webdriver/common/platform.rb +8 -0
  11. data/lib/selenium/webdriver/common/profile_helper.rb +2 -2
  12. data/lib/selenium/webdriver/common/proxy.rb +1 -1
  13. data/lib/selenium/webdriver/edge/legacy_support.rb +5 -5
  14. data/lib/selenium/webdriver/edge/service.rb +8 -5
  15. data/lib/selenium/webdriver/firefox/binary.rb +4 -0
  16. data/lib/selenium/webdriver/firefox/extension.rb +13 -11
  17. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  18. data/lib/selenium/webdriver/firefox/profile.rb +3 -3
  19. data/lib/selenium/webdriver/firefox/service.rb +8 -5
  20. data/lib/selenium/webdriver/phantomjs/service.rb +8 -6
  21. data/lib/selenium/webdriver/remote/bridge.rb +4 -0
  22. data/lib/selenium/webdriver/remote/capabilities.rb +1 -1
  23. data/lib/selenium/webdriver/remote/commands.rb +2 -1
  24. data/lib/selenium/webdriver/remote/http/common.rb +2 -2
  25. data/lib/selenium/webdriver/remote/w3c_bridge.rb +8 -8
  26. data/lib/selenium/webdriver/remote/w3c_capabilities.rb +31 -14
  27. data/lib/selenium/webdriver/remote/w3c_commands.rb +1 -1
  28. data/lib/selenium/webdriver/safari/resources/client.js +266 -214
  29. data/lib/selenium/webdriver/safari/server.rb +6 -4
  30. data/lib/selenium/webdriver/support/select.rb +12 -2
  31. data/selenium-webdriver.gemspec +1 -2
  32. metadata +18 -29
  33. data/lib/selenium/webdriver/common/json_helper.rb +0 -53
data/CHANGES CHANGED
@@ -1,3 +1,17 @@
1
+ 2.53.0 (2016-03-15)
2
+ ===================
3
+
4
+ Ruby:
5
+ * Removed dependency on "multi_json" (issue 1632)
6
+ * Properly handle namespaces in install manifest of Firefox add-ons (issue 1143)
7
+ * Improve error handling when stopping browsers (thanks bsedat)
8
+ * Fix deselecting options in select lists (thanks glib-briia)
9
+ * Fix w3c error handling
10
+ * Update w3c Capabilities support
11
+
12
+ IE:
13
+ * support for alert credentials (issue #1698, thanks Alan Baird & trabulmonkee)
14
+
1
15
  2.52.0 (2016-02-12)
2
16
  ===================
3
17
 
@@ -0,0 +1,53 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ selenium-webdriver (2.53.0dev)
5
+ childprocess (~> 0.5)
6
+ rubyzip (~> 1.0)
7
+ websocket (~> 1.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ addressable (2.4.0)
13
+ builder (3.2.2)
14
+ childprocess (0.5.9)
15
+ ffi (~> 1.0, >= 1.0.11)
16
+ ci_reporter (1.9.3)
17
+ builder (>= 2.1.2)
18
+ crack (0.4.2)
19
+ safe_yaml (~> 1.0.0)
20
+ diff-lcs (1.2.5)
21
+ ffi (1.9.10)
22
+ hashdiff (0.2.3)
23
+ rack (1.6.4)
24
+ rspec (2.99.0)
25
+ rspec-core (~> 2.99.0)
26
+ rspec-expectations (~> 2.99.0)
27
+ rspec-mocks (~> 2.99.0)
28
+ rspec-core (2.99.2)
29
+ rspec-expectations (2.99.2)
30
+ diff-lcs (>= 1.1.3, < 2.0)
31
+ rspec-mocks (2.99.4)
32
+ rubyzip (1.2.0)
33
+ safe_yaml (1.0.4)
34
+ webmock (1.22.3)
35
+ addressable (>= 2.3.6)
36
+ crack (>= 0.3.2)
37
+ hashdiff
38
+ websocket (1.2.2)
39
+ yard (0.8.7.6)
40
+
41
+ PLATFORMS
42
+ ruby
43
+
44
+ DEPENDENCIES
45
+ ci_reporter (~> 1.6, >= 1.6.2)
46
+ rack (~> 1.0)
47
+ rspec (~> 2.99.0)
48
+ selenium-webdriver!
49
+ webmock (~> 1.7, >= 1.7.5)
50
+ yard (~> 0.8.7)
51
+
52
+ BUNDLED WITH
53
+ 1.11.2
@@ -21,14 +21,12 @@ require 'childprocess'
21
21
  require 'tmpdir'
22
22
  require 'fileutils'
23
23
  require 'date'
24
+ require 'json'
24
25
 
25
- require 'multi_json'
26
26
  require 'selenium/webdriver/common'
27
27
 
28
28
  module Selenium
29
29
  module WebDriver
30
- extend JsonHelper
31
-
32
30
  Point = Struct.new(:x, :y)
33
31
  Dimension = Struct.new(:width, :height)
34
32
  Location = Struct.new(:latitude, :longitude, :altitude)
@@ -87,7 +87,7 @@ module Selenium
87
87
  prefs_file = prefs_file_for(dir)
88
88
 
89
89
  FileUtils.mkdir_p File.dirname(prefs_file)
90
- File.open(prefs_file, "w") { |file| file << WebDriver.json_dump(prefs) }
90
+ File.open(prefs_file, "w") { |file| file << JSON.generate(prefs) }
91
91
  end
92
92
 
93
93
  def prefs
@@ -96,7 +96,7 @@ module Selenium
96
96
 
97
97
  def read_model_prefs
98
98
  return {} unless @model
99
- WebDriver.json_load File.read(prefs_file_for(@model))
99
+ JSON.parse File.read(prefs_file_for(@model))
100
100
  end
101
101
 
102
102
  def prefs_file_for(dir)
@@ -80,11 +80,8 @@ module Selenium
80
80
 
81
81
  http.get("/shutdown")
82
82
  end
83
-
84
- @process.poll_for_exit STOP_TIMEOUT
85
- rescue ChildProcess::TimeoutError
86
- # ok, force quit
87
- @process.stop STOP_TIMEOUT
83
+ ensure
84
+ stop_process
88
85
  end
89
86
 
90
87
  def uri
@@ -105,6 +102,12 @@ module Selenium
105
102
  @process.start
106
103
  end
107
104
 
105
+ def stop_process
106
+ @process.poll_for_exit STOP_TIMEOUT
107
+ rescue ChildProcess::TimeoutError
108
+ @process.stop STOP_TIMEOUT
109
+ end
110
+
108
111
  def connect_until_stable
109
112
  socket_poller = SocketPoller.new @host, @port, START_TIMEOUT
110
113
 
@@ -59,6 +59,5 @@ require 'selenium/webdriver/common/driver_extensions/uploads_files'
59
59
  require 'selenium/webdriver/common/keys'
60
60
  require 'selenium/webdriver/common/bridge_helper'
61
61
  require 'selenium/webdriver/common/profile_helper'
62
- require 'selenium/webdriver/common/json_helper'
63
62
  require 'selenium/webdriver/common/driver'
64
63
  require 'selenium/webdriver/common/element'
@@ -43,7 +43,13 @@ module Selenium
43
43
  def text
44
44
  @bridge.getAlertText
45
45
  end
46
+
47
+ def authenticate(username, password)
48
+ @bridge.setAuthentication username: username, password: password
49
+ accept
50
+ end
46
51
 
47
52
  end # Alert
48
53
  end # WebDriver
49
- end # Selenium
54
+ end # Selenium
55
+
@@ -281,7 +281,7 @@ module Selenium
281
281
  #
282
282
 
283
283
  def to_json(*args)
284
- WebDriver.json_dump as_json
284
+ JSON.generate as_json
285
285
  end
286
286
 
287
287
  #
@@ -217,7 +217,7 @@ module Selenium
217
217
  return Errors[code - 1] if code.is_a? Fixnum
218
218
 
219
219
  klass_name = code.split(' ').map(&:capitalize).join
220
- Error.const_get("#{klass_name}Error")
220
+ Error.const_get("#{klass_name.gsub('Error','')}Error")
221
221
  rescue NameError
222
222
  WebDriverError
223
223
  end
@@ -61,6 +61,14 @@ module Selenium
61
61
  )
62
62
  end
63
63
 
64
+ def ci
65
+ if ENV['TRAVIS']
66
+ :travis
67
+ elsif ENV['JENKINS']
68
+ :jenkins
69
+ end
70
+ end
71
+
64
72
  def bitsize
65
73
  @bitsize ||= (
66
74
  if defined?(FFI::Platform::ADDRESS_SIZE)
@@ -38,7 +38,7 @@ module Selenium
38
38
  end
39
39
 
40
40
  def to_json(*args)
41
- WebDriver.json_dump as_json
41
+ JSON.generate as_json
42
42
  end
43
43
 
44
44
  private
@@ -65,7 +65,7 @@ module Selenium
65
65
 
66
66
  module ClassMethods
67
67
  def from_json(json)
68
- data = WebDriver.json_load(json).fetch('zip')
68
+ data = JSON.parse(json).fetch('zip')
69
69
 
70
70
  # can't use Tempfile here since it doesn't support File::BINARY mode on 1.8
71
71
  # can't use Dir.mktmpdir(&blk) because of http://jira.codehaus.org/browse/JRUBY-4082
@@ -139,7 +139,7 @@ module Selenium
139
139
  end
140
140
 
141
141
  def to_json(*args)
142
- WebDriver.json_dump as_json
142
+ JSON.generate as_json
143
143
  end
144
144
 
145
145
  class << self
@@ -24,11 +24,11 @@ module Selenium
24
24
  module LegacySupport
25
25
 
26
26
  # These are commands Edge is still using from JSON Wire Protocol
27
- %i(executeScript executeAsyncScript submitElement doubleClick mouseDown mouseUp mouseMoveTo
28
- click sendKeysToActiveElement getWindowHandles getCurrentWindowHandle getWindowSize
29
- setWindowSize getWindowPosition setWindowPosition maximizeWindow).each do |cmd|
30
- jwp = Remote::Bridge::COMMANDS[cmd]
31
- Remote::W3CBridge.command(cmd, jwp.first, jwp.last)
27
+ [:executeScript, :executeAsyncScript, :submitElement, :doubleClick, :mouseDown, :mouseUp, :mouseMoveTo, :click,
28
+ :sendKeysToActiveElement, :getWindowHandles, :getCurrentWindowHandle, :getWindowSize, :setWindowSize, :getWindowPosition,
29
+ :setWindowPosition, :maximizeWindow, :getAlertText, :acceptAlert, :dismissAlert].each do |cmd|
30
+ jwp = Remote::Bridge::COMMANDS[cmd]
31
+ Remote::W3CBridge.command(cmd, jwp.first, jwp.last)
32
32
  end
33
33
 
34
34
  def executeScript(script, *args)
@@ -80,11 +80,8 @@ module Selenium
80
80
 
81
81
  http.head("/shutdown")
82
82
  end
83
-
84
- @process.poll_for_exit STOP_TIMEOUT
85
- rescue ChildProcess::TimeoutError
86
- # ok, force quit
87
- @process.stop STOP_TIMEOUT
83
+ ensure
84
+ stop_process
88
85
  end
89
86
 
90
87
  def uri
@@ -103,6 +100,12 @@ module Selenium
103
100
  @process.start
104
101
  end
105
102
 
103
+ def stop_process
104
+ @process.poll_for_exit STOP_TIMEOUT
105
+ rescue ChildProcess::TimeoutError
106
+ @process.stop STOP_TIMEOUT
107
+ end
108
+
106
109
  def connect_until_stable
107
110
  socket_poller = SocketPoller.new @host, @port, START_TIMEOUT
108
111
 
@@ -128,6 +128,10 @@ module Selenium
128
128
  @path = path
129
129
  end
130
130
 
131
+ def reset_path!
132
+ @path = nil
133
+ end
134
+
131
135
  def path
132
136
  @path ||= case Platform.os
133
137
  when :macosx
@@ -21,8 +21,13 @@ module Selenium
21
21
  module WebDriver
22
22
  module Firefox
23
23
 
24
+ #
24
25
  # @api private
26
+ #
27
+
25
28
  class Extension
29
+ NAMESPACE = 'http://www.mozilla.org/2004/em-rdf#'
30
+
26
31
  def initialize(path)
27
32
  unless File.exist?(path)
28
33
  raise Error::WebDriverError, "could not find extension at #{path.inspect}"
@@ -61,20 +66,17 @@ module Selenium
61
66
  def read_id_from_install_rdf(directory)
62
67
  rdf_path = File.join(directory, "install.rdf")
63
68
  doc = REXML::Document.new(File.read(rdf_path))
69
+ namespace = doc.root.namespaces.key(NAMESPACE)
64
70
 
65
- id_node = REXML::XPath.first(doc, "//em:id")
66
-
67
- if id_node
68
- id_node.text
69
- else
70
- attr_node = REXML::XPath.first(doc, "//@em:id")
71
+ if namespace
72
+ id_node = REXML::XPath.first(doc, "//#{namespace}:id")
73
+ return id_node.text if id_node
71
74
 
72
- if attr_node.nil?
73
- raise Error::WebDriverError, "cannot locate extension id in #{rdf_path}"
74
- end
75
-
76
- attr_node.value
75
+ attr_node = REXML::XPath.first(doc, "//@#{namespace}:id")
76
+ return attr_node.value if attr_node
77
77
  end
78
+
79
+ raise Error::WebDriverError, "cannot locate extension id in #{rdf_path}"
78
80
  end
79
81
 
80
82
  end # Extension
@@ -46,7 +46,7 @@ module Selenium
46
46
  end
47
47
 
48
48
  def default_preferences
49
- @default_preferences ||= WebDriver.json_load(
49
+ @default_preferences ||= JSON.parse(
50
50
  File.read(File.expand_path("#{WebDriver.root}/selenium/webdriver/firefox/extension/prefs.json"))
51
51
  ).freeze
52
52
  end
@@ -261,7 +261,7 @@ module Selenium
261
261
  key, value = $1.strip, $2.strip
262
262
 
263
263
  # wrap the value in an array to make it a valid JSON string.
264
- prefs[key] = WebDriver.json_load("[#{value}]").first
264
+ prefs[key] = JSON.parse("[#{value}]").first
265
265
  end
266
266
  end
267
267
 
@@ -271,7 +271,7 @@ module Selenium
271
271
  def write_prefs(prefs, path)
272
272
  File.open(path, "w") { |file|
273
273
  prefs.each do |key, value|
274
- file.puts %{user_pref("#{key}", #{WebDriver.json_dump value});}
274
+ file.puts %{user_pref("#{key}", #{value.to_json});}
275
275
  end
276
276
  }
277
277
  end
@@ -79,11 +79,8 @@ module Selenium
79
79
 
80
80
  http.head("/shutdown")
81
81
  end
82
-
83
- @process.poll_for_exit STOP_TIMEOUT
84
- rescue ChildProcess::TimeoutError
85
- # ok, force quit
86
- @process.stop STOP_TIMEOUT
82
+ ensure
83
+ stop_process
87
84
  end
88
85
 
89
86
  def uri
@@ -102,6 +99,12 @@ module Selenium
102
99
  @process.start
103
100
  end
104
101
 
102
+ def stop_process
103
+ @process.poll_for_exit STOP_TIMEOUT
104
+ rescue ChildProcess::TimeoutError
105
+ @process.stop STOP_TIMEOUT
106
+ end
107
+
105
108
  def connect_until_stable
106
109
  @socket_poller = SocketPoller.new @host, @port, START_TIMEOUT
107
110
 
@@ -75,12 +75,8 @@ module Selenium
75
75
 
76
76
  http.get("/shutdown")
77
77
  end
78
-
79
- @process.poll_for_exit STOP_TIMEOUT
80
- rescue ChildProcess::TimeoutError
81
- # ok, force quit
82
- @process.stop STOP_TIMEOUT
83
-
78
+ ensure
79
+ stop_process
84
80
  if Platform.jruby? && !$DEBUG
85
81
  @process.io.close rescue nil
86
82
  end
@@ -110,6 +106,12 @@ module Selenium
110
106
  @process.start
111
107
  end
112
108
 
109
+ def stop_process
110
+ @process.poll_for_exit STOP_TIMEOUT
111
+ rescue ChildProcess::TimeoutError
112
+ @process.stop STOP_TIMEOUT
113
+ end
114
+
113
115
  def connect_until_stable
114
116
  socket_poller = SocketPoller.new @host, @port, START_TIMEOUT
115
117
 
@@ -169,6 +169,10 @@ module Selenium
169
169
  def getAlertText
170
170
  execute :getAlertText
171
171
  end
172
+
173
+ def setAuthentication(credentials)
174
+ execute :setAuthentication, {}, credentials
175
+ end
172
176
 
173
177
  #
174
178
  # navigation
@@ -260,7 +260,7 @@ module Selenium
260
260
  end
261
261
 
262
262
  def to_json(*args)
263
- WebDriver.json_dump as_json
263
+ JSON.generate as_json
264
264
  end
265
265
 
266
266
  def ==(other)
@@ -77,7 +77,8 @@ class Selenium::WebDriver::Remote::Bridge
77
77
  command :acceptAlert, :post, "session/:session_id/accept_alert"
78
78
  command :getAlertText, :get, "session/:session_id/alert_text"
79
79
  command :setAlertValue, :post, "session/:session_id/alert_text"
80
-
80
+ command :setAuthentication, :post, "session/:session_id/alert/credentials"
81
+
81
82
  #
82
83
  # target locator
83
84
  #
@@ -43,7 +43,7 @@ module Selenium
43
43
  headers['Cache-Control'] = "no-cache" if verb == :get
44
44
 
45
45
  if command_hash
46
- payload = WebDriver.json_dump(command_hash)
46
+ payload = JSON.generate(command_hash)
47
47
  headers["Content-Type"] = "#{CONTENT_TYPE}; charset=utf-8"
48
48
  headers["Content-Length"] = payload.bytesize.to_s if [:post, :put].include?(verb)
49
49
 
@@ -75,7 +75,7 @@ module Selenium
75
75
 
76
76
  if content_type.include? CONTENT_TYPE
77
77
  raise Error::WebDriverError, "empty body: #{content_type.inspect} (#{code})\n#{body}" if body.empty?
78
- Response.new(code, WebDriver.json_load(body))
78
+ Response.new(code, JSON.parse(body))
79
79
  elsif code == 204
80
80
  Response.new(code)
81
81
  else