selenium-webdriver 2.48.1 → 2.49.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.
Files changed (33) hide show
  1. data/CHANGES +34 -0
  2. data/lib/selenium/webdriver/chrome/bridge.rb +2 -2
  3. data/lib/selenium/webdriver/chrome/service.rb +6 -3
  4. data/lib/selenium/webdriver/common/driver.rb +6 -2
  5. data/lib/selenium/webdriver/common/element.rb +1 -1
  6. data/lib/selenium/webdriver/common/error.rb +7 -2
  7. data/lib/selenium/webdriver/common/options.rb +1 -2
  8. data/lib/selenium/webdriver/common/socket_lock.rb +5 -0
  9. data/lib/selenium/webdriver/common/window.rb +8 -0
  10. data/lib/selenium/webdriver/edge/bridge.rb +3 -2
  11. data/lib/selenium/webdriver/edge/legacy_support.rb +117 -0
  12. data/lib/selenium/webdriver/edge/service.rb +3 -2
  13. data/lib/selenium/webdriver/firefox/binary.rb +1 -0
  14. data/lib/selenium/webdriver/firefox/bridge.rb +2 -0
  15. data/lib/selenium/webdriver/firefox/extension/prefs.json +2 -0
  16. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  17. data/lib/selenium/webdriver/firefox/w3c_bridge.rb +10 -41
  18. data/lib/selenium/webdriver/ie/bridge.rb +1 -1
  19. data/lib/selenium/webdriver/ie/server.rb +36 -12
  20. data/lib/selenium/webdriver/phantomjs/service.rb +44 -25
  21. data/lib/selenium/webdriver/remote/bridge.rb +14 -33
  22. data/lib/selenium/webdriver/remote/capabilities.rb +8 -6
  23. data/lib/selenium/webdriver/remote/commands.rb +0 -5
  24. data/lib/selenium/webdriver/remote/w3c_bridge.rb +68 -86
  25. data/lib/selenium/webdriver/remote/w3c_capabilities.rb +35 -16
  26. data/lib/selenium/webdriver/remote/w3c_commands.rb +1 -2
  27. data/lib/selenium/webdriver/safari/bridge.rb +1 -1
  28. data/lib/selenium/webdriver/safari/browser.rb +2 -0
  29. data/lib/selenium/webdriver/safari/options.rb +6 -4
  30. data/lib/selenium/webdriver/safari/resources/client.js +65 -51
  31. data/lib/selenium/webdriver/safari/server.rb +23 -2
  32. data/selenium-webdriver.gemspec +1 -1
  33. metadata +3 -2
data/CHANGES CHANGED
@@ -1,3 +1,37 @@
1
+ 2.49.1 (UNRELEASED)
2
+ ===================
3
+
4
+ Ruby:
5
+ * support for SessionNotCreatedError (thanks Alexander Bayandin)
6
+
7
+ Safari:
8
+ * Limit support to OS X (issue 1186)
9
+ * support for multiple concurrent drivers
10
+
11
+ PhantomJS:
12
+ * Implement Socket locking
13
+
14
+ IE:
15
+ * support for multiple concurrent drivers
16
+
17
+ Chrome:
18
+ * prevent 404 error when shutting down Chrome service (thanks Fumiaki MATSUSHIMA)
19
+ * logging turned on by default
20
+ * support local storage capabilities
21
+
22
+ Firefox:
23
+ * support setting the location of Firefox binary to use when run locally
24
+ * add default lookup of Homebrew Cask default directory (issue 1437)
25
+
26
+ W3C Specification:
27
+ * support for using with Remote WebDriver
28
+ * implement window size command
29
+ * implement window position command
30
+ * implement element size command
31
+ * implement element position command
32
+ * implement full screen window command
33
+ * implement page source command
34
+
1
35
  2.48.1 (2015-10-13)
2
36
  ===================
3
37
 
@@ -55,7 +55,8 @@ module Selenium
55
55
  def driver_extensions
56
56
  [
57
57
  DriverExtensions::TakesScreenshot,
58
- DriverExtensions::HasInputDevices
58
+ DriverExtensions::HasInputDevices,
59
+ DriverExtensions::HasWebStorage
59
60
  ]
60
61
  end
61
62
 
@@ -103,7 +104,6 @@ module Selenium
103
104
  'extensions' => data['extensions']
104
105
  end
105
106
 
