selenium-webdriver 2.40.0.rc1 → 2.40.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +9 -0
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/safari.rb +2 -1
- data/lib/selenium/webdriver/safari/bridge.rb +23 -13
- data/lib/selenium/webdriver/safari/extensions.rb +168 -0
- data/lib/selenium/webdriver/safari/options.rb +79 -0
- data/lib/selenium/webdriver/support/abstract_event_listener.rb +25 -0
- metadata +4 -3
- data/lib/selenium/webdriver/safari/extension.rb +0 -121
data/CHANGES
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
2.40.0 (???)
|
2
|
+
============
|
3
|
+
|
4
|
+
* Fix bug where FileReaper would not reap files added in a child process
|
5
|
+
* Document AbstractEventListener (#5994)
|
6
|
+
* Safari:
|
7
|
+
* Add Safari::Options + clean up Safari extension handling (#6382)
|
8
|
+
* Add support for user extensions (#6815)
|
9
|
+
|
1
10
|
2.39.0 (2013-12-17)
|
2
11
|
===================
|
3
12
|
|
Binary file
|
@@ -41,6 +41,7 @@ end
|
|
41
41
|
|
42
42
|
require 'selenium/webdriver/safari/browser'
|
43
43
|
require 'selenium/webdriver/safari/server'
|
44
|
-
require 'selenium/webdriver/safari/
|
44
|
+
require 'selenium/webdriver/safari/extensions'
|
45
|
+
require 'selenium/webdriver/safari/options'
|
45
46
|
require 'selenium/webdriver/safari/bridge'
|
46
47
|
|
@@ -6,19 +6,17 @@ module Selenium
|
|
6
6
|
COMMAND_TIMEOUT = 60
|
7
7
|
|
8
8
|
def initialize(opts = {})
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
install_extension = opts.fetch(:install_extension) { true }
|
9
|
+
command_timeout = Integer(opts[:timeout] || COMMAND_TIMEOUT)
|
10
|
+
safari_options = opts.delete(:options) || Safari::Options.new(opts)
|
11
|
+
capabilities = merge_capabilities(opts, safari_options)
|
13
12
|
|
14
13
|
@command_id ||= 0
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
@extension.install
|
19
|
-
end
|
15
|
+
@extensions = Extensions.new(safari_options)
|
16
|
+
@extensions.install
|
20
17
|
|
21
|
-
|
18
|
+
# TODO: handle safari_opts['cleanSession']
|
19
|
+
@server = Server.new(safari_options.port, command_timeout)
|
22
20
|
@server.start
|
23
21
|
|
24
22
|
@safari = Browser.new
|
@@ -26,7 +24,7 @@ module Selenium
|
|
26
24
|
|
27
25
|
@server.wait_for_connection
|
28
26
|
|
29
|
-
super(:
|
27
|
+
super(desired_capabilities: capabilities)
|
30
28
|
end
|
31
29
|
|
32
30
|
def quit
|
@@ -34,7 +32,7 @@ module Selenium
|
|
34
32
|
|
35
33
|
@server.stop
|
36
34
|
@safari.stop
|
37
|
-
@
|
35
|
+
@extensions && @extensions.uninstall
|
38
36
|
end
|
39
37
|
|
40
38
|
def driver_extensions
|
@@ -75,8 +73,8 @@ module Selenium
|
|
75
73
|
raise Error.for_code(status_code), response['value']['message']
|
76
74
|
end
|
77
75
|
|
78
|
-
if raw['id'] != @command_id.to_s
|
79
|
-
raise Error::WebDriverError, "response id does not match command id"
|
76
|
+
if raw['id'].to_s != @command_id.to_s
|
77
|
+
raise Error::WebDriverError, "response id does not match command id: #{raw['id']} != #{@command_id}"
|
80
78
|
end
|
81
79
|
|
82
80
|
response
|
@@ -103,6 +101,18 @@ module Selenium
|
|
103
101
|
path
|
104
102
|
end
|
105
103
|
|
104
|
+
def merge_capabilities(opts, safari_options)
|
105
|
+
caps = safari_options.to_capabilities
|
106
|
+
other = opts[:desired_capabilities]
|
107
|
+
|
108
|
+
if other
|
109
|
+
other = opts[:desired_capabilities].as_json
|
110
|
+
caps['safari.options'].merge!(other.delete('safari.options') || {})
|
111
|
+
caps.merge!(other)
|
112
|
+
end
|
113
|
+
|
114
|
+
caps
|
115
|
+
end
|
106
116
|
end
|
107
117
|
|
108
118
|
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
module Safari
|
4
|
+
#
|
5
|
+
# @api private
|
6
|
+
#
|
7
|
+
|
8
|
+
class Extensions
|
9
|
+
|
10
|
+
PLIST = <<-XML
|
11
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
12
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
13
|
+
<plist version="1.0">
|
14
|
+
<dict>
|
15
|
+
<key>Available Updates</key>
|
16
|
+
<dict>
|
17
|
+
<key>Last Update Check Time</key>
|
18
|
+
<real>370125644.75941497</real>
|
19
|
+
<key>Updates List</key>
|
20
|
+
<array/>
|
21
|
+
</dict>
|
22
|
+
<key>Installed Extensions</key>
|
23
|
+
<array>
|
24
|
+
%s
|
25
|
+
</array>
|
26
|
+
<key>Version</key>
|
27
|
+
<integer>1</integer>
|
28
|
+
</dict>
|
29
|
+
</plist>
|
30
|
+
XML
|
31
|
+
|
32
|
+
PLIST_EXTENSION_LINE = <<-XML
|
33
|
+
<dict>
|
34
|
+
<key>Added Non-Default Toolbar Items</key>
|
35
|
+
<array/>
|
36
|
+
<key>Archive File Name</key>
|
37
|
+
<string>%s.safariextz</string>
|
38
|
+
<key>Bundle Directory Name</key>
|
39
|
+
<string>%s.safariextension</string>
|
40
|
+
<key>Enabled</key>
|
41
|
+
<true/>
|
42
|
+
<key>Hidden Bars</key>
|
43
|
+
<array/>
|
44
|
+
<key>Removed Default Toolbar Items</key>
|
45
|
+
<array/>
|
46
|
+
</dict>
|
47
|
+
XML
|
48
|
+
|
49
|
+
def initialize(opts = {})
|
50
|
+
@data_dir = opts.data_dir || safari_data_dir
|
51
|
+
@skip = opts.skip_extension_installation?
|
52
|
+
@extensions = opts.extensions
|
53
|
+
@backup = Backup.new
|
54
|
+
@installed = false
|
55
|
+
end
|
56
|
+
|
57
|
+
def install
|
58
|
+
return if @installed
|
59
|
+
installed_extensions = []
|
60
|
+
|
61
|
+
if install_directory.exist?
|
62
|
+
@backup.backup install_directory
|
63
|
+
end
|
64
|
+
|
65
|
+
install_directory.mkpath
|
66
|
+
|
67
|
+
unless @skip
|
68
|
+
extension_destination.rmtree if extension_destination.exist?
|
69
|
+
FileUtils.cp extension_source.to_s, extension_destination.to_s
|
70
|
+
|
71
|
+
installed_extensions << extension_destination
|
72
|
+
end
|
73
|
+
|
74
|
+
@extensions.each do |extension|
|
75
|
+
target = install_directory.join(extension.basename)
|
76
|
+
|
77
|
+
if extension.expand_path == target.expand_path
|
78
|
+
@backup.backup(target)
|
79
|
+
else
|
80
|
+
FileUtils.cp extension, target
|
81
|
+
end
|
82
|
+
|
83
|
+
installed_extensions << target
|
84
|
+
end
|
85
|
+
|
86
|
+
plist_destination.open('w') do |io|
|
87
|
+
extension_lines = installed_extensions.map do |ext|
|
88
|
+
name = ext.basename('.safariextz').to_s
|
89
|
+
PLIST_EXTENSION_LINE % [name, name]
|
90
|
+
end
|
91
|
+
io << PLIST % extension_lines.join("\n")
|
92
|
+
end
|
93
|
+
|
94
|
+
Platform.exit_hook { uninstall }
|
95
|
+
@installed = true
|
96
|
+
end
|
97
|
+
|
98
|
+
def uninstall
|
99
|
+
return unless @installed
|
100
|
+
|
101
|
+
install_directory.rmtree if install_directory.exist?
|
102
|
+
@backup.restore_all
|
103
|
+
ensure
|
104
|
+
@installed = false
|
105
|
+
end
|
106
|
+
|
107
|
+
def extension_source
|
108
|
+
Safari.resource_path.join('SafariDriver.safariextz')
|
109
|
+
end
|
110
|
+
|
111
|
+
def extension_destination
|
112
|
+
install_directory.join('WebDriver.safariextz')
|
113
|
+
end
|
114
|
+
|
115
|
+
def plist_destination
|
116
|
+
install_directory.join('Extensions.plist')
|
117
|
+
end
|
118
|
+
|
119
|
+
def install_directory
|
120
|
+
@install_directory ||= (
|
121
|
+
data_dir = Pathname.new(@data_dir || safari_data_dir)
|
122
|
+
|
123
|
+
unless data_dir.exist? && data_dir.directory?
|
124
|
+
raise Errno::ENOENT, "Safari data directory not found at #{data_dir.to_s}"
|
125
|
+
end
|
126
|
+
|
127
|
+
data_dir.join('Extensions')
|
128
|
+
)
|
129
|
+
end
|
130
|
+
|
131
|
+
def safari_data_dir
|
132
|
+
current = Platform.os
|
133
|
+
|
134
|
+
case current
|
135
|
+
when :macosx
|
136
|
+
Pathname.new(Platform.home).join('Library/Safari')
|
137
|
+
when :windows
|
138
|
+
Pathname.new(ENV['APPDATA']).join('Apple Computer/Safari')
|
139
|
+
else
|
140
|
+
raise Error::WebDriverError, "unsupported platform: #{current}"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
class Backup
|
145
|
+
def initialize
|
146
|
+
@dir = Pathname.new(Dir.mktmpdir('webdriver-safari-backups'))
|
147
|
+
@backups = {}
|
148
|
+
|
149
|
+
FileReaper << @dir.to_s
|
150
|
+
end
|
151
|
+
|
152
|
+
def backup(file)
|
153
|
+
src = file
|
154
|
+
dst = @dir.join(file.basename).to_s
|
155
|
+
|
156
|
+
FileUtils.cp_r src.to_s, dst.to_s
|
157
|
+
@backups[src] = dst
|
158
|
+
end
|
159
|
+
|
160
|
+
def restore_all
|
161
|
+
@backups.each {|src, dst| FileUtils.cp_r dst.to_s, src.to_s }
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
module Safari
|
4
|
+
class Options
|
5
|
+
attr_accessor :port, :data_dir, :skip_extension_installation
|
6
|
+
attr_reader :extensions
|
7
|
+
|
8
|
+
def initialize(opts = {})
|
9
|
+
@extensions = []
|
10
|
+
extract_options(opts)
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_extension(ext)
|
14
|
+
@extensions << verify_safari_extension(ext)
|
15
|
+
end
|
16
|
+
|
17
|
+
def clean_session?
|
18
|
+
!!@clean_session
|
19
|
+
end
|
20
|
+
|
21
|
+
def skip_extension_installation?
|
22
|
+
!!@skip_extension_installation
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_capabilities
|
26
|
+
caps = Remote::Capabilities.safari
|
27
|
+
caps.merge!('safari.options' => as_json)
|
28
|
+
|
29
|
+
caps
|
30
|
+
end
|
31
|
+
|
32
|
+
def as_json
|
33
|
+
{
|
34
|
+
'port' => port,
|
35
|
+
'dataDir' => data_dir,
|
36
|
+
'cleanSession' => clean_session?,
|
37
|
+
'extensions' => extensions_as_json,
|
38
|
+
'skipExtensionInstallation' => skip_extension_installation?
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def extensions_as_json
|
45
|
+
@extensions.map do |path|
|
46
|
+
{'filename' => path.basename, 'contents' => Base64.strict_encode64(path.read) }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def extract_options(opts)
|
51
|
+
@port = Integer(opts[:port] || PortProber.random)
|
52
|
+
@data_dir = opts[:custom_data_dir] || opts[:data_dir]
|
53
|
+
@clean_session = opts[:clean_session]
|
54
|
+
|
55
|
+
Array(opts[:extensions]).each { |ext| add_extension(ext) }
|
56
|
+
|
57
|
+
if opts.key?(:install_extension)
|
58
|
+
@skip_extension_installation = !opts[:install_extension]
|
59
|
+
elsif opts.key?(:skip_extension_installation)
|
60
|
+
@skip_extension_installation = opts[:skip_extension_installation]
|
61
|
+
else
|
62
|
+
@skip_extension_installation = false
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def verify_safari_extension(path)
|
67
|
+
pn = Pathname.new(path)
|
68
|
+
|
69
|
+
unless pn.file? && pn.extname == '.safariextz'
|
70
|
+
raise ArgumentError, "invalid Safari extension path: #{path}"
|
71
|
+
end
|
72
|
+
|
73
|
+
pn
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -2,6 +2,31 @@ module Selenium
|
|
2
2
|
module WebDriver
|
3
3
|
module Support
|
4
4
|
|
5
|
+
#
|
6
|
+
# Subclass and override methods from this class
|
7
|
+
# to implement your own event listener.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
#
|
11
|
+
# class NavigationListener < Selenium::WebDriver::Support::AbstractEventListener
|
12
|
+
# def initialize(log)
|
13
|
+
# @log = log
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# def before_navigate_to(url, driver)
|
17
|
+
# @log.info "navigating to #{url}"
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# def after_navigate_to(url, driver)
|
21
|
+
# @log.info "done navigating to #{url}"
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# listener = NavigationListener.new(logger)
|
26
|
+
# driver = Selenium::WebDriver.for :firefox, :listener => listener
|
27
|
+
#
|
28
|
+
#
|
29
|
+
|
5
30
|
class AbstractEventListener
|
6
31
|
def before_navigate_to(url, driver) end
|
7
32
|
def after_navigate_to(url, driver) end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: selenium-webdriver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 7
|
5
|
-
version: 2.40.0.
|
5
|
+
version: 2.40.0.rc2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jari Bakken
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-02-17 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -217,7 +217,8 @@ files:
|
|
217
217
|
- lib/selenium/webdriver/remote/http/persistent.rb
|
218
218
|
- lib/selenium/webdriver/safari/bridge.rb
|
219
219
|
- lib/selenium/webdriver/safari/browser.rb
|
220
|
-
- lib/selenium/webdriver/safari/
|
220
|
+
- lib/selenium/webdriver/safari/extensions.rb
|
221
|
+
- lib/selenium/webdriver/safari/options.rb
|
221
222
|
- lib/selenium/webdriver/safari/server.rb
|
222
223
|
- lib/selenium/webdriver/safari/resources/client.js
|
223
224
|
- lib/selenium/webdriver/safari/resources/SafariDriver.safariextz
|
@@ -1,121 +0,0 @@
|
|
1
|
-
module Selenium
|
2
|
-
module WebDriver
|
3
|
-
module Safari
|
4
|
-
class Extension
|
5
|
-
|
6
|
-
PLIST = <<-XML
|
7
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
8
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
9
|
-
<plist version="1.0">
|
10
|
-
<dict>
|
11
|
-
<key>Available Updates</key>
|
12
|
-
<dict>
|
13
|
-
<key>Last Update Check Time</key>
|
14
|
-
<real>370125644.75941497</real>
|
15
|
-
<key>Updates List</key>
|
16
|
-
<array/>
|
17
|
-
</dict>
|
18
|
-
<key>Installed Extensions</key>
|
19
|
-
<array>
|
20
|
-
<dict>
|
21
|
-
<key>Added Non-Default Toolbar Items</key>
|
22
|
-
<array/>
|
23
|
-
<key>Archive File Name</key>
|
24
|
-
<string>WebDriver.safariextz</string>
|
25
|
-
<key>Bundle Directory Name</key>
|
26
|
-
<string>WebDriver.safariextension</string>
|
27
|
-
<key>Enabled</key>
|
28
|
-
<true/>
|
29
|
-
<key>Hidden Bars</key>
|
30
|
-
<array/>
|
31
|
-
<key>Removed Default Toolbar Items</key>
|
32
|
-
<array/>
|
33
|
-
</dict>
|
34
|
-
</array>
|
35
|
-
<key>Version</key>
|
36
|
-
<integer>1</integer>
|
37
|
-
</dict>
|
38
|
-
</plist>
|
39
|
-
XML
|
40
|
-
|
41
|
-
def initialize(opts = {})
|
42
|
-
@custom_data_dir = opts[:custom_data_dir]
|
43
|
-
@installed = false
|
44
|
-
end
|
45
|
-
|
46
|
-
def install
|
47
|
-
return if @installed
|
48
|
-
|
49
|
-
if install_directory.exist?
|
50
|
-
backup_directory.rmtree if backup_directory.exist?
|
51
|
-
FileUtils.mv install_directory.to_s, backup_directory.to_s
|
52
|
-
end
|
53
|
-
|
54
|
-
install_directory.mkpath
|
55
|
-
|
56
|
-
extension_destination.rmtree if extension_destination.exist?
|
57
|
-
FileUtils.cp extension_source.to_s, extension_destination.to_s
|
58
|
-
|
59
|
-
plist_destination.open('w') { |io| io << PLIST }
|
60
|
-
|
61
|
-
at_exit { uninstall }
|
62
|
-
@installed = true
|
63
|
-
end
|
64
|
-
|
65
|
-
def uninstall
|
66
|
-
return unless @installed
|
67
|
-
|
68
|
-
install_directory.rmtree if install_directory.exist?
|
69
|
-
|
70
|
-
if backup_directory.exist?
|
71
|
-
FileUtils.mv backup_directory.to_s, install_directory.to_s
|
72
|
-
end
|
73
|
-
ensure
|
74
|
-
@installed = false
|
75
|
-
end
|
76
|
-
|
77
|
-
def extension_source
|
78
|
-
Safari.resource_path.join('SafariDriver.safariextz')
|
79
|
-
end
|
80
|
-
|
81
|
-
def extension_destination
|
82
|
-
install_directory.join('WebDriver.safariextz')
|
83
|
-
end
|
84
|
-
|
85
|
-
def backup_directory
|
86
|
-
Pathname.new("#{install_directory.to_s}.bak")
|
87
|
-
end
|
88
|
-
|
89
|
-
def plist_destination
|
90
|
-
install_directory.join('Extensions.plist')
|
91
|
-
end
|
92
|
-
|
93
|
-
def install_directory
|
94
|
-
@install_directory ||= (
|
95
|
-
data_dir = Pathname.new(@custom_data_dir || safari_data_dir)
|
96
|
-
|
97
|
-
unless data_dir.exist? && data_dir.directory?
|
98
|
-
raise Errno::ENOENT, "Safari data directory not found at #{data_dir.to_s}"
|
99
|
-
end
|
100
|
-
|
101
|
-
data_dir.join('Extensions')
|
102
|
-
)
|
103
|
-
end
|
104
|
-
|
105
|
-
def safari_data_dir
|
106
|
-
current = Platform.os
|
107
|
-
|
108
|
-
case current
|
109
|
-
when :macosx
|
110
|
-
Pathname.new(Platform.home).join('Library/Safari')
|
111
|
-
when :windows
|
112
|
-
Pathname.new(ENV['APPDATA']).join('Apple Computer/Safari')
|
113
|
-
else
|
114
|
-
raise Error::WebDriverError, "unsupported platform: #{current}"
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|