webdriver-firefox 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
@@ -6,154 +6,20 @@ module Selenium
|
|
6
6
|
|
7
7
|
# @api private
|
8
8
|
class Binary
|
9
|
-
|
10
|
-
|
11
|
-
NO_FOCUS_LIBRARIES = [
|
12
|
-
["#{WebDriver.root}/selenium/webdriver/firefox/native/linux/amd64/#{NO_FOCUS_LIBRARY_NAME}", "amd64/#{NO_FOCUS_LIBRARY_NAME}"],
|
13
|
-
["#{WebDriver.root}/selenium/webdriver/firefox/native/linux/x86/#{NO_FOCUS_LIBRARY_NAME}", "x86/#{NO_FOCUS_LIBRARY_NAME}"],
|
14
|
-
]
|
15
|
-
|
16
|
-
WAIT_TIMEOUT = 180
|
17
|
-
QUIT_TIMEOUT = 10
|
18
|
-
|
19
|
-
def start_with(profile, profile_path, *args)
|
20
|
-
if Platform.cygwin?
|
21
|
-
profile_path = Platform.cygwin_path(profile_path, :windows => true)
|
22
|
-
elsif Platform.windows?
|
23
|
-
profile_path = profile_path.gsub("/", "\\")
|
24
|
-
end
|
25
|
-
|
26
|
-
ENV['XRE_CONSOLE_LOG'] = profile.log_file if profile.log_file
|
27
|
-
ENV['XRE_PROFILE_PATH'] = profile_path
|
28
|
-
ENV['MOZ_NO_REMOTE'] = '1' # able to launch multiple instances
|
29
|
-
ENV['MOZ_CRASHREPORTER_DISABLE'] = '1' # disable breakpad
|
30
|
-
ENV['NO_EM_RESTART'] = '1' # prevent the binary from detaching from the console
|
31
|
-
|
32
|
-
if Platform.linux? && (profile.native_events? || profile.load_no_focus_lib?)
|
33
|
-
modify_link_library_path profile_path
|
34
|
-
end
|
35
|
-
|
36
|
-
execute(*args)
|
37
|
-
cope_with_mac_strangeness(args) if Platform.mac?
|
38
|
-
end
|
9
|
+
LONG_WAIT_TIMEOUT = 180
|
10
|
+
LONG_QUIT_TIMEOUT = 10
|
39
11
|
|
40
12
|
def quit
|
41
13
|
return unless @process
|
42
|
-
@process.poll_for_exit
|
14
|
+
@process.poll_for_exit LONG_QUIT_TIMEOUT
|
43
15
|
rescue ChildProcess::TimeoutError
|
44
16
|
# ok, force quit
|
45
|
-
@process.stop
|
17
|
+
@process.stop LONG_QUIT_TIMEOUT
|
46
18
|
end
|
47
19
|
|
48
20
|
def wait
|
49
|
-
@process.poll_for_exit(
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
def execute(*extra_args)
|
55
|
-
args = [self.class.path, "-no-remote"] + extra_args
|
56
|
-
@process = ChildProcess.build(*args)
|
57
|
-
@process.io.inherit! if $DEBUG
|
58
|
-
@process.start
|
59
|
-
end
|
60
|
-
|
61
|
-
def cope_with_mac_strangeness(args)
|
62
|
-
sleep 0.3
|
63
|
-
|
64
|
-
if @process.crashed?
|
65
|
-
# ok, trying a restart
|
66
|
-
sleep 7
|
67
|
-
execute(*args)
|
68
|
-
end
|
69
|
-
|
70
|
-
# ensure we're ok
|
71
|
-
sleep 0.3
|
72
|
-
if @process.crashed?
|
73
|
-
raise Error::WebDriverError, "unable to start Firefox cleanly, args: #{args.inspect}"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def modify_link_library_path(profile_path)
|
78
|
-
paths = []
|
79
|
-
|
80
|
-
NO_FOCUS_LIBRARIES.each do |from, to|
|
81
|
-
dest = File.join(profile_path, to)
|
82
|
-
FileUtils.mkdir_p File.dirname(dest)
|
83
|
-
FileUtils.cp from, dest
|
84
|
-
|
85
|
-
paths << File.expand_path(File.dirname(dest))
|
86
|
-
end
|
87
|
-
|
88
|
-
paths += ENV['LD_LIBRARY_PATH'].to_s.split(File::PATH_SEPARATOR)
|
89
|
-
|
90
|
-
ENV['LD_LIBRARY_PATH'] = paths.uniq.join(File::PATH_SEPARATOR)
|
91
|
-
ENV['LD_PRELOAD'] = NO_FOCUS_LIBRARY_NAME
|
21
|
+
@process.poll_for_exit(LONG_WAIT_TIMEOUT) if @process
|
92
22
|
end
|
93
|
-
|
94
|
-
class << self
|
95
|
-
|
96
|
-
#
|
97
|
-
# @api private
|
98
|
-
#
|
99
|
-
# @see Firefox.path=
|
100
|
-
#
|
101
|
-
|
102
|
-
def path=(path)
|
103
|
-
Platform.assert_executable(path)
|
104
|
-
@path = path
|
105
|
-
end
|
106
|
-
|
107
|
-
def path
|
108
|
-
@path ||= case Platform.os
|
109
|
-
when :macosx
|
110
|
-
macosx_path
|
111
|
-
when :windows
|
112
|
-
windows_path
|
113
|
-
when :linux, :unix
|
114
|
-
Platform.find_binary("firefox3", "firefox2", "firefox") || "/usr/bin/firefox"
|
115
|
-
else
|
116
|
-
raise Error::WebDriverError, "unknown platform: #{Platform.os}"
|
117
|
-
end
|
118
|
-
|
119
|
-
@path = Platform.cygwin_path(@path) if Platform.cygwin?
|
120
|
-
|
121
|
-
unless File.file?(@path.to_s)
|
122
|
-
raise Error::WebDriverError, "Could not find Firefox binary (os=#{Platform.os}). Make sure Firefox is installed or set the path manually with #{self}.path="
|
123
|
-
end
|
124
|
-
|
125
|
-
@path
|
126
|
-
end
|
127
|
-
|
128
|
-
private
|
129
|
-
|
130
|
-
def windows_path
|
131
|
-
windows_registry_path || Platform.find_in_program_files("\\Mozilla Firefox\\firefox.exe") || Platform.find_binary("firefox")
|
132
|
-
end
|
133
|
-
|
134
|
-
def macosx_path
|
135
|
-
path = "/Applications/Firefox.app/Contents/MacOS/firefox-bin"
|
136
|
-
path = Platform.find_binary("firefox-bin") unless File.exist?(path)
|
137
|
-
|
138
|
-
path
|
139
|
-
end
|
140
|
-
|
141
|
-
def windows_registry_path
|
142
|
-
require 'win32/registry'
|
143
|
-
|
144
|
-
lm = Win32::Registry::HKEY_LOCAL_MACHINE
|
145
|
-
lm.open("SOFTWARE\\Mozilla\\Mozilla Firefox") do |reg|
|
146
|
-
main = lm.open("SOFTWARE\\Mozilla\\Mozilla Firefox\\#{reg.keys[0]}\\Main")
|
147
|
-
if entry = main.find { |key, type, data| key =~ /pathtoexe/i }
|
148
|
-
return entry.last
|
149
|
-
end
|
150
|
-
end
|
151
|
-
rescue LoadError
|
152
|
-
# older JRuby or IronRuby does not have win32/registry
|
153
|
-
rescue Win32::Registry::Error
|
154
|
-
end
|
155
|
-
end # class << self
|
156
|
-
|
157
23
|
end # Binary
|
158
24
|
end # Firefox
|
159
25
|
end # WebDriver
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webdriver-firefox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: selenium-webdriver
|