ole-qa-framework 3.15.2 → 3.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42d0845744d038c733c59b1f29a621739cd4286f
4
- data.tar.gz: e0e8cca617f90b63dd5a6d62423ebc72694d4766
3
+ metadata.gz: 4e9fa06f5b7abbb5cf40e06832452a6c43601bc5
4
+ data.tar.gz: 449a85fb5a93a20c259407f3cdf4aafc61e0fa53
5
5
  SHA512:
6
- metadata.gz: cf1d41d0c8ab0a45eac7072549c7280f5bad7f40178cdfd7abb9e89d0791518dcccd1796e706b091cd8d47c76b821ab3e06231be31f75a135678c2dad3acdb65
7
- data.tar.gz: f0fcebf75a9ec84a567a789f3db77c261f763ff52c2fdfd77e6df229107f4d053328ca9d982050eb500726aa0a87141f957a42f92a2c935fdab2a6625a8f68c7
6
+ metadata.gz: de5dc1234bf216be9631732e3cf07b53fd0b06bddf84f36ba21a25f427ff02cfd1f938b6ba00081aa39f9b2234caeba6fb1b58b7bb1deb894407651636bda2bb
7
+ data.tar.gz: 7220eabbaaf62b2ba61acc3d695fb24d296606f068c8278ea0a5b9d7cae2ecc2e3b73a1301f3c7b860dbf233de179f4103a88b8508fab14e47d2624ef786c044
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ### v3.16.0 - 2014/06/30
2
+
3
+ * Headless gem sessions now persist across OLE_QA::Framework::Session instances
4
+ * Starting a new session with (:headless? => false) will stop Headless,
5
+ but not destroy the Headless session.
6
+ * Calling #quit on an OLE_QA::Framework::Session instance
7
+ will destroy the Headless session.
8
+ * Starting a new session with a pre-existing Watir Browser instance
9
+ will not start a new session, and will stop Headless if it is running.
10
+ * Session is now in its own classfile
11
+ * Created Headless spec to handle headless testing
12
+ * Removed headless tests from Session spec
13
+
1
14
  ### v3.15.2 - 2014/06/25
2
15
 
3
16
  * Rescue all exceptions in page wait_for_elements
@@ -86,116 +86,6 @@ module OLE_QA
86
86
  attr_reader :explicit_wait, :doc_wait
87
87
  end
88
88
 
89
- # Handle Browser Functions, Headless Session
90
- # Invoke with @ole = Session.new(opts)
91
- # Exit with @ole.quit
92
- #
93
- # Default options loaded from
94
- # config/options.yml
95
- #
96
- class Session
97
-
98
- # OLE Installation Base URL
99
- # (e.g. http://ole.your-site.edu/)
100
- attr_reader :url
101
- # @deprecated Included for backwards compatibility. Unnecessary after 1.0.0 unification (milestone m2-r13245).
102
- alias :fs_url :url
103
- alias :base_url :url
104
- alias :ls_url :url
105
-
106
- # OLE Document Store Installation Base URL
107
- # (e.g. http://docstore.ole.your-site.edu/)
108
- attr_reader :docstore_url
109
- alias :docstore :docstore_url
110
-
111
- # Wait period (in seconds) used by OLE QAF Web Element functions
112
- attr_accessor :explicit_wait
113
-
114
- # The options with which this OLE_QA Framework Session was invoked
115
- attr_reader :options
116
-
117
- # Options hash keys:
118
- # :url => "http://tst.ole.kuali.org/"
119
- # (URL for OLE Installation)
120
- # :docstore_url => 'http://tst.docstore.ole.kuali.org/'
121
- # (URL for OLE DocStore Installation)
122
- # :headless? => true/false
123
- # (Use Headless gem to handle XVFB session)
124
- # :implicit_wait => NN
125
- # (Set Selenium Webdriver's default wait period)
126
- # :explicit_wait => NN
127
- # (Set the wait period used by Watir Webdriver and custom functions)
128
- # :doc_wait => NN
129
- # (Set the wait period for eDoc routing to complete)
130
- # :browser => watir_webdriver
131
- # (Where browser is a Watir WebDriver session)
132
- #
133
- # To configure the default options, edit
134
- # config/options.yml
135
- #
136
- def initialize( options={} )
137
- options_defaults = YAML.load_file(OLE_QA::Framework::load_dir + '/../config/options.yml')
138
- @options = options_defaults.merge(options)
139
-
140
- # Start headless session if requested
141
- if @options[:headless?]
142
- @headless = Headless.new
143
- @headless.start
144
- end
145
-
146
- # Set trailing slash on URLs for consistency if not set.
147
- add_slash = ->(which) { which =~ /\/$/ ? which : which + '/' }
148
-
149
- # Globalize options to accessors
150
- @url = add_slash.call(@options[:url])
151
- @docstore_url = add_slash.call(@options[:docstore_url])
152
- @explicit_wait = @options[:explicit_wait]
153
- @doc_wait = @options[:doc_wait]
154
-
155
- # Pass explicit_wait to a module accessor for use with OLE_QA::Tools
156
- OLE_QA::Framework.instance_variable_set(:@explicit_wait,@options[:explicit_wait])
157
-
158
- # Pass doc_wait to a module accessor for use with OLE_QA::Tools
159
- OLE_QA::Framework.instance_variable_set(:@doc_wait,@options[:doc_wait])
160
-
161
- # Browser Start
162
- if @options.has_key?(:browser) && @options[:browser].class == Watir::Browser
163
- @browser = @options[:browser]
164
- else
165
- @browser = Watir::Browser.new :firefox
166
- @browser.driver.manage.timeouts.implicit_wait = @options[:implicit_wait]
167
- end
168
-
169
- # Set cutomizable default timeout on Watir-Webdriver (v0.6.5+).
170
- Watir.default_timeout = @explicit_wait
171
- end
172
-
173
- # Access Watir-Webdriver's browser session.
174
- def browser
175
- @browser
176
- end
177
-
178
- # Access Watir-Webdriver's Window Handling Method
179
- def windows
180
- @browser.windows
181
- end
182
-
183
- # Open a page via URL. (Defaults to @base_url.)
184
- def open(url = @url)
185
- @browser.goto(url)
186
- end
187
-
188
- # Teardown the OLE QA Framework.
189
- # - Exit the Selenium WebDriver browser session.
190
- # - Exit the Headless (XVFB) session if necessary.
191
- def quit
192
- @browser.quit
193
- if @options[:headless?] then
194
- @headless.destroy
195
- end
196
- end
197
- end
198
-
199
89
  # Define OLE_QA::Framework::Error.