106
-
107
107
  chrome_options['binary'] = Chrome.path if Chrome.path
108
108
  chrome_options['nativeEvents'] = true if native_events
109
109
  chrome_options['verbose'] = true if verbose
@@ -24,6 +24,7 @@ module Selenium
24
24
  #
25
25
  # @api private
26
26
  #
27
+
27
28
  class Service
28
29
  START_TIMEOUT = 20
29
30
  SOCKET_LOCK_TIMEOUT = 45
@@ -77,7 +78,7 @@ module Selenium
77
78
  http.open_timeout = STOP_TIMEOUT / 2
78
79
  http.read_timeout = STOP_TIMEOUT / 2
79
80
 
80
- http.head("/shutdown")
81
+ http.get("/shutdown")
81
82
  end
82
83
 
83
84
  @process.poll_for_exit STOP_TIMEOUT
@@ -90,6 +91,8 @@ module Selenium
90
91
  URI.parse "http://#{@host}:#{@port}"
91
92
  end
92
93
 
94
+ private
95
+
93
96
  def find_free_port
94
97
  @port = PortProber.above @port
95
98
  end
@@ -103,9 +106,9 @@ module Selenium
103
106
  end
104
107
 
105
108
  def connect_until_stable
106
- @socket_poller = SocketPoller.new @host, @port, START_TIMEOUT
109
+ socket_poller = SocketPoller.new @host, @port, START_TIMEOUT
107
110
 
108
- unless @socket_poller.connected?
111
+ unless socket_poller.connected?
109
112
  raise Error::WebDriverError, "unable to connect to chromedriver #{@host}:#{@port}"
110
113
  end
111
114
  end
@@ -46,14 +46,18 @@ module Selenium
46
46
  listener = opts.delete(:listener)
47
47
 
48
48
  bridge = case browser
49
- when :firefox, :ff
49
+ when :firefox, :ff, :marionette
50
50
  if Remote::W3CCapabilities.w3c?(opts)
51
51
  Firefox::W3CBridge.new(opts)
52
52
  else
53
53
  Firefox::Bridge.new(opts)
54
54
  end
55
55
  when :remote
56
- Remote::Bridge.new(opts)
56
+ if Remote::W3CCapabilities.w3c?(opts)
57
+ Remote::W3CBridge.new(opts)
58
+ else
59
+ Remote::Bridge.new(opts)
60
+ end
57
61
  when :ie, :internet_explorer
58
62
  IE::Bridge.new(opts)
59
63
  when :chrome
@@ -37,7 +37,7 @@ module Selenium
37
37
  end
38
38
 
39
39
  def ==(other)
40
- other.kind_of?(self.class) && bridge.elementEquals(self, other)
40
+ other.kind_of?(self.class) && ref == other.ref
41
41
  end
42
42
  alias_method :eql?, :==
43
43
 
@@ -159,7 +159,12 @@ module Selenium
159
159
  #
160
160
 
161
161
  class InvalidSelectorError < WebDriverError; end # 32
162
- # 33
162
+
163
+ #
164
+ # A new session could not be created.
165
+ #
166
+
167
+ class SessionNotCreatedError < WebDriverError; end # 33
163
168
 
164
169
  #
165
170
  # Indicates that the target provided to the actions #move method is
@@ -202,7 +207,7 @@ module Selenium
202
207
  IMENotAvailableError, # 30
203
208
  IMEEngineActivationFailedError, # 31
204
209
  InvalidSelectorError, # 32
205
- nil, # 33
210
+ SessionNotCreatedError, # 33
206
211
  MoveTargetOutOfBoundsError # 34
207
212
  ]
208
213
 
@@ -50,10 +50,9 @@ module Selenium
50
50
  opts[:secure] ||= false
51
51
 
52
52
  if obj = opts.delete(:expires)
53
- opts[:expiry] = seconds_from(obj)
53
+ opts[:expiry] = seconds_from(obj).to_i
54
54
  end
55
55
 
56
-
57
56
  @bridge.addCookie opts
58
57
  end
59
58
 
@@ -19,6 +19,11 @@
19
19
 
20
20
  module Selenium
21
21
  module WebDriver
22
+
23
+ #
24
+ # @api private
25
+ #
26
+
22
27
  class SocketLock
23
28
 
24
29
  def initialize(port, timeout)
@@ -117,6 +117,14 @@ module Selenium
117
117
  @bridge.maximizeWindow
118
118
  end
