Module: Selenium::WebDriver::ChildProcess::JRubyProcess

Defined in:
lib/selenium/webdriver/child_process.rb

Instance Method Summary collapse

Instance Method Details

#assert_startedObject



195
196
197
# File 'lib/selenium/webdriver/child_process.rb', line 195

def assert_started
  raise Error::WebDriverError, "process not started" unless @process
end

#exit_valueObject



188
189
190
191
192
193
# File 'lib/selenium/webdriver/child_process.rb', line 188

def exit_value
  assert_started
  @process.exitValue
rescue java.lang.IllegalThreadStateException
  nil
end

#killObject Also known as: kill!



176
177
178
179
# File 'lib/selenium/webdriver/child_process.rb', line 176

def kill
  assert_started
  @process.destroy
end

#startObject



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/selenium/webdriver/child_process.rb', line 146

def start
  require 'java'
  pb = java.lang.ProcessBuilder.new(@args)

  env = pb.environment
  ENV.each { |k,v| env.put(k, v) }

  @process = pb.start

  # Firefox 3.6 on Snow Leopard has a lot output on stderr, which makes
  # the launch act funny if we don't do something to the streams

  @process.getErrorStream.close
  @process.getInputStream.close

  # Closing the streams solves that problem, but on other platforms we might
  # need to actually read them.

  # Thread.new do
  #   input, error = 0, 0
  #   loop do
  #     error = @process.getErrorStream.read if error != -1
  #     input = @process.getInputStream.read if input != -1
  #     break if error == -1 && input == -1
  #   end
  # end

  self
end

#waitObject



182
183
184
185
186
# File 'lib/selenium/webdriver/child_process.rb', line 182

def wait
  assert_started
  @process.waitFor
  [nil, @process.exitValue] # no robust way to get pid here
end