ole-qa-framework 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/CHANGELOG.md +882 -0
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +45 -0
  4. data/LICENSE.md +14 -0
  5. data/README.md +17 -0
  6. data/Rakefile.rb +25 -0
  7. data/examples/README.md +57 -0
  8. data/examples/create_bib_record.rb +64 -0
  9. data/examples/create_requisition.rb +96 -0
  10. data/examples/purap_workflow_test.rb +185 -0
  11. data/lib/common/common_object.rb +57 -0
  12. data/lib/common/data_object.rb +21 -0
  13. data/lib/common/line_object.rb +44 -0
  14. data/lib/common/page.rb +72 -0
  15. data/lib/common/subline_object.rb +47 -0
  16. data/lib/config/default_options.yml +7 -0
  17. data/lib/docstore/docstore.rb +13 -0
  18. data/lib/module/qa_data_helpers.rb +17 -0
  19. data/lib/module/qa_helpers.rb +153 -0
  20. data/lib/module/qa_page_helpers.rb +33 -0
  21. data/lib/ole-qa-framework.rb +178 -0
  22. data/lib/ole_qa_framework/COMPATIBILITY.rb +20 -0
  23. data/lib/ole_qa_framework/VERSION.rb +20 -0
  24. data/lib/olefs/common/e_doc.rb +79 -0
  25. data/lib/olefs/common/line_object.rb +39 -0
  26. data/lib/olefs/common/lookup.rb +30 -0
  27. data/lib/olefs/common/purap_document.rb +73 -0
  28. data/lib/olefs/objects/line_item.rb +105 -0
  29. data/lib/olefs/objects/new_line_item.rb +44 -0
  30. data/lib/olefs/objects/new_preq_line_item.rb +43 -0
  31. data/lib/olefs/objects/new_receiving_line.rb +42 -0
  32. data/lib/olefs/objects/preq_line_item.rb +68 -0
  33. data/lib/olefs/objects/receiving_line.rb +88 -0
  34. data/lib/olefs/pages/building_lookup.rb +36 -0
  35. data/lib/olefs/pages/main_menu.rb +23 -0
  36. data/lib/olefs/pages/payment_request.rb +67 -0
  37. data/lib/olefs/pages/payment_request_creation.rb +44 -0
  38. data/lib/olefs/pages/purchase_order.rb +68 -0
  39. data/lib/olefs/pages/receiving_document.rb +49 -0
  40. data/lib/olefs/pages/requisition.rb +61 -0
  41. data/lib/olefs/pages/vendor_lookup.rb +40 -0
  42. data/lib/olefs/subobjects/accounting_line.rb +46 -0
  43. data/lib/olefs/subobjects/copies_line.rb +32 -0
  44. data/lib/olefs/subobjects/exception_notes_line.rb +26 -0
  45. data/lib/olefs/subobjects/invoice_notes_line.rb +25 -0
  46. data/lib/olefs/subobjects/new_accounting_line.rb +43 -0
  47. data/lib/olefs/subobjects/new_copies_line.rb +37 -0
  48. data/lib/olefs/subobjects/new_exception_notes_line.rb +30 -0
  49. data/lib/olefs/subobjects/new_invoice_notes_line.rb +35 -0
  50. data/lib/olefs/subobjects/new_notes_line.rb +36 -0
  51. data/lib/olefs/subobjects/new_receipt_notes_line.rb +35 -0
  52. data/lib/olefs/subobjects/notes_line.rb +29 -0
  53. data/lib/olefs/subobjects/processing_line.rb +24 -0
  54. data/lib/olefs/subobjects/receipt_notes_line.rb +25 -0
  55. data/lib/olels/common/e_doc.rb +23 -0
  56. data/lib/olels/common/editor.rb +92 -0
  57. data/lib/olels/common/line_object.rb +39 -0
  58. data/lib/olels/common/lookup.rb +30 -0
  59. data/lib/olels/objects/access_info_line.rb +25 -0
  60. data/lib/olels/objects/data_line.rb +31 -0
  61. data/lib/olels/objects/editor_note.rb +79 -0
  62. data/lib/olels/objects/holdings_note.rb +26 -0
  63. data/lib/olels/objects/item_note.rb +26 -0
  64. data/lib/olels/objects/ownership_extent_line.rb +40 -0
  65. data/lib/olels/pages/bib_editor.rb +63 -0
  66. data/lib/olels/pages/describe_workbench.rb +42 -0
  67. data/lib/olels/pages/instance_editor.rb +80 -0
  68. data/lib/olels/pages/item_editor.rb +91 -0
  69. data/lib/olels/pages/loan.rb +102 -0
  70. data/lib/olels/pages/main_menu.rb +31 -0
  71. data/lib/olels/pages/patron_lookup.rb +44 -0
  72. data/lib/olels/pages/return.rb +64 -0
  73. data/lib/olels/subobjects/ownership_note.rb +26 -0
  74. data/ole-qa-framework.gemspec +30 -0
  75. data/pkg/ole-qa-framework-2.1.0.gem +0 -0
  76. data/spec/common/browser_spec.rb +37 -0
  77. data/spec/common/data_object_spec.rb +37 -0
  78. data/spec/common/line_object_spec.rb +49 -0
  79. data/spec/common/page_spec.rb +44 -0
  80. data/spec/common/subline_object_spec.rb +54 -0
  81. data/spec/modules/qa_helpers_spec.rb +55 -0
  82. data/spec/modules/qa_page_helpers_spec.rb +43 -0
  83. data/spec/olefs/accounting_line_spec.rb +85 -0
  84. data/spec/olefs/building_lookup_spec.rb +45 -0
  85. data/spec/olefs/copies_line_spec.rb +70 -0
  86. data/spec/olefs/edocs_spec.rb +75 -0
  87. data/spec/olefs/exception_notes_line_spec.rb +52 -0
  88. data/spec/olefs/invoice_notes_line_spec.rb +45 -0
  89. data/spec/olefs/line_item_spec.rb +155 -0
  90. data/spec/olefs/lookup_spec.rb +44 -0
  91. data/spec/olefs/main_menu_spec.rb +34 -0
  92. data/spec/olefs/notes_line_spec.rb +65 -0
  93. data/spec/olefs/patron_lookup_spec.rb +54 -0
  94. data/spec/olefs/payment_request_spec.rb +85 -0
  95. data/spec/olefs/preq_creation_spec.rb +43 -0
  96. data/spec/olefs/preq_line_item_spec.rb +111 -0
  97. data/spec/olefs/processing_line_spec.rb +44 -0
  98. data/spec/olefs/purap_document_spec.rb +58 -0
  99. data/spec/olefs/purchase_order_spec.rb +77 -0
  100. data/spec/olefs/receipt_notes_line_spec.rb +54 -0
  101. data/spec/olefs/receive_spec.rb +66 -0
  102. data/spec/olefs/receiving_line_spec.rb +125 -0
  103. data/spec/olefs/requisition_spec.rb +83 -0
  104. data/spec/olefs/vendor_lookup_spec.rb +49 -0
  105. data/spec/olels/access_info_line_spec.rb +40 -0
  106. data/spec/olels/bib_editor_spec.rb +84 -0
  107. data/spec/olels/data_line_spec.rb +44 -0
  108. data/spec/olels/describe_workbench_spec.rb +44 -0
  109. data/spec/olels/editor_spec.rb +56 -0
  110. data/spec/olels/edocs_spec.rb +42 -0
  111. data/spec/olels/holdings_note_spec_spec.rb +41 -0
  112. data/spec/olels/instance_editor_spec.rb +81 -0
  113. data/spec/olels/item_editor_spec.rb +94 -0
  114. data/spec/olels/item_note_spec.rb +41 -0
  115. data/spec/olels/loan_spec.rb +104 -0
  116. data/spec/olels/lookup_spec.rb +38 -0
  117. data/spec/olels/main_menu_spec.rb +35 -0
  118. data/spec/olels/ownership_extent_line_spec.rb +58 -0
  119. data/spec/olels/ownership_note_spec.rb +41 -0
  120. data/spec/olels/return_spec.rb +72 -0
  121. data/spec/spec_helper.rb +21 -0
  122. data/spec/workflows/purap_spec.rb +221 -0
  123. metadata +313 -0