119
119
 
120
+ #
121
+ # Make current window full screen
122
+ #
123
+
124
+ def full_screen
125
+ @bridge.fullscreenWindow
126
+ end
127
+
120
128
  end # Window
121
129
  end # WebDriver
122
130
  end # Selenium
@@ -22,9 +22,10 @@ module Selenium
22
22
  module Edge
23
23
 
24
24
  # @api private
25
- class Bridge < Remote::Bridge
25
+ class Bridge < Remote::W3CBridge
26
26
 
27
27
  def initialize(opts = {})
28
+
28
29
  http_client = opts.delete(:http_client)
29
30
 
30
31
  if opts.has_key?(:url)
@@ -76,7 +77,7 @@ module Selenium
76
77
  private
77
78
 
78
79
  def create_capabilities(opts)
79
- caps = opts.delete(:desired_capabilities) { Remote::Capabilities.edge }
80
+ caps = opts.delete(:desired_capabilities) { Remote::W3CCapabilities.edge }
80
81
  page_load_strategy = opts.delete(:page_load_strategy) || "normal"
81
82
 
82
83
  unless opts.empty?
@@ -0,0 +1,117 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Licensed to the Software Freedom Conservancy (SFC) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The SFC licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ module Selenium
21
+ module WebDriver
22
+ module Edge
23
+
24
+ module LegacySupport
25
+
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)
32
+ end
33
+
34
+ def executeScript(script, *args)
35
+ result = execute :executeScript, {}, :script => script, :args => args
36
+ unwrap_script_result result
37
+ end
38
+
39
+ def executeAsyncScript(script, *args)
40
+ result = execute :executeAsyncScript, {}, :script => script, :args => args
41
+ unwrap_script_result result
42
+ end
43
+
44
+ def submitElement(element)
45
+ execute :submitElement, :id => element
46
+ end
47
+
48
+ def doubleClick
49
+ execute :doubleClick
50
+ end
51
+
52
+ def click
53
+ execute :click, {}, :button => 0
54
+ end
55
+
56
+ def contextClick
57
+ execute :click, {}, :button => 2
58
+ end
59
+
60
+ def mouseDown
61
+ execute :mouseDown
62
+ end
63
+
64
+ def mouseUp
65
+ execute :mouseUp
66
+ end
67
+
68
+ def mouseMoveTo(element, x = nil, y = nil)
69
+ params = { :element => element }
70
+
71
+ if x && y
72
+ params.merge! :xoffset => x, :yoffset => y
73
+ end
74
+
75
+ execute :mouseMoveTo, {}, params
76
+ end
77
+
78
+ def sendKeysToActiveElement(key)
79
+ execute :sendKeysToActiveElement, {}, :value => key
80
+ end
81
+
82
+ def getCurrentWindowHandle
83
+ execute :getCurrentWindowHandle
84
+ end
85
+
86
+ def getWindowSize(handle = :current)
87
+ data = execute :getWindowSize, :window_handle => handle
88
+
89
+ Dimension.new data['width'], data['height']
90
+ end
91
+
92
+ def setWindowSize(width, height, handle = :current)
93
+ execute :setWindowSize, {:window_handle => handle},
94
+ :width => width,
95
+ :height => height
96
+ end
97
+
98
+ def getWindowPosition(handle = :current)
99
+ data = execute :getWindowPosition, :window_handle => handle
100
+
101
+ Point.new data['x'], data['y']
102
+ end
103
+
104
+ def setWindowPosition(x, y, handle = :current)
105
+ execute :setWindowPosition, {:window_handle => handle},
106
+ :x => x, :y => y
107
+ end
108
+
109
+ def maximizeWindow(handle = :current)
110
+ execute :maximizeWindow, :window_handle => handle
111
+ end
112
+
113
+
114
+ end # LegacySupport
115
+ end # Edge
116
+ end # WebDriver
117
+ end # Selenium
@@ -24,6 +24,7 @@ module Selenium
24
24
  #
25
25
  # @api private
26
26
  #
27
+
27
28
  class Service
28
29
  START_TIMEOUT = 20
29
30
  SOCKET_LOCK_TIMEOUT = 45
@@ -103,9 +104,9 @@ module Selenium
103
104
  end
104
105
 
105
106
  def connect_until_stable
106
- @socket_poller = SocketPoller.new @host, @port, START_TIMEOUT
107
+ socket_poller = SocketPoller.new @host, @port, START_TIMEOUT
107
108
 
