selenium-webdriver 2.48.1 → 2.49.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +34 -0
- data/lib/selenium/webdriver/chrome/bridge.rb +2 -2
- data/lib/selenium/webdriver/chrome/service.rb +6 -3
- data/lib/selenium/webdriver/common/driver.rb +6 -2
- data/lib/selenium/webdriver/common/element.rb +1 -1
- data/lib/selenium/webdriver/common/error.rb +7 -2
- data/lib/selenium/webdriver/common/options.rb +1 -2
- data/lib/selenium/webdriver/common/socket_lock.rb +5 -0
- data/lib/selenium/webdriver/common/window.rb +8 -0
- data/lib/selenium/webdriver/edge/bridge.rb +3 -2
- data/lib/selenium/webdriver/edge/legacy_support.rb +117 -0
- data/lib/selenium/webdriver/edge/service.rb +3 -2
- data/lib/selenium/webdriver/firefox/binary.rb +1 -0
- data/lib/selenium/webdriver/firefox/bridge.rb +2 -0
- data/lib/selenium/webdriver/firefox/extension/prefs.json +2 -0
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/w3c_bridge.rb +10 -41
- data/lib/selenium/webdriver/ie/bridge.rb +1 -1
- data/lib/selenium/webdriver/ie/server.rb +36 -12
- data/lib/selenium/webdriver/phantomjs/service.rb +44 -25
- data/lib/selenium/webdriver/remote/bridge.rb +14 -33
- data/lib/selenium/webdriver/remote/capabilities.rb +8 -6
- data/lib/selenium/webdriver/remote/commands.rb +0 -5
- data/lib/selenium/webdriver/remote/w3c_bridge.rb +68 -86
- data/lib/selenium/webdriver/remote/w3c_capabilities.rb +35 -16
- data/lib/selenium/webdriver/remote/w3c_commands.rb +1 -2
- data/lib/selenium/webdriver/safari/bridge.rb +1 -1
- data/lib/selenium/webdriver/safari/browser.rb +2 -0
- data/lib/selenium/webdriver/safari/options.rb +6 -4
- data/lib/selenium/webdriver/safari/resources/client.js +65 -51
- data/lib/selenium/webdriver/safari/server.rb +23 -2
- data/selenium-webdriver.gemspec +1 -1
- metadata +3 -2
@@ -34,7 +34,7 @@ module Selenium
|
|
34
34
|
def initialize(opts = {})
|
35
35
|
caps = opts.delete(:desired_capabilities) { Remote::Capabilities.internet_explorer }
|
36
36
|
timeout = opts.delete(:timeout) { DEFAULT_TIMEOUT }
|
37
|
-
port = opts.delete(:port) {
|
37
|
+
port = opts.delete(:port) { DEFAULT_PORT }
|
38
38
|
http_client = opts.delete(:http_client)
|
39
39
|
ignore_mode = opts.delete(:introduce_flakiness_by_ignoring_security_domains)
|
40
40
|
native_events = opts.delete(:native_events) != false
|
@@ -20,9 +20,16 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module IE
|
23
|
+
|
24
|
+
#
|
25
|
+
# @api private
|
26
|
+
#
|
27
|
+
|
23
28
|
class Server
|
24
29
|
|
25
|
-
STOP_TIMEOUT
|
30
|
+
STOP_TIMEOUT = 5
|
31
|
+
SOCKET_LOCK_TIMEOUT = 45
|
32
|
+
MISSING_TEXT = "Unable to find standalone executable. Please download the IEDriverServer from http://selenium-release.storage.googleapis.com/index.html and place the executable on your PATH."
|
26
33
|
|
27
34
|
def self.get(opts = {})
|
28
35
|
binary = IE.driver_path || Platform.find_binary("IEDriverServer")
|
@@ -30,8 +37,7 @@ module Selenium
|
|
30
37
|
if binary
|
31
38
|
new binary, opts
|
32
39
|
else
|
33
|
-
raise Error::WebDriverError,
|
34
|
-
"Unable to find standalone executable. Please download the IEDriverServer from http://selenium-release.storage.googleapis.com/index.html and place the executable on your PATH."
|
40
|
+
raise Error::WebDriverError, MISSING_TEXT
|
35
41
|
end
|
36
42
|
end
|
37
43
|
|
@@ -52,23 +58,19 @@ module Selenium
|
|
52
58
|
unless opts.empty?
|
53
59
|
raise ArgumentError, "invalid option#{'s' if opts.size != 1}: #{opts.inspect}"
|
54
60
|
end
|
55
|
-
|
56
61
|
end
|
57
62
|
|
58
63
|
def start(port, timeout)
|
59
64
|
return @port if running?
|
60
65
|
|
61
66
|
@port = port
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
unless SocketPoller.new(Platform.localhost, @port, timeout).connected?
|
68
|
-
raise Error::WebDriverError, "unable to connect to IE server within #{timeout} seconds"
|
67
|
+
socket_lock.locked do
|
68
|
+
find_free_port
|
69
|
+
start_process
|
70
|
+
connect_until_stable(timeout)
|
69
71
|
end
|
70
72
|
|
71
|
-
Platform.exit_hook { stop }
|
73
|
+
Platform.exit_hook { stop } # make sure we don't leave the server running
|
72
74
|
|
73
75
|
@port
|
74
76
|
end
|
@@ -103,6 +105,28 @@ module Selenium
|
|
103
105
|
args
|
104
106
|
end
|
105
107
|
|
108
|
+
def find_free_port
|
109
|
+
@port = PortProber.above @port
|
110
|
+
end
|
111
|
+
|
112
|
+
def start_process
|
113
|
+
@process = ChildProcess.new(@binary_path, *server_args)
|
114
|
+
@process.io.inherit! if $DEBUG
|
115
|
+
@process.start
|
116
|
+
end
|
117
|
+
|
118
|
+
def connect_until_stable(timeout)
|
119
|
+
socket_poller = SocketPoller.new Platform.localhost, @port, timeout
|
120
|
+
|
121
|
+
unless socket_poller.connected?
|
122
|
+
raise Error::WebDriverError, "unable to connect to IE server within #{timeout} seconds"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def socket_lock
|
127
|
+
@socket_lock ||= SocketLock.new(@port - 1, SOCKET_LOCK_TIMEOUT)
|
128
|
+
end
|
129
|
+
|
106
130
|
end # Server
|
107
131
|
end # IE
|
108
132
|
end # WebDriver
|
@@ -26,12 +26,11 @@ module Selenium
|
|
26
26
|
#
|
27
27
|
|
28
28
|
class Service
|
29
|
-
START_TIMEOUT
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
attr_reader :uri
|
29
|
+
START_TIMEOUT = 20
|
30
|
+
SOCKET_LOCK_TIMEOUT = 45
|
31
|
+
STOP_TIMEOUT = 5
|
32
|
+
DEFAULT_PORT = 8910
|
33
|
+
MISSING_TEXT = "Unable to find phantomjs executable."
|
35
34
|
|
36
35
|
def self.executable_path
|
37
36
|
@executable_path ||= (
|
@@ -44,35 +43,33 @@ module Selenium
|
|
44
43
|
end
|
45
44
|
|
46
45
|
def self.default_service(port = nil)
|
47
|
-
new executable_path,
|
46
|
+
new executable_path, DEFAULT_PORT
|
48
47
|
end
|
49
48
|
|
50
49
|
def initialize(executable_path, port)
|
51
|
-
@
|
50
|
+
@host = Platform.localhost
|
52
51
|
@executable = executable_path
|
52
|
+
@port = Integer(port)
|
53
53
|
end
|
54
54
|
|
55
55
|
def start(args = [])
|
56
56
|
if @process && @process.alive?
|
57
|
-
raise "already started: #{
|
57
|
+
raise "already started: #{uri.inspect} #{@executable.inspect}"
|
58
58
|
end
|
59
59
|
|
60
|
-
|
61
|
-
@process.start
|
62
|
-
|
63
|
-
socket_poller = SocketPoller.new Platform.localhost, @uri.port, START_TIMEOUT
|
60
|
+
Platform.exit_hook { stop } # make sure we don't leave the server running
|
64
61
|
|
65
|
-
|
66
|
-
|
62
|
+
socket_lock.locked do
|
63
|
+
find_free_port
|
64
|
+
start_process(args)
|
65
|
+
connect_until_stable
|
67
66
|
end
|
68
|
-
|
69
|
-
Platform.exit_hook { stop } # make sure we don't leave the server running
|
70
67
|
end
|
71
68
|
|
72
69
|
def stop
|
73
70
|
return if @process.nil? || @process.exited?
|
74
71
|
|
75
|
-
Net::HTTP.start(
|
72
|
+
Net::HTTP.start(@host, @port) do |http|
|
76
73
|
http.open_timeout = STOP_TIMEOUT / 2
|
77
74
|
http.read_timeout = STOP_TIMEOUT / 2
|
78
75
|
|
@@ -89,21 +86,43 @@ module Selenium
|
|
89
86
|
end
|
90
87
|
end
|
91
88
|
|
92
|
-
def
|
93
|
-
|
94
|
-
|
89
|
+
def find_free_port
|
90
|
+
@port = PortProber.above @port
|
91
|
+
end
|
92
|
+
|
93
|
+
def uri
|
94
|
+
URI.parse "http://#{@host}:#{@port}"
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def start_process(args)
|
100
|
+
server_command = [@executable, "--webdriver=#{@port}", *args]
|
101
|
+
@process = ChildProcess.build(*server_command.compact)
|
95
102
|
|
96
103
|
if $DEBUG == true
|
97
|
-
process.io.inherit!
|
104
|
+
@process.io.inherit!
|
98
105
|
elsif Platform.jruby?
|
99
106
|
# apparently we need to read the output for phantomjs to work on jruby
|
100
|
-
process.io.stdout = process.io.stderr = File.new(Platform.null_device, 'w')
|
107
|
+
@process.io.stdout = @process.io.stderr = File.new(Platform.null_device, 'w')
|
108
|
+
end
|
109
|
+
|
110
|
+
@process.start
|
111
|
+
end
|
112
|
+
|
113
|
+
def connect_until_stable
|
114
|
+
socket_poller = SocketPoller.new @host, @port, START_TIMEOUT
|
115
|
+
|
116
|
+
unless socket_poller.connected?
|
117
|
+
raise Error::WebDriverError, "unable to connect to phantomjs @ #{uri} after #{START_TIMEOUT} seconds"
|
101
118
|
end
|
119
|
+
end
|
102
120
|
|
103
|
-
|
121
|
+
def socket_lock
|
122
|
+
@socket_lock ||= SocketLock.new(@port - 1, SOCKET_LOCK_TIMEOUT)
|
104
123
|
end
|
105
124
|
|
106
125
|
end # Service
|
107
126
|
end # PhantomJS
|
108
127
|
end # WebDriver
|
109
|
-
end # Service
|
128
|
+
end # Service
|
@@ -106,7 +106,8 @@ module Selenium
|
|
106
106
|
DriverExtensions::HasTouchScreen,
|
107
107
|
DriverExtensions::HasLocation,
|
108
108
|
DriverExtensions::HasNetworkConnection,
|
109
|
-
DriverExtensions::HasRemoteStatus
|
109
|
+
DriverExtensions::HasRemoteStatus,
|
110
|
+
DriverExtensions::HasWebStorage
|
110
111
|
]
|
111
112
|
end
|
112
113
|
|
@@ -153,28 +154,20 @@ module Selenium
|
|
153
154
|
# alerts
|
154
155
|
#
|
155
156
|
|
156
|
-
def getAlert
|
157
|
-
execute :getAlert
|
158
|
-
end
|
159
|
-
|
160
157
|
def acceptAlert
|
161
|
-
|
162
|
-
execute command
|
158
|
+
execute :acceptAlert
|
163
159
|
end
|
164
160
|
|
165
161
|
def dismissAlert
|
166
|
-
|
167
|
-
execute command
|
162
|
+
execute :dismissAlert
|
168
163
|
end
|
169
164
|
|
170
165
|
def setAlertValue(keys)
|
171
|
-
|
172
|
-
execute command, {}, :text => keys.to_s
|
166
|
+
execute :setAlertValue, {}, :text => keys.to_s
|
173
167
|
end
|
174
168
|
|
175
169
|
def getAlertText
|
176
|
-
|
177
|
-
execute command
|
170
|
+
execute :getAlertText
|
178
171
|
end
|
179
172
|
|
180
173
|
#
|
@@ -201,20 +194,8 @@ module Selenium
|
|
201
194
|
execute :getPageSource
|
202
195
|
end
|
203
196
|
|
204
|
-
def getVisible
|
205
|
-
execute :getVisible
|
206
|
-
end
|
207
|
-
|
208
|
-
def setVisible(bool)
|
209
|
-
execute :setVisible, {}, bool
|
210
|
-
end
|
211
|
-
|
212
197
|
def switchToWindow(name)
|
213
|
-
|
214
|
-
execute :switchToWindow, {}, :handle => name
|
215
|
-
else
|
216
|
-
execute :switchToWindow, {}, :name => name
|
217
|
-
end
|
198
|
+
execute :switchToWindow, {}, :name => name
|
218
199
|
end
|
219
200
|
|
220
201
|
def switchToFrame(id)
|
@@ -458,7 +439,6 @@ module Selenium
|
|
458
439
|
execute :clearElement, :id => element
|
459
440
|
end
|
460
441
|
|
461
|
-
|
462
442
|
def submitElement(element)
|
463
443
|
execute :submitElement, :id => element
|
464
444
|
end
|
@@ -534,7 +514,11 @@ module Selenium
|
|
534
514
|
data = execute :getLog, {}, :type => type.to_s
|
535
515
|
|
536
516
|
Array(data).map do |l|
|
537
|
-
|
517
|
+
begin
|
518
|
+
LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message')
|
519
|
+
rescue KeyError
|
520
|
+
next
|
521
|
+
end
|
538
522
|
end
|
539
523
|
end
|
540
524
|
|
@@ -587,14 +571,11 @@ module Selenium
|
|
587
571
|
def isElementDisplayed(element)
|
588
572
|
execute :isElementDisplayed, :id => element
|
589
573
|
end
|
574
|
+
|
590
575
|
def getElementValueOfCssProperty(element, prop)
|
591
576
|
execute :getElementValueOfCssProperty, :id => element, :property_name => prop
|
592
577
|
end
|
593
578
|
|
594
|
-
def elementEquals(element, other)
|
595
|
-
element.ref == other.ref
|
596
|
-
end
|
597
|
-
|
598
579
|
#
|
599
580
|
# finding elements
|
600
581
|
#
|
@@ -627,7 +608,7 @@ module Selenium
|
|
627
608
|
private
|
628
609
|
|
629
610
|
def assert_javascript_enabled
|
630
|
-
return if capabilities.
|
611
|
+
return if capabilities.javascript_enabled?
|
631
612
|
raise Error::UnsupportedOperationError, "underlying webdriver instance does not support javascript"
|
632
613
|
end
|
633
614
|
|
@@ -74,18 +74,19 @@ module Selenium
|
|
74
74
|
new({
|
75
75
|
:browser_name => "chrome",
|
76
76
|
:javascript_enabled => true,
|
77
|
-
:css_selectors_enabled => true
|
78
|
-
|
77
|
+
:css_selectors_enabled => true,
|
78
|
+
:loggingPrefs => {:browser => "ALL",
|
79
|
+
:driver => "ALL"}
|
80
|
+
}.merge(opts))
|
79
81
|
end
|
80
82
|
|
81
83
|
def edge(opts = {})
|
82
|
-
|
83
|
-
:browser_name => "MicrosoftEdge",
|
84
|
-
:platform => :windows,
|
85
|
-
}.merge(opts))
|
84
|
+
W3CCapabilities.edge(opts)
|
86
85
|
end
|
87
86
|
|
88
87
|
def firefox(opts = {})
|
88
|
+
return W3CCapabilities.firefox(opts) if opts[:marionette]
|
89
|
+
|
89
90
|
new({
|
90
91
|
:browser_name => "firefox",
|
91
92
|
:javascript_enabled => true,
|
@@ -146,6 +147,7 @@ module Selenium
|
|
146
147
|
def safari(opts = {})
|
147
148
|
new({
|
148
149
|
:browser_name => "safari",
|
150
|
+
:platform => :mac,
|
149
151
|
:javascript_enabled => true,
|
150
152
|
:takes_screenshot => true,
|
151
153
|
:css_selectors_enabled => true
|
@@ -78,11 +78,6 @@ class Selenium::WebDriver::Remote::Bridge
|
|
78
78
|
command :getAlertText, :get, "session/:session_id/alert_text"
|
79
79
|
command :setAlertValue, :post, "session/:session_id/alert_text"
|
80
80
|
|
81
|
-
command :dismissAlertW3C, :post, "session/:session_id/alert/dismiss"
|
82
|
-
command :acceptAlertW3C, :post, "session/:session_id/alert/accept"
|
83
|
-
command :getAlertTextW3C, :get, "session/:session_id/alert/text"
|
84
|
-
command :setAlertValueW3C, :post, "session/:session_id/alert/text"
|
85
|
-
|
86
81
|
#
|
87
82
|
# target locator
|
88
83
|
#
|
@@ -17,6 +17,8 @@
|
|
17
17
|
# specific language governing permissions and limitations
|
18
18
|
# under the License.
|
19
19
|
|
20
|
+
require 'json'
|
21
|
+
|
20
22
|
module Selenium
|
21
23
|
module WebDriver
|
22
24
|
module Remote
|
@@ -60,22 +62,27 @@ module Selenium
|
|
60
62
|
#
|
61
63
|
|
62
64
|
def initialize(opts = {})
|
65
|
+
if opts.fetch(:desired_capabilities, {})[:browser_name] == 'MicrosoftEdge'
|
66
|
+
require_relative '../edge/legacy_support'
|
67
|
+
extend Edge::LegacySupport
|
68
|
+
end
|
69
|
+
|
63
70
|
opts = opts.dup
|
64
71
|
|
65
72
|
http_client = opts.delete(:http_client) { Http::Default.new }
|
66
73
|
desired_capabilities = opts.delete(:desired_capabilities) { W3CCapabilities.firefox }
|
67
74
|
url = opts.delete(:url) { "http://#{Platform.localhost}:4444/wd/hub" }
|
68
75
|
|
69
|
-
|
70
|
-
|
71
|
-
|
76
|
+
desired_capabilities = W3CCapabilities.send(desired_capabilities) if desired_capabilities.is_a? Symbol
|
77
|
+
|
78
|
+
desired_capabilities[:marionette] = opts.delete(:marionette) unless opts[:marionette].nil?
|
72
79
|
|
73
|
-
if desired_capabilities.
|
74
|
-
|
75
|
-
|
76
|
-
end
|
80
|
+
if desired_capabilities[:marionette] && Firefox::Binary.version < 45
|
81
|
+
raise Error::WebDriverError, "Marionette is not supported in Firefox Version #{Firefox::Binary.version}"
|
82
|
+
end
|
77
83
|
|
78
|
-
|
84
|
+
unless opts.empty?
|
85
|
+
raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
|
79
86
|
end
|
80
87
|
|
81
88
|
uri = url.kind_of?(URI) ? url : URI.parse(url)
|
@@ -85,7 +92,6 @@ module Selenium
|
|
85
92
|
|
86
93
|
@http = http_client
|
87
94
|
@capabilities = create_session(desired_capabilities)
|
88
|
-
|
89
95
|
@file_detector = nil
|
90
96
|
end
|
91
97
|
|
@@ -104,9 +110,8 @@ module Selenium
|
|
104
110
|
DriverExtensions::HasSessionId,
|
105
111
|
DriverExtensions::Rotatable,
|
106
112
|
DriverExtensions::HasTouchScreen,
|
107
|
-
DriverExtensions::
|
108
|
-
DriverExtensions::
|
109
|
-
DriverExtensions::HasRemoteStatus
|
113
|
+
DriverExtensions::HasRemoteStatus,
|
114
|
+
DriverExtensions::HasWebStorage
|
110
115
|
]
|
111
116
|
end
|
112
117
|
|
@@ -126,6 +131,8 @@ module Selenium
|
|
126
131
|
end
|
127
132
|
|
128
133
|
def status
|
134
|
+
jwp = Selenium::WebDriver::Remote::Bridge::COMMANDS[:status]
|
135
|
+
self.class.command(:status, jwp.first, jwp.last)
|
129
136
|
execute :status
|
130
137
|
end
|
131
138
|
|
@@ -133,10 +140,6 @@ module Selenium
|
|
133
140
|
execute :get, {}, :url => url
|
134
141
|
end
|
135
142
|
|
136
|
-
def getCapabilities
|
137
|
-
W3CCapabilities.json_create execute(:getCapabilities)
|
138
|
-
end
|
139
|
-
|
140
143
|
def setImplicitWaitTimeout(milliseconds)
|
141
144
|
setTimeout('implicit', milliseconds)
|
142
145
|
end
|
@@ -153,10 +156,6 @@ module Selenium
|
|
153
156
|
# alerts
|
154
157
|
#
|
155
158
|
|
156
|
-
def getAlert
|
157
|
-
execute :getAlert
|
158
|
-
end
|
159
|
-
|
160
159
|
def acceptAlert
|
161
160
|
execute :acceptAlert
|
162
161
|
end
|
@@ -194,15 +193,9 @@ module Selenium
|
|
194
193
|
end
|
195
194
|
|
196
195
|
def getPageSource
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
def getVisible
|
201
|
-
execute :getVisible
|
202
|
-
end
|
203
|
-
|
204
|
-
def setVisible(bool)
|
205
|
-
execute :setVisible, {}, bool
|
196
|
+
executeScript("var source = document.documentElement.outerHTML;" +
|
197
|
+
"if (!source) { source = new XMLSerializer().serializeToString(document); }" +
|
198
|
+
"return source;")
|
206
199
|
end
|
207
200
|
|
208
201
|
def switchToWindow(name)
|
@@ -210,16 +203,8 @@ module Selenium
|
|
210
203
|
end
|
211
204
|
|
212
205
|
def switchToFrame(id)
|
213
|
-
|
214
|
-
|
215
|
-
find_element_by('id', id)
|
216
|
-
when Hash
|
217
|
-
find_element_by(id.keys.first.to_s, id.values.first)
|
218
|
-
else
|
219
|
-
id
|
220
|
-
end
|
221
|
-
|
222
|
-
execute :switchToFrame, {}, :id => locator
|
206
|
+
id = find_element_by('id', id) if id.is_a? String
|
207
|
+
execute :switchToFrame, {}, :id => id
|
223
208
|
end
|
224
209
|
|
225
210
|
def switchToParentFrame
|
@@ -258,31 +243,40 @@ module Selenium
|
|
258
243
|
execute :getWindowHandle
|
259
244
|
end
|
260
245
|
|
261
|
-
# TODO - These Commands might require checking for being
|
262
|
-
# current window before performing
|
263
246
|
def setWindowSize(width, height, handle = :current)
|
247
|
+
unless handle == :current
|
248
|
+
raise Error::WebDriverError, 'Switch to desired window before changing its size'
|
249
|
+
end
|
264
250
|
execute :setWindowSize, {}, {:width => width,
|
265
251
|
:height => height}
|
266
252
|
end
|
267
253
|
|
268
254
|
def maximizeWindow(handle = :current)
|
255
|
+
unless handle == :current
|
256
|
+
raise Error::WebDriverError, 'Switch to desired window before changing its size'
|
257
|
+
end
|
269
258
|
execute :maximizeWindow
|
270
259
|
end
|
271
260
|
|
261
|
+
def fullscreenWindow
|
262
|
+
execute :fullscreenWindow
|
263
|
+
end
|
264
|
+
|
272
265
|
def getWindowSize(handle = :current)
|
266
|
+
unless handle == :current
|
267
|
+
raise Error::WebDriverError, 'Switch to desired window before getting its size'
|
268
|
+
end
|
273
269
|
data = execute :getWindowSize
|
274
270
|
|
275
271
|
Dimension.new data['width'], data['height']
|
276
272
|
end
|
277
273
|
|
278
|
-
def setWindowPosition(
|
279
|
-
|
274
|
+
def setWindowPosition(_x, _y, _handle = nil)
|
275
|
+
raise Error::WebDriverError::UnsupportedOperationError, 'The W3C standard does not currently support setting the Window Position'
|
280
276
|
end
|
281
277
|
|
282
|
-
def getWindowPosition(
|
283
|
-
|
284
|
-
|
285
|
-
Point.new data['x'], data['y']
|
278
|
+
def getWindowPosition(_handle = nil)
|
279
|
+
raise Error::WebDriverError::UnsupportedOperationError, 'The W3C standard does not currently support getting the Window Position'
|
286
280
|
end
|
287
281
|
|
288
282
|
def getScreenshot
|
@@ -294,69 +288,67 @@ module Selenium
|
|
294
288
|
#
|
295
289
|
|
296
290
|
def getLocalStorageItem(key)
|
297
|
-
|
291
|
+
executeScript("return localStorage.getItem('#{key}')")
|
298
292
|
end
|
299
293
|
|
300
294
|
def removeLocalStorageItem(key)
|
301
|
-
|
295
|
+
executeScript("localStorage.removeItem('#{key}')")
|
302
296
|
end
|
303
297
|
|
304
298
|
def getLocalStorageKeys
|
305
|
-
|
299
|
+
executeScript("return Object.keys(localStorage)")
|
306
300
|
end
|
307
301
|
|
308
302
|
def setLocalStorageItem(key, value)
|
309
|
-
|
303
|
+
executeScript("localStorage.setItem('#{key}', '#{value}')")
|
310
304
|
end
|
311
305
|
|
312
306
|
def clearLocalStorage
|
313
|
-
|
307
|
+
executeScript("localStorage.clear()")
|
314
308
|
end
|
315
309
|
|
316
310
|
def getLocalStorageSize
|
317
|
-
|
311
|
+
executeScript("return localStorage.length")
|
318
312
|
end
|
319
313
|
|
320
314
|
def getSessionStorageItem(key)
|
321
|
-
|
315
|
+
executeScript("return sessionStorage.getItem('#{key}')")
|
322
316
|
end
|
323
317
|
|
324
318
|
def removeSessionStorageItem(key)
|
325
|
-
|
319
|
+
executeScript("sessionStorage.removeItem('#{key}')")
|
326
320
|
end
|
327
321
|
|
328
322
|
def getSessionStorageKeys
|
329
|
-
|
323
|
+
executeScript("return Object.keys(sessionStorage)")
|
330
324
|
end
|
331
325
|
|
332
326
|
def setSessionStorageItem(key, value)
|
333
|
-
|
327
|
+
executeScript("sessionStorage.setItem('#{key}', '#{value}')")
|
334
328
|
end
|
335
329
|
|
336
330
|
def clearSessionStorage
|
337
|
-
|
331
|
+
executeScript("sessionStorage.clear()")
|
338
332
|
end
|
339
333
|
|
340
334
|
def getSessionStorageSize
|
341
|
-
|
335
|
+
executeScript("return sessionStorage.length")
|
342
336
|
end
|
343
337
|
|
344
338
|
def getLocation
|
345
|
-
|
346
|
-
Location.new obj['latitude'], obj['longitude'], obj['altitude']
|
339
|
+
raise Error::WebDriverError::UnsupportedOperationError, 'The W3C standard does not currently support getting location'
|
347
340
|
end
|
348
341
|
|
349
|
-
def setLocation(
|
350
|
-
|
351
|
-
execute :setLocation, {}, :location => loc
|
342
|
+
def setLocation(_lat, _lon, _alt)
|
343
|
+
raise Error::WebDriverError::UnsupportedOperationError, 'The W3C standard does not currently support setting location'
|
352
344
|
end
|
353
345
|
|
354
346
|
def getNetworkConnection
|
355
|
-
|
347
|
+
raise Error::WebDriverError::UnsupportedOperationError, 'The W3C standard does not currently support getting network connection'
|
356
348
|
end
|
357
349
|
|
358
|
-
def setNetworkConnection(
|
359
|
-
|
350
|
+
def setNetworkConnection(_type)
|
351
|
+
raise Error::WebDriverError::UnsupportedOperationError, 'The W3C standard does not currently support setting network connection'
|
360
352
|
end
|
361
353
|
|
362
354
|
#
|
@@ -378,7 +370,7 @@ module Selenium
|
|
378
370
|
#
|
379
371
|
|
380
372
|
def addCookie(cookie)
|
381
|
-
execute :addCookie, {}, cookie
|
373
|
+
execute :addCookie, {}, :cookie => cookie
|
382
374
|
end
|
383
375
|
|
384
376
|
def deleteCookie(name)
|
@@ -440,23 +432,15 @@ module Selenium
|
|
440
432
|
sendKeysToElement(getActiveElement, keys)
|
441
433
|
end
|
442
434
|
|
435
|
+
# TODO - Implement file verification
|
443
436
|
def sendKeysToElement(element, keys)
|
444
437
|
execute :elementSendKeys, {:id => element}, {:value => keys.join('').split(//)}
|
445
438
|
end
|
446
439
|
|
447
|
-
def upload(local_file)
|
448
|
-
unless File.file?(local_file)
|
449
|
-
raise Error::WebDriverError, "you may only upload files: #{local_file.inspect}"
|
450
|
-
end
|
451
|
-
|
452
|
-
execute :uploadFile, {}, :file => Zipper.zip_file(local_file)
|
453
|
-
end
|
454
|
-
|
455
440
|
def clearElement(element)
|
456
441
|
execute :elementClear, :id => element
|
457
442
|
end
|
458
443
|
|
459
|
-
|
460
444
|
def submitElement(element)
|
461
445
|
executeScript("var e = arguments[0].ownerDocument.createEvent('Event');" +
|
462
446
|
"e.initEvent('submit', true, true);" +
|
@@ -542,19 +526,18 @@ module Selenium
|
|
542
526
|
end
|
543
527
|
|
544
528
|
def getElementLocation(element)
|
545
|
-
data = execute :
|
529
|
+
data = execute :getElementRect, :id => element
|
546
530
|
|
547
531
|
Point.new data['x'], data['y']
|
548
532
|
end
|
549
533
|
|
550
534
|
def getElementLocationOnceScrolledIntoView(element)
|
551
|
-
|
552
|
-
|
553
|
-
Point.new data['x'], data['y']
|
535
|
+
sendKeysToElement(element, [''])
|
536
|
+
getElementLocation(element)
|
554
537
|
end
|
555
538
|
|
556
539
|
def getElementSize(element)
|
557
|
-
data = execute :
|
540
|
+
data = execute :getElementRect, :id => element
|
558
541
|
|
559
542
|
Dimension.new data['width'], data['height']
|
560
543
|
end
|
@@ -568,16 +551,15 @@ module Selenium
|
|
568
551
|
end
|
569
552
|
|
570
553
|
def isElementDisplayed(element)
|
554
|
+
jwp = Selenium::WebDriver::Remote::Bridge::COMMANDS[:isElementDisplayed]
|
555
|
+
self.class.command(:isElementDisplayed, jwp.first, jwp.last)
|
571
556
|
execute :isElementDisplayed, :id => element
|
572
557
|
end
|
558
|
+
|
573
559
|
def getElementValueOfCssProperty(element, prop)
|
574
560
|
execute :getElementCssValue, :id => element, :property_name => prop
|
575
561
|
end
|
576
562
|
|
577
|
-
def elementEquals(element, other)
|
578
|
-
element.ref == other.ref
|
579
|
-
end
|
580
|
-
|
581
563
|
#
|
582
564
|
# finding elements
|
583
565
|
#
|