@@ -0,0 +1,57 @@
1
+ # Copyright 2005-2013 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
+ # OLE object class to be inherited by both Page Object and Data Object classes.
17
+ # (Grouping together common initialize settings for DRYness.)
18
+ # @note The instance variable @browser can be used internally to refer to the
19
+ # browser and only the browser, whereas the instance method .browser, defined
20
+ # in {OLE_QA::Framework::Helpers#browser} will refer either to the browser
21
+ # itself or to the browser within the context of the "iframeportlet" frame,
22
+ # if it is found to be present.
23
+ class Common_Object
24
+ include OLE_QA::Framework::Helpers
25
+
26
+ # The OLE_QA::Framework::Session instance passed to the Data Object.
27
+ attr_accessor :ole
28
+
29
+ # Arrays containing the names(Symbol) of each element or function declared
30
+ # on a data object.
31
+ attr_reader :elements, :functions
32
+
33
+ # @param ole_session [Object] The OLE_QA::Framework::Session instance with which the object should load.
34
+ def initialize(ole_session)
35
+ @ole = ole_session
36
+ @browser = ole_session.browser
37
+ @elements = Array.new
38
+ @functions = Array.new
39
+ set_elements if defined?(self.set_elements)
40
+ set_functions if defined?(self.set_functions)
41
+ end
42
+
43
+ # Fill this method with element definitions in a subclass.
44
+ # - Call super first in this method if the subclass overrides elements from the superclass.
45
+ # - Use with {OLE_QA::Framework::Helpers#set_element}
46
+ # @note This method is automatically called on any subclass if defined therein.
47
+ def set_elements
48
+ end
49
+
50
+ # Fill this method with function definitions in a subclass.
51
+ # - Call super first in this method if the subclass overrides functions from the superclass.
52
+ # - Use with {OLE_QA::Framework::Helpers#set_function}
53
+ # @note This method is automatically called on any subclass if defined therein.
54
+ def set_functions
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,21 @@
1
+ # Copyright 2005-2013 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
+ # An object in OLE which contains screen elements but is not itself a screen element.
18
+ class Data_Object < Common_Object
19
+ include OLE_QA::Framework::Data_Helpers
20
+ end
21
+ end
@@ -0,0 +1,44 @@
1
+ # Copyright 2005-2013 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
+ # A Data Object in OLE that represents a single line in a given area.
18
+ # A line object can usually be added or deleted, and may or may not
19
+ # have its own line objects beneath it in the page-object hierarchy.
20
+ class Line_Object < Data_Object
21
+
22
+ # The line number that this object will have on the screen.
23
+ # - Used for line identifier replacement.
24
+ attr_reader :line_number
25
+ attr_reader :line_id
26
+
27
+ # @param ole_session [Object] The OLE_QA::Framework::Session session to pass to the Data Object.
28
+ # @param line_number [Fixnum] The number this line object will use for element definitions.
29
+ def initialize(ole_session, line_number = 1)
30
+ @line_number = line_number
31
+ @line_id = line_number - 1
32
+ super(ole_session)
33
+ end
34
+
35
+ # Set element definitions, if any.
36
+ # @note Use @line_number or @line_id in an element definition to specify either the textual,
37
+ # human-readable (1-based) line number of the line object, or the coded, application-readable
38
+ # (0-based) line identifier number of the line object.
39
+ def set_elements
40
+ end
41
+
42
+
43
+ end
44
+ end
@@ -0,0 +1,72 @@
1
+ # Copyright 2005-2013 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
+ # An OLE Page object
18
+ class Page < Common_Object
19
+
20
+ # The URL to open a given page.
21
+ # @note Do not use this value for the URL to open a new page of a given
22
+ # document type. If the page object represents an e-Document in OLEFS
23
+ # or OLELS, instead use the :new_url accessor set on the e-Doc object.
24
+ attr_reader :url
25
+
26
+ include OLE_QA::Framework::Page_Helpers
27
+
28
+ # @param ole_session [Object] The OLE_QA::Framework::Session instance in which the page should load.
29
+ # @param url [String] The URL (if any) used to open the page. (Set to "" if unused.)
30
+ def initialize(ole_session, url)
31
+ super(ole_session)
32
+ @url = url
33
+ @wait_on = Array.new
34
+ wait_for_elements if defined?(self.wait_for_elements)
35
+ end
36
+
37
+ # Open the page via URL.
38
+ # @note Some pages may not have custom open URLs. If this is the case,
39
+ # this method can be passed a lookup URL with a document ID #.
40
+ # @note This method will invoke the wait_for_elements method if it is defined on a page.
41
+ # @note If a page has declared elements to wait on, invoking this method will return
42
+ # an array of the symbols used to call those methods.
43
+ def open(url = @url)
44
+ @browser.goto(url)
45
+ @wait_on.each { |element| wait_for_element(element) } if defined?(wait_for_elements)
46
+ end
47
+
48
+ # Define this method on a subclass. Add element symbols to the @wait_on array.
49
+ # This will require the open method to wait for each of these elements to be present before it finishes.
50
+ # e.g.
51
+ # def wait_for_elements
52
+ # @wait_on << :title
53
+ # @wait_on << :close_button
54
+ # super
55
+ # end
56
+ #
57
+ def wait_for_elements
58
+ end
59
+
60
+ # Use this method on subclasses to define elements that must be loaded for the page to be considered completely loaded.
61
+ # This method can be called individually or will be called on an open command if .wait_for_elements is defined on the subclass.
62
+ def wait_for_element(element)
63
+ self.send(element).wait_until_present(@ole.explicit_wait)
64
+ end
65
+
66
+ # Call this method on a page that has wait_for_elements defined
67
+ # to wait for all required elements on that page to load.
68
+ def wait_for_page_to_load
69
+ @wait_on.each { |element| wait_for_element(element) }
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,47 @@
1
+ # Copyright 2005-2013 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
+ # A Data Object in OLE that represents a line nested under another line.
17
+ # A subline can usually be added or deleted, and has element identifiers
18
+ # which vary dependent upon the line below which they are nested.
19
+ class Subline_Object < Data_Object
20
+
21
+ # The line number that this object will have on the screen.
22
+ # - Used for line identifier replacement.
23
+ attr_reader :line_number
24
+ attr_reader :line_id
25
+
26
+ # The line number that this subline object will have on the screen.
27
+ # - Used for subline identifier replacement.
28
+ attr_reader :subline_number
29
+ attr_reader :subline_id
30
+
31
+ # @param ole_session [Object] The OLE_QA::Framework::Session session to pass to the Data Object.
32
+ # @param line_number [Fixnum] The line number this subline object will use for element definitions.
33
+ # @param subline_number [Fixnum] The subline number this subline object will use for element definitions.
34
+ def initialize(ole_session, line_number = 1, subline_number = 1)
35
+ @line_number, @subline_number = line_number, subline_number
36
+ @line_id = line_number -1
37
+ @subline_id = subline_number -1
38
+ super(ole_session)
39
+ end
40
+
41
+ # Set elements on the subline object.
42
+ # @note Use line_number, line_id, subline_number, and subline_id to replace dynamic identifier numbers.
43
+ # (See {OLE_QA::Framework::Line_Object#set_elements} for more on line number substitution.)
44
+ def set_elements
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,7 @@
1
+ ---
2
+ :base_url: http://tst.ole.kuali.org/
3
+ :ls_url: http://tst.rice2.ole.kuali.org/
4
+ :headless?: true
5
+ :implicit_wait: 0
6
+ :explicit_wait: 15
7
+ :doc_wait: 45
@@ -0,0 +1,13 @@
1
+ # Copyright 2005-2013 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.
@@ -0,0 +1,17 @@
1
+ # Copyright 2005-2013 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::Data_Helpers
16
+
17
+ end
@@ -0,0 +1,153 @@
1
+ # Copyright 2005-2013 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::Helpers
16
+ # Handle frame selection in the browser via aliasing the @browser session passed to a page or data object.
17
+ # - If the page or data object is inherited by any kind of OLE e-Doc, all elements will be encapsulated within a frame
18
+ # with an ID of 'iframeportlet'.
19
+ # - If the page is a main menu page or a lookup page, the frame may not be present.
20
+ def browser
21
+ if @ole.browser.frame(:class => 'fancybox-iframe').present?
22
+ @ole.browser.frame(:class => 'fancybox-iframe')
23
+ elsif @ole.browser.frame(:id => 'iframeportlet').present?
24
+ @ole.browser.frame(:id => 'iframeportlet')
25
+ else
26
+ @ole.browser
27
+ end
28
+ end
29
+ alias_method(:b,:browser)
30
+
31
+ # Add an accessor to a class from within that class only.
32
+ def make_accessor(symbol)
33
+ eigenclass = class << self;
34
+ self
35
+ end
36
+ eigenclass.class_eval do
37
+ attr_accessor symbol
38
+ end
39
+ end
40
+ private :make_accessor
41
+
42
+ # Add a reader to a class from within that class only.
43
+ def make_reader(symbol)
44
+ eigenclass = class << self;
45
+ self
46
+ end
47
+ eigenclass.class_eval do
48
+ attr_reader symbol
49
+ end
50
+ end
51
+ private :make_reader
52
+
53
+ # Add a writer to a class from within that class only.
54
+ def make_writer(symbol)
55
+ eigenclass = class << self;
56
+ self
57
+ end
58
+ eigenclass.class_eval do
59
+ attr_writer symbol
60
+ end
61
+ end
62
+ private :make_writer
63
+
64
+ # Unset a previously defined attribute on a class.
65
+ def unmake_attr(method_name)
66
+ eigenclass = class << self;
67
+ self
68
+ end
69
+ eigenclass.class_eval do
70
+ undef_method(method_name)
71
+ end
72
+ end
73
+ private :unmake_attr
74
+
75
+ # Set an element definition on a page or data object.
76
+ # - An element created with this method becomes an accessor attribute
77
+ # associated with an instance variable on the page or data object on
78
+ # which it is created.
79
+ #
80
+ # @param name [Symbol] The name the new element will have on the object.
81
+ # (This will be an instance variable, so it cannot contain spaces.)
82
+ # @param force [Boolean] If set to true, this method can be used to override an existing element definition.
83
+ #
84
+ # @raise StandardError if a parameter is of an incorrect type.
85
+ # @raise StandardError if an instance method already exists for an element with the same name.
86
+ # (Suppress with force = true.)
87
+ #
88
+ # @note This method can also be used to add an element to an existing page object instance.
89
+ # The code block passed to the method will need to explicitly name the class instance in order to
90
+ # access the browser method.
91
+ #
92
+ # @note In some cases in OLE, text_field elements are coded as <input> elements. If Watir-Webdriver
93
+ # returns an error in a case like this, affixing .to_subtype should make the #set method available.
94
+ #
95
+ def set_element(name, force = false)
96
+ raise StandardError, "Name must be a symbol. Given: #{name} (#{name.class})" unless name.instance_of?(Symbol)
97
+ eigenclass = class << self;
98
+ self
99
+ end
100
+ raise StandardError, "Element is already defined. (Use the 'force = true' option to suppress this error.)" if eigenclass.instance_methods.include?(name) && ! force
101
+ eigenclass.class_eval do
102
+ define_method name.to_s do
103
+ yield self
104
+ end
105
+ end
106
+ @elements << name
107
+ end
108
+ alias_method(:element, :set_element)
109
+
110
+ # Set a function definition on a page or data object.
111
+ # - A function created with this method becomes an accessor attribute
112
+ # associated with an instance variable on the page or data object on
113
+ # which it is created.
114
+ #
115
+ # @param name [Symbol] The name the new function will have on the object.
116
+ # (This will be an instance variable, so it cannot contain spaces.)
117
+ # @param force [Boolean] If set to true, this method can be used to override an existing function definition.
118
+ #
119
+ # @raise StandardError if a parameter is of an incorrect type.
120
+ # @raise StandardError if an instance method already exists for a function with the same name.
121
+ # (Suppress with force = true.)
122
+ #
123
+ # @note Invoking a function without passing the expected parameter/s may not return an appropriate error message.
124
+ def set_function(name, force = false, &block)
125
+ raise StandardError, "Name must be a symbol. Given: #{name} (#{name.class})" unless name.instance_of?(Symbol)
126
+ eigenclass = class << self;
127
+ self
128
+ end
129
+ raise StandardError, "Element is already defined. (Use the 'force = true' option to suppress this error.)" if eigenclass.instance_methods.include?(name) && ! force
130
+ eigenclass.class_eval do
131
+ define_method name.to_s do |*arg|
132
+ yield *arg
133
+ end
134
+ end
135
+ @functions << name
136
+ end
137
+ alias_method(:function,:set_function)
138
+
139
+ # Load a YML file.
140
+ def load_yml(subdir, filename)
141
+ basedir = OLE_QA::Framework::load_dir
142
+ file_path = basedir + '/' + subdir + filename
143
+ if File.exists?(file_path) then
144
+ yaml_file = File.open(file_path, 'r')
145
+ yaml = YAML.load(yaml_file)
146
+ yaml_file.close
147
+ yaml
148
+ else
149
+ raise StandardError, "File does not exist. (#{basedir + subdir + filename})"
150
+ end
151
+ end
152
+ alias_method(:load_yaml,:load_yml)
153
+ end
@@ -0,0 +1,33 @@
1
+ # Copyright 2005-2013 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::Page_Helpers
16
+ # Login as a given user.
17
+ # @param username [String] The username to use.
18
+ # @return [Boolean] Whether the login process succeeded.
19
+ def login(username)
20
+ raise OLE_QA::Framework::Error,"Login field not present on this page: #{self.class.name}" unless @browser.text_field(:name => "backdoorId").present?
21
+ @browser.text_field(:name => "backdoorId").set(username)
22
+ @browser.input(:class => "go", :value => "Login").click
23
+ @browser.div(:id => "login-info").strong(:text => /Impersonating User\:/, :text => /#{username}/).present?
24
+ end
25
+
26
+ # Logout from previous login.
27
+ # @return [Boolean] Whether the logout process succeeded.
28
+ def logout
29
+ @browser.input(:class => "go", :value => "Logout").click
30
+ # Return false if still impersonating user, true if not.
31
+ @browser.div(:id => "login-info").strong(:text => /Impersonating User\:/).present? ? false : true
32
+ end
33
+ end