selenium-webdriver 0.0.28 → 0.0.29
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.
- data/CHANGES +25 -0
- data/lib/selenium/webdriver.rb +6 -29
- data/lib/selenium/webdriver/chrome.rb +4 -2
- data/lib/selenium/webdriver/chrome/extension.zip +0 -0
- data/lib/selenium/webdriver/chrome/launcher.rb +15 -16
- data/lib/selenium/webdriver/common.rb +18 -0
- data/lib/selenium/webdriver/{bridge_helper.rb → common/bridge_helper.rb} +0 -0
- data/lib/selenium/webdriver/{core_ext → common/core_ext}/dir.rb +0 -0
- data/lib/selenium/webdriver/{core_ext → common/core_ext}/string.rb +0 -0
- data/lib/selenium/webdriver/{driver.rb → common/driver.rb} +19 -7
- data/lib/selenium/webdriver/{driver_extensions → common/driver_extensions}/takes_screenshot.rb +2 -2
- data/lib/selenium/webdriver/{element.rb → common/element.rb} +30 -3
- data/lib/selenium/webdriver/{error.rb → common/error.rb} +0 -0
- data/lib/selenium/webdriver/{file_reaper.rb → common/file_reaper.rb} +0 -0
- data/lib/selenium/webdriver/{find.rb → common/find.rb} +9 -1
- data/lib/selenium/webdriver/{keys.rb → common/keys.rb} +0 -0
- data/lib/selenium/webdriver/{navigation.rb → common/navigation.rb} +3 -3
- data/lib/selenium/webdriver/{options.rb → common/options.rb} +47 -5
- data/lib/selenium/webdriver/{platform.rb → common/platform.rb} +10 -0
- data/lib/selenium/webdriver/common/socket_poller.rb +47 -0
- data/lib/selenium/webdriver/{target_locator.rb → common/target_locator.rb} +11 -8
- data/lib/selenium/webdriver/{timeouts.rb → common/timeouts.rb} +0 -0
- data/lib/selenium/webdriver/common/wait.rb +60 -0
- data/lib/selenium/webdriver/common/zipper.rb +54 -0
- data/lib/selenium/webdriver/firefox.rb +6 -3
- data/lib/selenium/webdriver/firefox/binary.rb +46 -43
- data/lib/selenium/webdriver/firefox/bridge.rb +2 -10
- data/lib/selenium/webdriver/firefox/extension.rb +51 -0
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/launcher.rb +25 -69
- data/lib/selenium/webdriver/firefox/profile.rb +123 -89
- data/lib/selenium/webdriver/firefox/profiles_ini.rb +2 -1
- data/lib/selenium/webdriver/firefox/socket_lock.rb +77 -0
- data/lib/selenium/webdriver/ie/bridge.rb +25 -38
- data/lib/selenium/webdriver/ie/lib.rb +11 -1
- data/lib/selenium/webdriver/ie/native/win32/InternetExplorerDriver.dll +0 -0
- data/lib/selenium/webdriver/ie/native/x64/InternetExplorerDriver.dll +0 -0
- data/lib/selenium/webdriver/ie/util.rb +3 -17
- data/lib/selenium/webdriver/remote/bridge.rb +9 -1
- data/lib/selenium/webdriver/remote/capabilities.rb +53 -20
- data/lib/selenium/webdriver/remote/http/default.rb +2 -2
- metadata +52 -31
- data/lib/selenium/webdriver/child_process.rb +0 -243
- data/lib/selenium/webdriver/zip_helper.rb +0 -27
@@ -1,243 +0,0 @@
|
|
1
|
-
module Selenium
|
2
|
-
module WebDriver
|
3
|
-
|
4
|
-
#
|
5
|
-
# Cross platform child process launcher
|
6
|
-
#
|
7
|
-
# @private
|
8
|
-
#
|
9
|
-
|
10
|
-
class ChildProcess
|
11
|
-
attr_reader :pid
|
12
|
-
|
13
|
-
def initialize(*args)
|
14
|
-
@args = args
|
15
|
-
|
16
|
-
if Platform.jruby?
|
17
|
-
extend JRubyProcess
|
18
|
-
elsif Platform.ironruby?
|
19
|
-
extend IronRubyProcess
|
20
|
-
elsif Platform.os == :windows
|
21
|
-
extend WindowsProcess
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def ugly_death?
|
26
|
-
code = exit_value
|
27
|
-
code && code != 0
|
28
|
-
end
|
29
|
-
|
30
|
-
#
|
31
|
-
# Returns the exit value of the process, or nil if it's still alive.
|
32
|
-
#
|
33
|
-
|
34
|
-
def exit_value
|
35
|
-
pid, status = Process.waitpid2(@pid, Process::WNOHANG)
|
36
|
-
status.exitstatus if pid
|
37
|
-
end
|
38
|
-
|
39
|
-
def start
|
40
|
-
@pid = fork do
|
41
|
-
unless $DEBUG
|
42
|
-
[STDOUT, STDERR].each { |io| io.reopen("/dev/null") }
|
43
|
-
end
|
44
|
-
|
45
|
-
exec(*@args)
|
46
|
-
end
|
47
|
-
|
48
|
-
self
|
49
|
-
end
|
50
|
-
|
51
|
-
#
|
52
|
-
# Tries increasingly harsher methods to make the process die within
|
53
|
-
# a reasonable time
|
54
|
-
#
|
55
|
-
|
56
|
-
def ensure_death
|
57
|
-
begin
|
58
|
-
$stderr.puts "wait_nonblock(5) -> #{self}" if $DEBUG
|
59
|
-
return wait_nonblock(5)
|
60
|
-
rescue Error::TimeOutError
|
61
|
-
# try next
|
62
|
-
end
|
63
|
-
|
64
|
-
$stderr.puts "TERM -> #{self}" if $DEBUG
|
65
|
-
kill
|
66
|
-
|
67
|
-
begin
|
68
|
-
$stderr.puts "wait_nonblock(5) -> #{self}" if $DEBUG
|
69
|
-
return wait_nonblock(5)
|
70
|
-
rescue Error::TimeOutError
|
71
|
-
# try next
|
72
|
-
end
|
73
|
-
|
74
|
-
$stderr.puts "KILL -> #{self}" if $DEBUG
|
75
|
-
kill!
|
76
|
-
|
77
|
-
$stderr.puts "wait_nonblock(5) -> #{self}" if $DEBUG
|
78
|
-
wait_nonblock(5)
|
79
|
-
rescue Errno::ECHILD
|
80
|
-
# great!
|
81
|
-
true
|
82
|
-
end
|
83
|
-
|
84
|
-
def wait_nonblock(timeout)
|
85
|
-
end_time = Time.now + timeout
|
86
|
-
until Time.now > end_time || exited = exit_value
|
87
|
-
sleep 0.1
|
88
|
-
end
|
89
|
-
|
90
|
-
unless exited
|
91
|
-
raise Error::TimeOutError, "process still alive after #{timeout} seconds"
|
92
|
-
end
|
93
|
-
|
94
|
-
exited
|
95
|
-
end
|
96
|
-
|
97
|
-
def wait
|
98
|
-
assert_started
|
99
|
-
Process.waitpid2 @pid
|
100
|
-
rescue Errno::ECHILD
|
101
|
-
nil
|
102
|
-
end
|
103
|
-
|
104
|
-
def kill
|
105
|
-
assert_started
|
106
|
-
Process.kill('TERM', @pid)
|
107
|
-
end
|
108
|
-
|
109
|
-
def kill!
|
110
|
-
assert_started
|
111
|
-
Process.kill('KILL', @pid)
|
112
|
-
end
|
113
|
-
|
114
|
-
def assert_started
|
115
|
-
raise Error::WebDriverError, "process not started" unless @pid
|
116
|
-
end
|
117
|
-
|
118
|
-
module WindowsProcess
|
119
|
-
def start
|
120
|
-
require "win32/process" # adds a dependency on windows - perhaps we could just use FFI instead?
|
121
|
-
@pid = Process.create(
|
122
|
-
:app_name => @args.join(" "),
|
123
|
-
:inherit => false # don't inherit open file handles
|
124
|
-
).process_id
|
125
|
-
|
126
|
-
self
|
127
|
-
end
|
128
|
-
|
129
|
-
def wait_nonblock(timeout)
|
130
|
-
# win32-process doesn't support passing a second argument to waitpid2
|
131
|
-
# See the README @ http://rubyforge.org/docman/view.php/85/707/README.html
|
132
|
-
if defined?(Process::WNOHANG) && Process.method(:waitpid2).arity != 1
|
133
|
-
return super
|
134
|
-
end
|
135
|
-
Timeout.timeout(timeout, Error::TimeOutError) { wait }
|
136
|
-
rescue Process::Error
|
137
|
-
# no handle, great
|
138
|
-
end
|
139
|
-
|
140
|
-
def kill
|
141
|
-
kill!
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
module JRubyProcess
|
146
|
-
def start
|
147
|
-
require 'java'
|
148
|
-
pb = java.lang.ProcessBuilder.new(@args)
|
149
|
-
|
150
|
-
env = pb.environment
|
151
|
-
ENV.each { |k,v| env.put(k, v) }
|
152
|
-
|
153
|
-
@process = pb.start
|
154
|
-
|
155
|
-
# Firefox 3.6 on Snow Leopard has a lot output on stderr, which makes
|
156
|
-
# the launch act funny if we don't do something to the streams
|
157
|
-
|
158
|
-
@process.getErrorStream.close
|
159
|
-
@process.getInputStream.close
|
160
|
-
|
161
|
-
# Closing the streams solves that problem, but on other platforms we might
|
162
|
-
# need to actually read them.
|
163
|
-
|
164
|
-
# Thread.new do
|
165
|
-
# input, error = 0, 0
|
166
|
-
# loop do
|
167
|
-
# error = @process.getErrorStream.read if error != -1
|
168
|
-
# input = @process.getInputStream.read if input != -1
|
169
|
-
# break if error == -1 && input == -1
|
170
|
-
# end
|
171
|
-
# end
|
172
|
-
|
173
|
-
self
|
174
|
-
end
|
175
|
-
|
176
|
-
def kill
|
177
|
-
assert_started
|
178
|
-
@process.destroy
|
179
|
-
end
|
180
|
-
alias_method :kill!, :kill
|
181
|
-
|
182
|
-
def wait
|
183
|
-
assert_started
|
184
|
-
@process.waitFor
|
185
|
-
[nil, @process.exitValue] # no robust way to get pid here
|
186
|
-
end
|
187
|
-
|
188
|
-
def exit_value
|
189
|
-
assert_started
|
190
|
-
@process.exitValue
|
191
|
-
rescue java.lang.IllegalThreadStateException
|
192
|
-
nil
|
193
|
-
end
|
194
|
-
|
195
|
-
def assert_started
|
196
|
-
raise Error::WebDriverError, "process not started" unless @process
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
module IronRubyProcess
|
201
|
-
def start
|
202
|
-
args = @args.dup
|
203
|
-
|
204
|
-
@process = System::Diagnostics::Process.new
|
205
|
-
@process.StartInfo.UseShellExecute = true
|
206
|
-
@process.StartInfo.FileName = args.shift
|
207
|
-
@process.StartInfo.Arguments = args.join ' '
|
208
|
-
@process.start
|
209
|
-
|
210
|
-
self
|
211
|
-
end
|
212
|
-
|
213
|
-
def kill
|
214
|
-
assert_started
|
215
|
-
@process.Kill
|
216
|
-
end
|
217
|
-
|
218
|
-
def wait
|
219
|
-
assert_started
|
220
|
-
@process.WaitForExit
|
221
|
-
[pid, exit_value]
|
222
|
-
end
|
223
|
-
|
224
|
-
def pid
|
225
|
-
assert_started
|
226
|
-
@process.Id
|
227
|
-
end
|
228
|
-
|
229
|
-
def exit_value
|
230
|
-
assert_started
|
231
|
-
return unless @process.HasExited
|
232
|
-
|
233
|
-
@process.ExitCode
|
234
|
-
end
|
235
|
-
|
236
|
-
def assert_started
|
237
|
-
raise Error::WebDriverError, "process not started" unless @process
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
end # ChildProcess
|
242
|
-
end # WebDriver
|
243
|
-
end # Selenium
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'zip/zip'
|
2
|
-
|
3
|
-
module Selenium
|
4
|
-
module WebDriver
|
5
|
-
module ZipHelper
|
6
|
-
|
7
|
-
def self.unzip(path)
|
8
|
-
destination = Dir.mktmpdir("unzip")
|
9
|
-
FileReaper << destination
|
10
|
-
|
11
|
-
Zip::ZipFile.open(path) do |zip|
|
12
|
-
zip.each do |entry|
|
13
|
-
to = File.join(destination, entry.name)
|
14
|
-
dirname = File.dirname(to)
|
15
|
-
|
16
|
-
FileUtils.mkdir_p dirname unless File.exist? dirname
|
17
|
-
zip.extract(entry, to)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
destination
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
end # ZipHelper
|
26
|
-
end # WebDriver
|
27
|
-
end # Selenium
|