Module: SaucelabsAdapter::JsunitSeleniumSupport

Includes:
Utilities
Defined in:
lib/saucelabs_adapter/jsunit_selenium_support.rb

Instance Method Summary collapse

Methods included from Utilities

#debug, #diagnostics_prefix, #find_unused_port, #kill_mongrel_if_needed, #raise_with_message, #say, #setup_tunnel, #start_mongrel, #teardown_tunnel

Instance Method Details

#requiresObject



5
6
7
8
9
# File 'lib/saucelabs_adapter/jsunit_selenium_support.rb', line 5

def requires
  require 'saucelabs_adapter/run_utils'
  require "selenium/client"
  require 'lsof'
end

#run_jsunit_test(jsunit_params, options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/saucelabs_adapter/jsunit_selenium_support.rb', line 27

def run_jsunit_test(jsunit_params, options = {})
  if $:.detect{ |x| x =~ /Selenium/}
    raise_with_message 'Selenium gem should not be in path! (deprecated in favor of selenium-client, which we require)'
  end

  default_jsunit_params = {
    :testPage => "/jsunit/javascripts/test-pages/suite.html",
    :autorun => "true",
    :setupPageTimeout => "60",
    :pageLoadTimeout => "60",
    :suppressCacheBuster => (@selenium_config.selenium_server_address == 'saucelabs.com').to_s
  }
  jsunit_params = default_jsunit_params.merge(jsunit_params)

  test_url = "/jsunit/javascripts/jsunit/jsunit/testRunner.html?" + jsunit_params.map { |k,v| "#{k}=#{v}" }.join("&")
  if @selenium_config.jsunit_polling_interval_seconds
    options = {:polling_interval => @selenium_config.jsunit_polling_interval_seconds}.merge(options)
  end
  run_suite(@selenium_driver, test_url, options)
end

#setup_jsunit_selenium(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/saucelabs_adapter/jsunit_selenium_support.rb', line 11

def setup_jsunit_selenium(options = {})
  @diagnostics_prefix = '[JsunitSeleniumSupport]'
  requires
  @selenium_config = SeleniumConfig.new(ENV['SELENIUM_ENV'])
  start_app_server(options)
  @selenium_driver = @selenium_config.create_driver(options)
  debug "calling @selenium_driver.start"
  @selenium_driver.start_new_browser_session :trustAllSSLCertificates => false
  debug "@selenium_driver.start done"
end

#teardown_jsunit_seleniumObject



22
23
24
25
# File 'lib/saucelabs_adapter/jsunit_selenium_support.rb', line 22

def teardown_jsunit_selenium
  @selenium_driver.stop
  stop_app_server
end