Module: OLE_QA::Framework::Helpers
- Included in:
- Common_Object
- Defined in:
- lib/module/qa_helpers.rb
Overview
Copyright 2005-2014 The Kuali Foundation
Licensed under the Educational Community License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at:
http://www.opensource.org/licenses/ecl2.php
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Instance Method Summary collapse
-
#browser ⇒ Object
(also: #b)
Handle frame selection in the browser via aliasing the @browser session passed to a page or data object.
-
#load_yml(subdir, filename) ⇒ Object
(also: #load_yaml)
Load a YML file.
-
#set_element(name, force = false) ⇒ Object
(also: #element)
Set an element definition on a page or data object.
-
#set_function(name, force = false, &block) ⇒ Object
(also: #function)
Set a function definition on a page or data object.
Instance Method Details
#browser ⇒ Object Also known as: b
Handle frame selection in the browser via aliasing the @browser session passed to a page or data object.
-
If the page or data object is inherited by any kind of OLE e-Doc, all elements will be encapsulated within a frame with an ID of ‘iframeportlet’.
-
If the page is a main menu page or a lookup page, the frame may not be present.
20 21 22 23 24 25 26 27 28 |
# File 'lib/module/qa_helpers.rb', line 20 def browser if @ole.browser.iframe(:class => 'fancybox-iframe').present? @ole.browser.iframe(:class => 'fancybox-iframe') elsif @ole.browser.iframe(:id => 'iframeportlet').present? @ole.browser.iframe(:id => 'iframeportlet') else @ole.browser end end |
#load_yml(subdir, filename) ⇒ Object Also known as: load_yaml
Load a YML file.
140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/module/qa_helpers.rb', line 140 def load_yml(subdir, filename) basedir = OLE_QA::Framework::load_dir file_path = basedir + '/' + subdir + filename if File.exists?(file_path) then yaml_file = File.open(file_path, 'r') yaml = YAML.load(yaml_file) yaml_file.close yaml else raise StandardError, "File does not exist. (#{basedir + subdir + filename})" end end |
#set_element(name, force = false) ⇒ Object Also known as: element
This method can also be used to add an element to an existing page object instance. The code block passed to the method will need to explicitly name the class instance in order to access the browser method.
In some cases in OLE, text_field elements are coded as <input> elements. If Watir-Webdriver returns an error in a case like this, affixing .to_subtype should make the #set method available.
Set an element definition on a page or data object.
-
An element created with this method becomes an accessor attribute associated with an instance variable on the page or data object on which it is created.
95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/module/qa_helpers.rb', line 95 def set_element(name, force = false) raise StandardError, "Name must be a symbol. Given: #{name} (#{name.class})" unless name.instance_of?(Symbol) eigenclass = class << self; self end raise StandardError, "Element is already defined. (Use the 'force = true' option to suppress this error.)" if eigenclass.instance_methods.include?(name) && ! force eigenclass.class_eval do define_method name.to_s do yield self end end @elements << name unless force end |
#set_function(name, force = false, &block) ⇒ Object Also known as: function
Invoking a function without passing the expected parameter/s may not return an appropriate error message.
Set a function definition on a page or data object.
-
A function created with this method becomes an accessor attribute associated with an instance variable on the page or data object on which it is created.
124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/module/qa_helpers.rb', line 124 def set_function(name, force = false, &block) raise StandardError, "Name must be a symbol. Given: #{name} (#{name.class})" unless name.instance_of?(Symbol) eigenclass = class << self; self end raise StandardError, "Function is already defined. (Use the 'force = true' option to suppress this error.)" if eigenclass.instance_methods.include?(name) && ! force eigenclass.class_eval do define_method name.to_s do |*arg| yield *arg end end @functions << name unless force end |