Class: OLE_QA::Framework::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/ole-qa-framework.rb

Overview

Handle Browser Functions, Headless Session

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

Default options loaded from

lib/config/default_options.yml

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Session

Options hash keys:

:url => "http://tst.ole.kuali.org/"
  (URL for OLE 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 custom wait functions)
:doc_wait => NN
  (Set the wait period for eDoc routing to complete)
:browser => selenium_webdriver
  (Where browser is a Selenium WebDriver session)

To configure the default options, edit

lib/config/default_options.yml


112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/ole-qa-framework.rb', line 112

def initialize( options={} )
  yaml_configuration = File.open(OLE_QA::Framework::load_dir + '/config/default_options.yml', 'r')
  options_defaults = YAML.load(yaml_configuration)
  yaml_configuration.close
  @options = options_defaults.merge(options)

  # Start headless session if requested
  if @options[:headless?]
    @headless = Headless.new
    @headless.start
  end

  # Globalize options to accessors
  @url = @options[: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 @options.has_key?(:browser) && @options[:browser].class == Watir::Browser
    @browser = @options[:browser]
  else
    @browser = Watir::Browser.new :firefox
    @browser.driver.manage.timeouts.implicit_wait = @options[:implicit_wait]
  end

end

Instance Attribute Details

#explicit_waitObject

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



90
91
92
# File 'lib/ole-qa-framework.rb', line 90

def explicit_wait
  @explicit_wait
end

#optionsObject (readonly)

The options with which this OLE_QA Framework Session was invoked



93
94
95
# File 'lib/ole-qa-framework.rb', line 93

def options
  @options
end

#urlObject (readonly) Also known as: fs_url, base_url, ls_url

OLE Installation Base URL

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


83
84
85
# File 'lib/ole-qa-framework.rb', line 83

def url
  @url
end

Instance Method Details

#browserObject

Access Watir-Webdriver’s browser session.



146
147
148
# File 'lib/ole-qa-framework.rb', line 146

def browser
  @browser
end

#open(url = @url) ⇒ Object

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



156
157
158
# File 'lib/ole-qa-framework.rb', line 156

def open(url = @url)
  @browser.goto(url)
end

#quitObject

Teardown the OLE QA Framework.

  • Exit the Selenium WebDriver browser session.

  • Exit the Headless (XVFB) session if necessary.



163
164
165
166
167
168
# File 'lib/ole-qa-framework.rb', line 163

def quit
  @browser.quit
  if @options[:headless?] then
    @headless.destroy
  end
end

#windowsObject

Access Watir-Webdriver’s Window Handling Method



151
152
153
# File 'lib/ole-qa-framework.rb', line 151

def windows
  @browser.windows
end