200
90
  class Error < StandardError
201
91
  end
@@ -15,6 +15,6 @@
15
15
  module OLE_QA
16
16
  module Framework
17
17
  # The version number for this project.
18
- VERSION = '3.15.2'
18
+ VERSION = '3.16.0'
19
19
  end
20
20
  end
@@ -0,0 +1,183 @@
1
+ # Copyright 2005-2014 The Kuali Foundation
2
+ #
3
+ # Licensed under the Educational Community License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at:
6
+ #
7
+ # http://www.opensource.org/licenses/ecl2.php
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module OLE_QA::Framework
16
+
17
+ # Handle Browser Functions, Headless Session
18
+ # Invoke with @ole = Session.new(opts)
19
+ # Exit with @ole.quit
20
+ #
21
+ # Default options loaded from
22
+ # config/options.yml
23
+ #
24
+ class Session
25
+
26
+ # Eigenclass setup to lock different instances to the same Headless session.
27
+ class << self
28
+ # Return the current Headless session.
29
+ attr_accessor :headless_session
30
+
31
+ # Is Headless started?
32
+ def is_headless?
33
+ @is_headless
34
+ end
35
+
36
+ # Start a new Headless session.
37
+ def start_headless
38
+ @headless_session ||= Headless.new
39
+ unless self.is_headless? then
40
+ @is_headless = true
41
+ @headless_session.start
42
+ end
43
+ end
44
+
45
+ # Stop the headless session.
46
+ def stop_headless
47
+ if self.is_headless? then
48
+ @headless_session.stop
49
+ @is_headless = false
50
+ else
51
+ raise OLE_QA::Framework::Error,"Headless is not running."
52
+ end
53
+ end
54
+
55
+ # Quit the headless session entirely.
56
+ def quit_headless
57
+ @headless_session.destroy if self.is_headless?
58
+ end
59
+ end
60
+
61
+ @headless_session = nil
62
+ @is_headless = false
63
+
64
+ # OLE Installation Base URL
65
+ # (e.g. http://ole.your-site.edu/)
66
+ attr_reader :url
67
+ # @deprecated Included for backwards compatibility. Unnecessary after 1.0.0 unification (milestone m2-r13245).
68
+ alias :fs_url :url
69
+ alias :base_url :url
70
+ alias :ls_url :url
71
+
72
+ # OLE Document Store Installation Base URL
73
+ # (e.g. http://docstore.ole.your-site.edu/)
74
+ attr_reader :docstore_url
75
+ alias :docstore :docstore_url
76
+
77
+ # Wait period (in seconds) used by OLE QAF Web Element functions
78
+ attr_accessor :explicit_wait
79
+
80
+ # The options with which this OLE_QA Framework Session was invoked
81
+ attr_reader :options
82
+
83
+ # Options hash keys:
84
+ # :url => "http://tst.ole.kuali.org/"
85
+ # (URL for OLE Installation)
86
+ # :docstore_url => 'http://tst.docstore.ole.kuali.org/'
87
+ # (URL for OLE DocStore Installation)
88
+ # :headless? => true/false
89
+ # (Use Headless gem to handle XVFB session)
90
+ # :implicit_wait => NN
91
+ # (Set Selenium Webdriver's default wait period)
92
+ # :explicit_wait => NN
93
+ # (Set the wait period used by Watir Webdriver and custom functions)
94
+ # :doc_wait => NN
95
+ # (Set the wait period for eDoc routing to complete)
96
+ # :browser => watir_webdriver
97
+ # (Where browser is a Watir WebDriver session)
98
+ #
99
+ # To configure the default options, edit
100
+ # config/options.yml
101
+ #
102
+ def initialize( options={} )
103
+ options_defaults = YAML.load_file(OLE_QA::Framework::load_dir + '/../config/options.yml')
104
+ @options = options_defaults.merge(options)
105
+
106
+ # Set local variable if @options[:browser] is given a Watir::Browser session.
107
+ browser_given = @options.has_key?(:browser) && @options[:browser].is_a?(Watir::Browser)
108
+
109
+ # Use Headless if requested.
110
+ if @options[:headless?] && ! browser_given
111
+ self.class.start_headless
112
+ else
113
+ self.class.stop_headless if self.is_headless?
114
+ end
115
+
116
+ # Set trailing slash on URLs for consistency if not set.
117
+ add_slash = ->(which) { which =~ /\/$/ ? which : which + '/' }
118
+
119
+ # Globalize options to accessors
120
+ @url = add_slash.call(@options[:url])
121
+ @docstore_url = add_slash.call(@options[:docstore_url])
122
+ @explicit_wait = @options[:explicit_wait]
123
+ @doc_wait = @options[:doc_wait]
124
+
125
+ # Pass explicit_wait to a module accessor for use with OLE_QA::Tools
126
+ OLE_QA::Framework.instance_variable_set(:@explicit_wait,@options[:explicit_wait])
127
+
128
+ # Pass doc_wait to a module accessor for use with OLE_QA::Tools
129
+ OLE_QA::Framework.instance_variable_set(:@doc_wait,@options[:doc_wait])
130
+
131
+ # Browser Start
132
+ if browser_given
133
+ @browser = @options[:browser]
134
+ else
135
+ @browser = Watir::Browser.new :firefox
136
+ @browser.driver.manage.timeouts.implicit_wait = @options[:implicit_wait]
137
+ end
138
+
139
+ # Set cutomizable default timeout on Watir-Webdriver (v0.6.5+).
140
+ Watir.default_timeout = @explicit_wait
141
+ end
142
+
143
+ # Access the Headless session class-level instance variable.
144
+ def headless_session
145
+ self.class.headless_session
146
+ end
147
+
148
+ # Return whether Headless is running.
149
+ def is_headless?
150
+ self.class.is_headless?
151
+ end
152
+
153
+ # Access Watir-Webdriver's browser session.
154
+ def browser
155
+ @browser
156
+ end
157
+
158
+ # Access Watir-Webdriver's Window Handling Method
159
+ def windows
160
+ @browser.windows
161
+ end
162
+
163
+ # Open a page via URL. (Defaults to @base_url.)
164
+ def open(url = @url)
165
+ @browser.goto(url)
166
+ end
167
+
168
+ # Exit the browser only, stop the Headless (XVFB) session, but don't destroy it entirely.
169
+ def close
170
+ @browser.quit
171
+ end
172
+
173
+ # Teardown the OLE QA Framework.
174
+ # - Exit the Selenium WebDriver browser session.
175
+ # - Exit the Headless (XVFB) session if necessary.
176
+ def quit
177
+ @browser.quit
178
+ if self.is_headless? then
179
+ self.class.quit_headless
180
+ end
181
+ end
182
+ end
183
+ end
@@ -0,0 +1,63 @@
1
+ # Copyright 2005-2014 The Kuali Foundation
2
+ #
3
+ # Licensed under the Educational Community License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at:
6
+ #
7
+ # http://www.opensource.org/licenses/ecl2.php
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'rspec'
16
+ require 'spec_helper'
17
+
18
+ describe 'A Headless session' do
19
+
20
+ before :all do
21
+ @ole = OLE_QA::Framework::Session.new(:headless? => true)
22
+ end
23
+
24
+ after :all do
25
+ @ole.quit
26
+ end
27
+
28
+ it 'should be available in an instance method' do
29
+ expect(@ole.headless_session).to be_an_instance_of(Headless)
30
+ end
31
+
32
+ it 'should be available in a class method' do
33
+ expect(OLE_QA::Framework::Session.headless_session).to eq(@ole.headless_session)
34
+ end
35
+
36
+ it 'should show as started on an instance' do
37
+ expect(@ole.is_headless?).to be_true
38
+ end
39
+
40
+ it 'should show as started on the class' do
41
+ expect(OLE_QA::Framework::Session.is_headless?).to be_true
42
+ end
43
+
44
+ it 'should keep running if a new Headless session is requested' do
45
+ original_session = @ole.headless_session.inspect
46
+ @ole = OLE_QA::Framework::Session.new(:headless? => true)
47
+ expect(original_session).to eq(@ole.headless_session.inspect)
48
+ end
49
+
50
+ it 'should stop if a new non-Headless session is requested' do
51
+ ole = OLE_QA::Framework::Session.new(:headless? => false)
52
+ ole.close
53
+ expect(ole.is_headless?).to be_false
54
+ end
55
+
56
+ it 'will not be used with a pre-existing Watir session' do
57
+ browser = Watir::Browser.new
58
+ ole = OLE_QA::Framework::Session.new(:browser => browser)
59
+ ole.close
60
+ expect(ole.is_headless?).to be_false
61
+ end
62
+
63
+ end
@@ -19,23 +19,19 @@ describe 'An OLE QA Framework Session' do
19
19
 
