class OLE_QA::Framework::Session

Handle Browser Functions, Headless Session

Invoke with @ole = Session.new(opts)
Exit with @ole.quit

Default options loaded from

config/options.yml

Attributes

headless_session[RW]

Return the current Headless session.

base_url[R]

OLE Installation Base URL

(e.g. http://ole.your-site.edu/)
docstore[R]

OLE Document Store Installation Base URL

(e.g. http://docstore.ole.your-site.edu/)
docstore_url[R]

OLE Document Store Installation Base URL

(e.g. http://docstore.ole.your-site.edu/)
explicit_wait[RW]

Wait period (in seconds) used by OLE QAF Web Element functions

fs_url[R]

OLE Installation Base URL

(e.g. http://ole.your-site.edu/)
ls_url[R]

OLE Installation Base URL

(e.g. http://ole.your-site.edu/)
options[R]

The options with which this OLE_QA Framework Session was invoked

url[R]

OLE Installation Base URL

(e.g. http://ole.your-site.edu/)

Public Class Methods

is_headless?() click to toggle source

Is Headless started?

# File lib/ole_qa_framework/session.rb, line 32
def is_headless?
  @is_headless
end
new( options={} ) click to toggle source

Options hash keys:

:url => "http://tst.ole.kuali.org/"
  (URL for OLE Installation)
:docstore_url => 'http://tst.docstore.ole.kuali.org/'
  (URL for OLE DocStore Installation)
:headless? => true/false
  (Use Headless gem to handle XVFB session)
:implicit_wait => NN
  (Set Selenium Webdriver's default wait period)
:explicit_wait => NN
  (Set the wait period used by Watir Webdriver and custom functions)
:doc_wait => NN
  (Set the wait period for eDoc routing to complete)
:browser => watir_webdriver
  (Where browser is a Watir WebDriver session)
:profile => profile
  (Where profile is a Selenium::WebDriver::Firefox::Profile instance)

To configure the default options, edit

config/options.yml
# File lib/ole_qa_framework/session.rb, line 104
def initialize( options={} )
  options_defaults = YAML.load_file(OLE_QA::Framework::load_dir + '/../config/options.yml')
  @options = options_defaults.merge(options)

  # Set local variable if @options[:browser] is given a Watir::Browser session.
  browser_given = @options.has_key?(:browser) && @options[:browser].is_a?(Watir::Browser)

  # Use Headless if requested.
  if @options[:headless?] && ! browser_given
    self.class.start_headless
  else
    self.class.stop_headless if self.is_headless?
  end

  # Set trailing slash on URLs for consistency if not set.
  add_slash = ->(which) { which =~ /\/$/ ? which : which + '/' }

  # Globalize options to accessors
  @url            = add_slash.call(@options[:url])
  @docstore_url   = add_slash.call(@options[:docstore_url])
  @explicit_wait  = @options[:explicit_wait]
  @doc_wait       = @options[:doc_wait]

  # Pass explicit_wait to a module accessor for use with OLE_QA::Tools
  OLE_QA::Framework.instance_variable_set(:@explicit_wait,@options[:explicit_wait])

  # Pass doc_wait to a module accessor for use with OLE_QA::Tools
  OLE_QA::Framework.instance_variable_set(:@doc_wait,@options[:doc_wait])

  # Browser Start
  if browser_given
    @browser = @options[:browser]
  else
    # Use a Firefox profile, if given.
    @options.has_key?(:profile) ?
        @browser = Watir::Browser.new(:firefox, :profile => @options[:profile]) :
        @browser = Watir::Browser.new(:firefox)
    @browser.driver.manage.timeouts.implicit_wait = @options[:implicit_wait]
  end

  # Set cutomizable default timeout on Watir-Webdriver (v0.6.5+).
  Watir.default_timeout = @explicit_wait
end
quit_headless() click to toggle source

Quit the headless session entirely.

# File lib/ole_qa_framework/session.rb, line 56
def quit_headless
  @headless_session.destroy if self.is_headless?
end
start_headless() click to toggle source

Start a new Headless session.

# File lib/ole_qa_framework/session.rb, line 37
def start_headless
  @headless_session ||= Headless.new
  unless self.is_headless? then
    @is_headless      = true
    @headless_session.start
  end
end
stop_headless() click to toggle source

Stop the headless session.

# File lib/ole_qa_framework/session.rb, line 46
def stop_headless
  if self.is_headless? then
    @headless_session.stop
    @is_headless = false
  else
    raise OLE_QA::Framework::Error,"Headless is not running."
  end
end

Public Instance Methods

browser() click to toggle source

Access Watir-Webdriver’s browser session.

# File lib/ole_qa_framework/session.rb, line 159
def browser
  @browser
end
close() click to toggle source

Exit the browser only, stop the Headless (XVFB) session, but don’t destroy it entirely.

# File lib/ole_qa_framework/session.rb, line 174
def close
  @browser.quit
end
headless_session() click to toggle source

Access the Headless session class-level instance variable.

# File lib/ole_qa_framework/session.rb, line 149
def headless_session
  self.class.headless_session
end
is_headless?() click to toggle source

Return whether Headless is running.

# File lib/ole_qa_framework/session.rb, line 154
def is_headless?
  self.class.is_headless?
end
open(url = @url) click to toggle source

Open a page via URL. (Defaults to @base_url.)

# File lib/ole_qa_framework/session.rb, line 169
def open(url = @url)
  @browser.goto(url)
end
quit() click to toggle source

Teardown the OLE QA Framework.

  • Exit the Selenium WebDriver browser session.

  • Exit the Headless (XVFB) session if necessary.

# File lib/ole_qa_framework/session.rb, line 181
def quit
  @browser.quit
  if self.is_headless? then
    self.class.quit_headless
  end
end
windows() click to toggle source

Access Watir-Webdriver’s Window Handling Method

# File lib/ole_qa_framework/session.rb, line 164
def windows
  @browser.windows
end