Class: OLE_QA::Framework::Session
- Inherits:
-
Object
- Object
- OLE_QA::Framework::Session
- Defined in:
- lib/ole_qa_framework/session.rb
Overview
Handle Browser Functions, Headless Session
Invoke with @ole = Session.new(opts)
Exit with @ole.quit
Default options loaded from
config/.yml
Class Attribute Summary collapse
-
.headless_session ⇒ Object
Return the current Headless session.
Instance Attribute Summary collapse
-
#docstore_url ⇒ Object
(also: #docstore)
readonly
OLE Document Store Installation Base URL (e.g. docstore.ole.your-site.edu/).
-
#explicit_wait ⇒ Object
Wait period (in seconds) used by OLE QAF Web Element functions.
-
#options ⇒ Object
readonly
The options with which this OLE_QA Framework Session was invoked.
-
#url ⇒ Object
(also: #fs_url, #base_url, #ls_url)
readonly
OLE Installation Base URL (e.g. ole.your-site.edu/).
Class Method Summary collapse
-
.is_headless? ⇒ Boolean
Is Headless started?.
-
.quit_headless ⇒ Object
Quit the headless session entirely.
-
.start_headless ⇒ Object
Start a new Headless session.
-
.stop_headless ⇒ Object
Stop the headless session.
Instance Method Summary collapse
-
#browser ⇒ Object
Access Watir-Webdriver’s browser session.
-
#close ⇒ Object
Exit the browser only, stop the Headless (XVFB) session, but don’t destroy it entirely.
-
#headless_session ⇒ Object
Access the Headless session class-level instance variable.
-
#initialize(options = {}) ⇒ Session
constructor
Options hash keys: :url => “tst.ole.kuali.org/” (URL for OLE Installation) :docstore_url => ‘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).
-
#is_headless? ⇒ Boolean
Return whether Headless is running.
-
#open(url = @url) ⇒ Object
Open a page via URL.
-
#quit ⇒ Object
Teardown the OLE QA Framework.
-
#windows ⇒ Object
Access Watir-Webdriver’s Window Handling Method.
Constructor Details
#initialize(options = {}) ⇒ Session
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/.yml
104 105 106 107 108 109 110 111 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 144 145 146 |
# File 'lib/ole_qa_framework/session.rb', line 104 def initialize( ={} ) = YAML.load_file(OLE_QA::Framework::load_dir + '/../config/options.yml') @options = .merge() # 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 |
Class Attribute Details
.headless_session ⇒ Object
Return the current Headless session.
29 30 31 |
# File 'lib/ole_qa_framework/session.rb', line 29 def headless_session @headless_session end |
Instance Attribute Details
#docstore_url ⇒ Object (readonly) Also known as: docstore
OLE Document Store Installation Base URL
(e.g. http://docstore.ole.your-site.edu/)
74 75 76 |
# File 'lib/ole_qa_framework/session.rb', line 74 def docstore_url @docstore_url end |
#explicit_wait ⇒ Object
Wait period (in seconds) used by OLE QAF Web Element functions
78 79 80 |
# File 'lib/ole_qa_framework/session.rb', line 78 def explicit_wait @explicit_wait end |
#options ⇒ Object (readonly)
The options with which this OLE_QA Framework Session was invoked
81 82 83 |
# File 'lib/ole_qa_framework/session.rb', line 81 def @options end |
#url ⇒ Object (readonly) Also known as: fs_url, base_url, ls_url
OLE Installation Base URL
(e.g. http://ole.your-site.edu/)
66 67 68 |
# File 'lib/ole_qa_framework/session.rb', line 66 def url @url end |
Class Method Details
.is_headless? ⇒ Boolean
Is Headless started?
32 33 34 |
# File 'lib/ole_qa_framework/session.rb', line 32 def is_headless? @is_headless end |
.quit_headless ⇒ Object
Quit the headless session entirely.
56 57 58 |
# File 'lib/ole_qa_framework/session.rb', line 56 def quit_headless @headless_session.destroy if self.is_headless? end |
.start_headless ⇒ Object
Start a new Headless session.
37 38 39 40 41 42 43 |
# 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 |
Instance Method Details
#browser ⇒ Object
Access Watir-Webdriver’s browser session.
159 160 161 |
# File 'lib/ole_qa_framework/session.rb', line 159 def browser @browser end |
#close ⇒ Object
Exit the browser only, stop the Headless (XVFB) session, but don’t destroy it entirely.
174 175 176 |
# File 'lib/ole_qa_framework/session.rb', line 174 def close @browser.quit end |
#headless_session ⇒ Object
Access the Headless session class-level instance variable.
149 150 151 |
# File 'lib/ole_qa_framework/session.rb', line 149 def headless_session self.class.headless_session end |
#is_headless? ⇒ Boolean
Return whether Headless is running.
154 155 156 |
# File 'lib/ole_qa_framework/session.rb', line 154 def is_headless? self.class.is_headless? end |
#open(url = @url) ⇒ Object
Open a page via URL. (Defaults to @base_url.)
169 170 171 |
# File 'lib/ole_qa_framework/session.rb', line 169 def open(url = @url) @browser.goto(url) end |
#quit ⇒ Object
Teardown the OLE QA Framework.
-
Exit the Selenium WebDriver browser session.
-
Exit the Headless (XVFB) session if necessary.
181 182 183 184 185 186 |
# 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 ⇒ Object
Access Watir-Webdriver’s Window Handling Method
164 165 166 |
# File 'lib/ole_qa_framework/session.rb', line 164 def windows @browser.windows end |