20
20
  before :all do
21
21
  @ole = OLE_QA::Framework::Session.new(:headless? => false)
22
- @headless_ole = OLE_QA::Framework::Session.new(:headless? => true)
22
+ @browser = Watir::Browser.new :firefox
23
+ @ole_alt = OLE_QA::Framework::Session.new(:browser => @browser)
23
24
  end
24
25
 
25
26
  after :all do
26
27
  @ole.quit unless @ole.nil?
27
- @headless_ole.quit unless @ole.nil?
28
+ @browser.quit unless @browser.nil?
29
+ @ole_alt.quit unless @ole_alt.nil?
28
30
  end
29
31
 
30
32
  context 'should start' do
31
33
  it 'normally' do
32
34
  expect(@ole).to be_an(OLE_QA::Framework::Session)
33
- expect(@ole.options[:headless?]).to be_false
34
- end
35
-
36
- it 'headlessly' do
37
- expect(@headless_ole).to be_an(OLE_QA::Framework::Session)
38
- expect(@headless_ole.options[:headless?]).to be_true
39
35
  end
40
36
 
41
37
  it 'with a URL reader attribute' do
@@ -46,11 +42,8 @@ describe 'An OLE QA Framework Session' do
46
42
  expect(@ole.docstore_url).to be_a(String)