108
- unless @socket_poller.connected?
109
+ unless socket_poller.connected?
109
110
  raise Error::WebDriverError, "unable to connect to MicrosoftWebDriver #{@host}:#{@port}"
110
111
  end
111
112
  end
@@ -170,6 +170,7 @@ module Selenium
170
170
 
171
171
  def macosx_path
172
172
  path = "/Applications/Firefox.app/Contents/MacOS/firefox-bin"
173
+ path = "~/Applications/Firefox.app/Contents/MacOS/firefox-bin" unless File.exist?(path)
173
174
  path = Platform.find_binary("firefox-bin") unless File.exist?(path)
174
175
 
175
176
  path
@@ -32,6 +32,8 @@ module Selenium
32
32
 
33
33
  caps = opts.delete(:desired_capabilities) { Remote::Capabilities.firefox }
34
34
 
35
+ Binary.path = caps[:firefox_binary] if caps[:firefox_binary]
36
+
35
37
  @launcher = create_launcher(port, profile)
36
38
 
37
39
  unless opts.empty?
@@ -61,12 +61,14 @@
61
61
  "browser.newtabpage.enabled": false,
62
62
  "browser.startup.page": 0,
63
63
  "browser.startup.homepage": "about:blank",
64
+ "browser.usedOnWindows10.introURL": "about:blank",
64
65
  "dom.max_chrome_script_run_time": 30,
65
66
  "dom.max_script_run_time": 30,
66
67
  "dom.report_all_js_exceptions": true,
67
68
  "javascript.options.showInConsole": true,
68
69
  "network.http.max-connections-per-server": 10,
69
70
  "startup.homepage_welcome_url": "about:blank",
71
+ "startup.homepage_welcome_url.additional": "about:blank",
70
72
  "webdriver_accept_untrusted_certs": true,
71
73
  "webdriver_assume_untrusted_issuer": true
72
74
  }
@@ -25,31 +25,14 @@ module Selenium
25
25
  class W3CBridge < Remote::W3CBridge
26
26
 
27
27
  def initialize(opts = {})
28
- http_client = opts.delete(:http_client)
28
+ caps = opts[:desired_capabilities] ||= Remote::W3CCapabilities.firefox
29
+ Binary.path = caps[:firefox_binary] if caps[:firefox_binary]
29
30
 
30
- if opts.has_key?(:url)
31
- url = opts.delete(:url)
32
- else
33
- @service = Service.default_service(*extract_service_args(opts))
31
+ @service = Service.default_service(*extract_service_args(opts))
32
+ @service.start
33
+ opts[:url] = @service.uri
34
34
 
35
- if @service.instance_variable_get("@host") == "127.0.0.1"
36
- @service.instance_variable_set("@host", 'localhost')
37
- end
38
-
39
- @service.start
40
-
41
- url = @service.uri
42
- end
43
-
44
- caps = create_capabilities(opts)
45
-
46
- remote_opts = {
47
- :url => url,
48
- :desired_capabilities => caps
49
- }
50
-
51
- remote_opts.merge!(:http_client => http_client) if http_client
52
- super(remote_opts)
35
+ super
53
36
  end
54
37
 
55
38
  def browser
@@ -59,7 +42,8 @@ module Selenium
59
42
  def driver_extensions
60
43
  [
61
44
  DriverExtensions::TakesScreenshot,
62
- DriverExtensions::HasInputDevices
45
+ DriverExtensions::HasInputDevices,
46
+ DriverExtensions::HasWebStorage
63
47
  ]
64
48
  end
65
49
 
@@ -71,24 +55,9 @@ module Selenium
71
55
 
72
56
  private
73
57
 
74
- def create_capabilities(opts)
75
- caps = opts.delete(:desired_capabilities) { Remote::W3CCapabilities.firefox }
76
-
77
- unless opts.empty?
78
- raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
79
- end
80
-
81
- caps
82
- end
83
-
84
58
  def extract_service_args(opts)
85
- args = []
86
-
87
- if opts.has_key?(:service_log_path)
88
- args << "--log-path=#{opts.delete(:service_log_path)}"
89
- end
90
-
91
- args
59
+ service_log_path = opts.delete(:service_log_path)
60
+ service_log_path ? ["--log-path=#{service_log_path}"] : []
92
61
  end
93
62
 
94
63
  end # W3CBridge