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


124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/ole-qa-framework.rb', line 124

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



102
103
104
# File 'lib/ole-qa-framework.rb', line 102

def explicit_wait
  @explicit_wait
end

#optionsObject (readonly)

The options with which this OLE_QA Framework Session was invoked



105
106
107
# File 'lib/ole-qa-framework.rb', line 105

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)


95
96
97
# File 'lib/ole-qa-framework.rb', line 95

def url
  @url
end

Instance Method Details

#browserObject

Access Watir-Webdriver’s browser session.



158
159
160
# File 'lib/ole-qa-framework.rb', line 158

def browser
  @browser
end

#open(url = @url) ⇒ Object

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



168
169
170
# File 'lib/ole-qa-framework.rb', line 168

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.



175
176
177
178
179
180
# File 'lib/ole-qa-framework.rb', line 175

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

#windowsObject

Access Watir-Webdriver’s Window Handling Method



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

def windows
  @browser.windows
end