webdriver-firefox 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/webdriver-firefox.rb +1 -0
- data/lib/webdriver-firefox/firefox_binary.rb +160 -0
- data/lib/webdriver-firefox/version.rb +1 -1
- metadata +37 -51
data/lib/webdriver-firefox.rb
CHANGED
@@ -0,0 +1,160 @@
|
|
1
|
+
# This file subject to Apache License 2.0; see LICENSE.txt
|
2
|
+
|
3
|
+
module Selenium
|
4
|
+
module WebDriver
|
5
|
+
module Firefox
|
6
|
+
|
7
|
+
# @api private
|
8
|
+
class Binary
|
9
|
+
|
10
|
+
NO_FOCUS_LIBRARY_NAME = "x_ignore_nofocus.so"
|
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
|
39
|
+
|
40
|
+
def quit
|
41
|
+
return unless @process
|
42
|
+
@process.poll_for_exit QUIT_TIMEOUT
|
43
|
+
rescue ChildProcess::TimeoutError
|
44
|
+
# ok, force quit
|
45
|
+
@process.stop QUIT_TIMEOUT
|
46
|
+
end
|
47
|
+
|
48
|
+
def wait
|
49
|
+
@process.poll_for_exit(WAIT_TIMEOUT) if @process
|
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
|
92
|
+
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
|
+
end # Binary
|
158
|
+
end # Firefox
|
159
|
+
end # WebDriver
|
160
|
+
end # Selenium
|
metadata
CHANGED
@@ -1,81 +1,67 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: webdriver-firefox
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 6
|
9
|
-
version: 0.0.6
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.7
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Solano Labs
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-11-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: selenium-webdriver
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 0
|
30
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
31
22
|
type: :runtime
|
32
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
33
30
|
description: Lockless Support for Webdriver and Firefox
|
34
|
-
email:
|
31
|
+
email:
|
35
32
|
- info@solanolabs.com
|
36
33
|
executables: []
|
37
|
-
|
38
34
|
extensions: []
|
39
|
-
|
40
35
|
extra_rdoc_files: []
|
41
|
-
|
42
|
-
files:
|
36
|
+
files:
|
43
37
|
- lib/webdriver-firefox.rb
|
38
|
+
- lib/webdriver-firefox/firefox_binary.rb
|
44
39
|
- lib/webdriver-firefox/no_lock_driver.rb
|
45
40
|
- lib/webdriver-firefox/no_lock_firefox_bridge.rb
|
46
41
|
- lib/webdriver-firefox/port_pool.rb
|
47
42
|
- lib/webdriver-firefox/version.rb
|
48
|
-
|
49
|
-
homepage: https://github.com/solanolabs/webdriver-firefox
|
43
|
+
homepage: http://www.solanolabs.com/
|
50
44
|
licenses: []
|
51
|
-
|
52
45
|
post_install_message:
|
53
46
|
rdoc_options: []
|
54
|
-
|
55
|
-
require_paths:
|
47
|
+
require_paths:
|
56
48
|
- lib
|
57
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
50
|
none: false
|
59
|
-
requirements:
|
60
|
-
- -
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
|
63
|
-
|
64
|
-
version: "0"
|
65
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
56
|
none: false
|
67
|
-
requirements:
|
68
|
-
- -
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
|
71
|
-
- 0
|
72
|
-
version: "0"
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
73
61
|
requirements: []
|
74
|
-
|
75
62
|
rubyforge_project: tddium
|
76
|
-
rubygems_version: 1.
|
63
|
+
rubygems_version: 1.8.23
|
77
64
|
signing_key:
|
78
65
|
specification_version: 3
|
79
|
-
summary: WebdriverFirefox
|
66
|
+
summary: WebdriverFirefox
|
80
67
|
test_files: []
|
81
|
-
|