47
43
  end
48
44
 
49
- it 'should accept a predefined Watir-Webdriver session' do
50
- browser = Watir::Browser.new :firefox
51
- ole = OLE_QA::Framework::Session.new(:browser => browser)
52
- expect(ole.browser).to eq(browser)
53
- browser.quit
45
+ it 'with a predefined Watir-Webdriver session' do
46
+ expect(@ole_alt.browser).to eq(@browser)
54
47
  end
55
48
  end
56
49
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ole-qa-framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.15.2
4
+ version: 3.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jain Waldrip
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-25 00:00:00.000000000 Z
11
+ date: 2014-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -135,6 +135,7 @@ files:
135
135
  - lib/ole-qa-framework.rb
136
136
  - lib/ole_qa_framework/COMPATIBILITY.rb
137
137
  - lib/ole_qa_framework/VERSION.rb
138
+ - lib/ole_qa_framework/session.rb
138
139
  - lib/olefs/common/e_doc.rb
139
140
  - lib/olefs/common/lookup.rb
140
141
  - lib/olefs/common/purap_document.rb
@@ -212,6 +213,7 @@ files:
212
213
  - ole-qa-framework.gemspec
213
214
  - spec/common/browser_spec.rb
214
215
  - spec/common/data_object_spec.rb
216
+ - spec/common/headless_spec.rb
215
217
  - spec/common/line_object_spec.rb
216
218
  - spec/common/page_spec.rb
217
219
  - spec/common/session_spec.rb
@@ -250,6 +252,7 @@ summary: Kuali Open Library Environment
250
252
  test_files:
251
253
  - spec/common/browser_spec.rb
252
254
  - spec/common/data_object_spec.rb
255
+ - spec/common/headless_spec.rb
253
256
  - spec/common/line_object_spec.rb
254
257
  - spec/common/page_spec.rb
255
258
  - spec/common/session_spec.rb