testability-driver 0.9.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +1 -1
  2. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +11 -7
  3. data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +8 -0
  4. data/lib/tdriver/base/behaviour/factory.rb +229 -209
  5. data/lib/tdriver/base/errors.rb +3 -0
  6. data/lib/tdriver/base/state_object.rb +11 -20
  7. data/lib/tdriver/base/sut/controller.rb +4 -4
  8. data/lib/tdriver/base/sut/factory.rb +205 -170
  9. data/lib/tdriver/base/sut/generic/behaviours/application.rb +256 -174
  10. data/lib/tdriver/base/sut/generic/behaviours/find.rb +17 -11
  11. data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +57 -66
  12. data/lib/tdriver/base/sut/generic/behaviours/sut.rb +578 -497
  13. data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +41 -15
  14. data/lib/tdriver/base/sut/generic/behaviours/verification.rb +48 -19
  15. data/lib/tdriver/base/sut/generic/commands/fixture.rb +47 -0
  16. data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +25 -13
  17. data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +16 -10
  18. data/lib/tdriver/base/sut/generic/plugin.rb +9 -3
  19. data/lib/tdriver/base/sut/sut.rb +41 -33
  20. data/lib/tdriver/base/test_object/abstract.rb +26 -3
  21. data/lib/tdriver/base/test_object/adapter.rb +399 -0
  22. data/lib/tdriver/base/test_object/behaviours/syncronization.rb +56 -14
  23. data/lib/tdriver/base/test_object/behaviours/test_object.rb +663 -197
  24. data/lib/tdriver/base/test_object/cache.rb +132 -0
  25. data/lib/tdriver/base/test_object/factory.rb +677 -426
  26. data/lib/tdriver/base/test_object/factory_new.rb +202 -0
  27. data/lib/tdriver/base/test_object/identificator.rb +24 -17
  28. data/lib/tdriver/base/test_object/loader.rb +9 -3
  29. data/lib/tdriver/base/test_object/verification.rb +181 -0
  30. data/lib/tdriver/loader.rb +1 -1
  31. data/lib/tdriver/report/report.rb +2 -0
  32. data/lib/tdriver/report/report_api.rb +4 -4
  33. data/lib/tdriver/report/report_creator.rb +29 -3
  34. data/lib/tdriver/report/report_data_presentation.rb +7 -3
  35. data/lib/tdriver/report/report_execution_statistics.rb +80 -21
  36. data/lib/tdriver/report/report_javascript.rb +192 -0
  37. data/lib/tdriver/report/report_test_case_run.rb +22 -0
  38. data/lib/tdriver/report/report_test_run.rb +62 -55
  39. data/lib/tdriver/report/report_writer.rb +57 -56
  40. data/lib/tdriver/tdriver.rb +14 -41
  41. data/lib/tdriver/util/common/error.rb +1 -0
  42. data/lib/tdriver/util/common/exceptions.rb +12 -0
  43. data/lib/tdriver/util/common/file.rb +12 -6
  44. data/lib/tdriver/util/common/gem.rb +2 -1
  45. data/lib/tdriver/util/common/hash.rb +152 -0
  46. data/lib/tdriver/util/common/kernel.rb +49 -34
  47. data/lib/tdriver/util/common/loader.rb +21 -17
  48. data/lib/tdriver/util/common/numeric.rb +39 -0
  49. data/lib/tdriver/util/common/object.rb +115 -0
  50. data/lib/tdriver/util/common/string.rb +55 -2
  51. data/lib/tdriver/util/dbaccess/dbaccess.rb +194 -161
  52. data/lib/tdriver/util/dynamic_attribute_filter.rb +6 -0
  53. data/lib/tdriver/util/hooking.rb +2 -2
  54. data/lib/tdriver/util/loader.rb +2 -2
  55. data/lib/tdriver/util/localisation/localisation.rb +277 -18
  56. data/lib/tdriver/util/logger.rb +142 -13
  57. data/lib/tdriver/util/parameter/parameter_hash.rb +8 -5
  58. data/lib/tdriver/util/parameter/parameter_xml.rb +18 -2
  59. data/lib/tdriver/util/recorder.rb +17 -12
  60. data/lib/tdriver/util/user_data/user_data.rb +3 -2
  61. data/lib/tdriver/util/{video_rec.rb → video_utils.rb} +136 -16
  62. data/lib/tdriver/util/xml/abstraction.rb +7 -0
  63. data/lib/tdriver/util/xml/attribute.rb +32 -0
  64. data/lib/tdriver/util/xml/loader.rb +8 -2
  65. data/lib/tdriver/util/xml/nil_node.rb +95 -0
  66. data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +46 -7
  67. data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +19 -9
  68. data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +1 -1
  69. data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +13 -1
  70. data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +6 -0
  71. data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +27 -15
  72. data/lib/tdriver/util/xml/parsers/nokogiri/text.rb +57 -0
  73. data/lib/tdriver/util/xml/text.rb +32 -0
  74. data/lib/tdriver/util/xml/xml.rb +35 -22
  75. data/lib/tdriver/version.rb +1 -1
  76. data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +41 -34
  77. data/lib/tdriver-devtools/doc/generate.rb +31 -6
  78. data/lib/tdriver-devtools/doc/xslt/template.xsl +46 -25
  79. data/lib/tdriver-devtools/tests/feature_tests/example/behaviour_example.rb +100 -0
  80. data/lib/tdriver-devtools/tests/feature_tests/update +1 -1
  81. data/lib/tdriver.rb +0 -3
  82. data/xml/behaviours/generic.xml +1 -1
  83. data/xml/defaults/generic.xml +4 -90
  84. data/xml/templates/generic.xml +33 -25
  85. metadata +21 -29
  86. data/lib/tdriver-devtools/behaviour/xml_generator/example/flick-example.rb +0 -245
  87. data/lib/tdriver-devtools/behaviour/xml_generator/example/sut.rb +0 -964
  88. data/lib/tdriver-devtools/behaviour/xml_generator/generate.rb +0 -68
  89. data/lib/tdriver-devtools/behaviour/xml_generator/lib/custom_rdoc_generator.rb +0 -1865
  90. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.default.template +0 -1
  91. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.template +0 -3
  92. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument_type.template +0 -4
  93. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.exception.template +0 -4
  94. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.arguments.template +0 -4
  95. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.deprecated.template +0 -3
  96. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.exceptions.template +0 -3
  97. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.info.template +0 -1
  98. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.returns.template +0 -3
  99. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.tables.template +0 -3
  100. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.template +0 -12
  101. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.returns.template +0 -5
  102. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.item.template +0 -1
  103. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.row.template +0 -2
  104. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.template +0 -7
  105. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.template +0 -14
  106. data/lib/tdriver-devtools/behaviour/xml_generator/update +0 -3
  107. data/lib/tdriver-devtools/tests/feature_tests/example/flick-example.rb +0 -233
  108. data/lib/tdriver-devtools/tests/feature_tests/example/impl.rb +0 -194
@@ -44,26 +44,68 @@ module MobyBehaviour
44
44
 
45
45
  include MobyBehaviour::Behaviour
46
46
 
47
- # Wait until this test object has a child test object of the specified type and matching the given attributes.
48
- # The child being waited for must be identifiable by the provided constraints. The call terminates
49
- # only when exactly a single child matches the criteria.
47
+ # == description
48
+ # Wait until this test object has a child test object matching the given attributes or timeout exceeds. An exception will be raised if test object was not found in the specified timeout.
49
+ #
50
+ # == arguments
51
+ # attributes
52
+ # Hash
53
+ # description: Hash defining the set of attributes that the child test object must possess.
54
+ # example: {:text=>'1'}
55
+ #
56
+ # timeout_secs
57
+ # Fixnum
58
+ # description: Overriding the default synchronization timeout
59
+ # example: 30
60
+ #
61
+ # retry_interval
62
+ # Fixnum
63
+ # description: Time used before retrying to find test object
64
+ # example: 1
65
+ #
66
+ # == returns
67
+ # MobyBase::TestObject
68
+ # description: Returns self
69
+ # example: -
70
+ #
71
+ # == exceptions
72
+ # TypeError
73
+ # description: Wrong argument type %s for attributes (expected Hash)
74
+ #
75
+ # TypeError
76
+ # description: Wrong argument type %s for attribute :type (expected String)
77
+ #
78
+ # TypeError
79
+ # description: Wrong argument type %s for timeout (expected Integer, Fixnum or Float)
80
+ #
81
+ # ArgumentError
82
+ # description: Argument retry_interval was not a valid. Expected: Integer, Fixnum or Float
83
+ #
84
+ # MobyBase::SyncTimeoutError
85
+ # description: Synchronization timed out (%i) before the defined child object could be found
50
86
  #
51
- # === params
52
- # type:: String defining the type of the child test object, eg. "list", "softkey"
53
- # attributes:: (optional) Hash defining the set of attributes that the child test object must possess.
54
- # timeout:: (optional) Integer overriding the default synchronization timeout.
55
- # === raises
56
- # ArgumentError:: One of the arguments was not of a valid format.
57
- # SyncTimeoutError:: The timeout has passed without synchronization success.
58
87
  def wait_child( attributes = {}, timeout_secs = 10, retry_interval = 0.5 )
59
88
 
60
- Kernel::raise ArgumentError.new( "Argument type was not a valid. Expected: String" ) unless attributes[ :type ].kind_of?( String ) && attributes[ :type ].length > 0
89
+ #Kernel::raise ArgumentError.new( "Argument attributes was not a valid. Expected: Hash" ) unless attributes.kind_of?( Hash )
90
+ #Kernel::raise ArgumentError.new( "Argument type was not a valid. Expected: String" ) unless attributes[ :type ].kind_of?( String ) && attributes[ :type ].length > 0
91
+ #Kernel::raise ArgumentError.new( "Argument timeout_secs was not a valid. Expected: Integer, Fixnum or Float" ) unless [ Integer, Fixnum, Float ].include? timeout_secs.class
92
+ #Kernel::raise ArgumentError.new( "Argument retry_interval was not a valid. Expected: Integer, Fixnum or Float" ) unless [ Integer, Fixnum, Float ].include? retry_interval.class
93
+
94
+
95
+ # verify that attributes is type of Hash
96
+ attributes.check_type( Hash, "Wrong argument type $1 for attributes (expected $2)" )
97
+
98
+ # verify that :type is type of String
99
+ attributes[ :type ].check_type( String, "Wrong argument type $1 for attribute :type (expected $2)" )
61
100
 
62
- Kernel::raise ArgumentError.new( "Argument attributes was not a valid. Expected: Hash" ) unless attributes.kind_of?( Hash )
101
+ # verify that :type is not empty string
102
+ attributes[ :type ].not_empty( "Attribute :type must not be empty" )
63
103
 
64
- Kernel::raise ArgumentError.new( "Argument timeout_secs was not a valid. Expected: Integer, Fixnum or Float" ) unless [ Integer, Fixnum, Float ].include? timeout_secs.class
104
+ # verify timeout type is numeric
105
+ timeout_secs.check_type( [ Integer, Fixnum, Float ], "Wrong argument type $1 for timeout (expected $2)" )
65
106
 
66
- Kernel::raise ArgumentError.new( "Argument retry_interval was not a valid. Expected: Integer, Fixnum or Float" ) unless [ Integer, Fixnum, Float ].include? retry_interval.class
107
+ # verify timeout type is numeric
108
+ retry_interval.check_type( [ Integer, Fixnum, Float ], "Wrong argument type $1 for retry interval (expected $2)" )
67
109
 
68
110
  begin
69
111
 
@@ -51,14 +51,27 @@ module MobyBehaviour
51
51
  # example: { :name => 'Triangle1', :type => :Triangle }
52
52
  attr_accessor :creation_attributes
53
53
 
54
- # === description
54
+
55
+ # == nodoc
56
+ # == description
57
+ # Changes the status of the test object to active
58
+ # == returns
59
+ # TrueClass::
60
+ # == example
61
+ # @app = @sut.run(:name => 'testapp') # launches testapp
62
+ # @app.Node( :name => 'Node1' ).activate() # activate given object
63
+ def activate
64
+
65
+ @_active = true
66
+
67
+ end
68
+
69
+ # == description
55
70
  # Determines if the current test object is of type 'application'
56
- # === returns
57
- # TrueClass::
58
- # FalseClass::
59
- # == example
60
- # @test_app = @sut.run(:name => 'testapp') # launches testapp
61
- # isApplication = @test_app.application?
71
+ # == returns
72
+ # Boolean
73
+ # description: Determines is test object type of application
74
+ # example: false
62
75
  def application?
63
76
 
64
77
  @type == 'application'
@@ -67,157 +80,194 @@ module MobyBehaviour
67
80
 
68
81
  # == description
69
82
  # Return all test object attributes
70
- # === returns
71
- # Hash:: Test object attributes
83
+ # == returns
84
+ # Hash
85
+ # description: Test object attributes
86
+ # example: {"localeLanguage"=>"English", "startDragDistance"=>"4", "windowIcon"=>"", "memUsage"=>"25669"}
72
87
  # == example
73
88
  # @test_app = @sut.run(:name => 'testapp') # launches testapp
74
89
  # attributes_hash = @test_app.Triangle( :name => 'Triangle1' ).attributes # retrieve all attribute for triangle object
75
90
  def attributes
76
91
 
77
- # return hash of test object attributes
78
- Hash[ xml_data.xpath( 'attributes/attribute' ).collect{ | test_object | [ test_object.attribute( 'name' ), test_object.content ] } ]
92
+ begin
79
93
 
80
- end
94
+ # retrieve xml data, performs xpath to sut xml_data
95
+ _xml_data = xml_data
81
96
 
82
- # == nodoc
83
- # == description
84
- # Changes the status of the test object to active
85
- # == returns
86
- # TrueClass::
87
- # == example
88
- # @app = @sut.run(:name => 'testapp') # launches testapp
89
- # @app.Node( :name => 'Node1' ).activate() # activate given object
90
- def activate
97
+ rescue MobyBase::TestObjectNotFoundError
91
98
 
92
- @_active = true
99
+ # attributes used to refresh parent application
100
+ if @creation_attributes[ :type ] == 'application'
93
101
 
94
- end
102
+ # use application name and id attributes
103
+ refresh_args = { :name => @creation_attributes[ :name ], :id => @creation_attributes[ :id ] }
95
104
 
96
- # == nodoc
97
- # Changes the status of the test object to inactive, also deactivating all children
98
- # Removes reference from @parent TestObject or SUT to this TestObject so that
99
- # @parent.refresh does not refresh currrent TestObject
100
- #
101
- # Does nothing if TestObject is already deactivated
102
- # == returns
103
- # ?
104
- def deactivate
105
-
106
- return if !@_active
105
+ else
107
106
 
108
- @_active = false
107
+ # test object if not type of application
108
+ refresh_args = { :id => get_application_id }
109
109
 
110
- @_child_object_cache.each_value{ | test_object |
110
+ end
111
111
 
112
- # deactivate test object
113
- test_object.deactivate
112
+ #lets refresh if attribute not found on first attempt
113
+ refresh( refresh_args )
114
114
 
115
- }
115
+ # retrieve updated xml data
116
+ _xml_data = xml_data
116
117
 
117
- @_child_object_cache.clear
118
+ end
118
119
 
119
- @parent.remove_child( self )
120
+ # return hash of test object attributes
121
+ TDriver::TestObjectAdapter.test_object_attributes( _xml_data )
120
122
 
121
123
  end
122
124
 
123
125
  # == description
124
126
  # Function returns a attribute of test object
125
- # == params
126
- # name:: String definig the name of the attribute to get
127
+ #
128
+ # == arguments
129
+ # name
130
+ # String
131
+ # description: String definig the name of the attribute to get
132
+ # example: "name"
133
+ #
127
134
  # == returns
128
- # String:: Value of the attribute as a string
135
+ # String
136
+ # description: Value of the attribute as a string
137
+ # example: "value"
138
+ #
129
139
  # == exceptions
130
- # TestObjectNotInitializedError:: if the test object xml data has not been initialized
131
- # AttributeNotFoundError:: if the requested attribute can not be found in the xml data of the object
140
+ # TestObjectNotInitializedError
141
+ # description: if the test object xml data has not been initialized
142
+ #
143
+ # AttributeNotFoundError
144
+ # description: if the requested attribute can not be found in the xml data of the object
145
+ #
132
146
  # == example
133
147
  # @test_app = @sut.run(:name => 'testapp') # launches testapp
134
148
  # puts @test_app.Triangle( :name => 'Triangle1' ).attribute('color') # prints color of triangle object
135
149
  def attribute( name )
136
-
137
- # note: count of tries represents total number of tries
138
- MobyUtil::Retryable.while( :tries => 2, :interval => 0 ) { | attempt |
139
-
140
- begin
141
-
142
- # find attribute from xml
143
- find_attribute( name )
144
-
145
- rescue MobyBase::AttributeNotFoundError
146
-
147
- # do following actions only once
148
- if ( attempt == 1 )
149
150
 
150
- # add to dynamic attribute filter once
151
- MobyUtil::DynamicAttributeFilter.instance.add_attribute( name )
152
-
153
- # refresh ui state
154
- refresh( :id => get_application_id )
155
-
156
- end
151
+ # TODO: add behaviour logging?
157
152
 
158
- # raise exception and retry if attempts left
159
- raise
160
-
161
- end
153
+ # raise exception if attribute name variable type is other than string
154
+ name.check_type( [ String, Symbol ], "Wrong argument type %s for attribute (expected $2)" )
155
+
156
+ # convert name to string if variable type is symbol
157
+ name = name.to_s if name.kind_of?( Symbol )
162
158
 
163
- }
159
+ # retrieve attribute value
160
+ find_attribute( name )
164
161
 
165
162
  end
166
-
163
+
167
164
  # == description
168
165
  # Returns the parent test object for the current object in question, according to the UI object hierarchy. For getting the test object that was actually used
169
166
  # as the parent when the test object instance was created, see parent_object.
170
167
  # == returns
171
- # TestObject:: test object that is parent of this test object, self if no parent (ie. application objects)
168
+ # TestObject
169
+ # description: test object that is parent of this test object, self if no parent (ie. application objects)
170
+ # example: -
172
171
  # == example
173
172
  # @app = @sut.run(:name => 'testapp') # launches testapp
174
173
  # parent_test_object = @app.Node( :name => 'Node1' ).get_parent() #get parent for some test object
175
- def get_parent()
174
+ def get_parent
176
175
 
176
+ # return current test object if it's type of application
177
177
  return self if application?
178
178
 
179
- @sut.refresh if disable_optimizer
179
+ @sut.refresh if disable_optimizer
180
+
181
+ # retrieve parent of current xml element; objects/object/objects/object/../..
182
+ parent_element = TDriver::TestObjectAdapter.parent_test_object_element( self )
183
+
184
+ # retrieve parent element attributes
185
+ parent_attributes = TDriver::TestObjectAdapter.test_object_element_attributes( parent_element )
186
+
187
+ if self.get_application_id && parent_attributes[ 'type' ] != 'application'
188
+
189
+ parent = @sut.child(
180
190
 
181
- #find parent id
182
- #element_set = @sut.xml_data.xpath( "//object/objects/object[@id='%s']/../.." % @id )
191
+ :id => get_application_id,
192
+ :type => 'application'
193
+
194
+ ).child(
195
+
196
+ :id => parent_attributes[ 'id' ],
197
+ :name => parent_attributes[ 'name' ],
198
+ :type => parent_attributes[ 'type' ],
199
+
200
+ # there was a case when the same parent was included twice in the ui dump
201
+ :__index => 0
202
+ )
203
+
204
+ else
205
+
206
+ parent = @sut.child(
207
+ :id => parent_attributes[ 'id' ],
208
+ :name => parent_attributes[ 'name' ],
209
+ :type => parent_attributes[ 'type' ]
210
+ )
211
+
212
+ end
213
+
214
+ enable_optimizer
215
+
216
+ parent
217
+
218
+
219
+ =begin
220
+
221
+ # return current test object if it's type of application
222
+ return self if application?
223
+
224
+ @sut.refresh if disable_optimizer
225
+
226
+ # find parent id
183
227
  element_set = @sut.xml_data.xpath( "//object/objects/object[@id='#{ @id }']/../.." )
184
228
 
185
- kid = nil
186
- if( element_set == nil or element_set.size == 0 )
187
- kid = self
188
- else
189
- element = element_set.first
229
+ kid = nil
190
230
 
191
- #if app set look for the item under the app to make sure app id is available
231
+ if( element_set == nil or element_set.size == 0 )
232
+
233
+ # return self if there is not parent object available
234
+ kid = self
235
+
236
+ else
237
+
238
+ element = element_set.first
192
239
 
193
- if self.get_application_id && element.attribute( "type" ) != 'application'
240
+ #if app set look for the item under the app to make sure app id is available
194
241
 
195
- kid = @sut.child(
242
+ if self.get_application_id && element.attribute( "type" ) != 'application'
196
243
 
197
- :id => get_application_id,
198
- :type => 'application'
244
+ kid = @sut.child(
245
+ :id => get_application_id,
246
+ :type => 'application'
247
+ ).child(
248
+ :id => element.attribute( "id" ),
249
+ :name => element.attribute( "name" ),
250
+ :type => element.attribute( "type" ),
251
+ :__index => 0 # there was a case when the same parent was included twice in the ui dump
252
+ )
199
253
 
200
- ).child(
254
+ else
201
255
 
202
- :id => element.attribute( "id" ),
203
- :name => element.attribute( "name" ),
204
- :type => element.attribute( "type" ),
205
- :__index => 0 # there was a case when the same parent was included twice in the ui dump
256
+ kid = @sut.child(
257
+ :id => element.attribute( "id" ),
258
+ :name => element.attribute( "name" ),
259
+ :type => element.attribute( "type" )
260
+ )
206
261
 
207
- )
262
+ end
208
263
 
209
- else
264
+ end
210
265
 
211
- kid = @sut.child(
212
- :id => element.attribute( "id" ),
213
- :name => element.attribute( "name" ),
214
- :type => element.attribute( "type" )
215
- )
266
+ enable_optimizer
267
+
268
+ kid
269
+ =end
216
270
 
217
- end
218
- end
219
- enable_optimizer
220
- kid
221
271
  end
222
272
 
223
273
  # == nodoc
@@ -259,10 +309,13 @@ module MobyBehaviour
259
309
  # TestObjectNotFoundError:: if TestObject is not identified within synch timeout.
260
310
  def refresh( refresh_args = {} )
261
311
 
262
- object_search_params = @test_object_factory.make_object_search_params(@creation_attributes)
263
- search_params = @test_object_factory.get_parent_params(parent)
264
- search_params.push(object_search_params)
265
- @sut.refresh( refresh_args, search_params )
312
+ @sut.refresh(
313
+
314
+ refresh_args,
315
+
316
+ @test_object_factory.get_parent_params( parent ) << @test_object_factory.make_object_search_params( @creation_attributes )
317
+
318
+ )
266
319
 
267
320
  end
268
321
 
@@ -311,6 +364,7 @@ module MobyBehaviour
311
364
 
312
365
  end
313
366
 
367
+ # == nodoc
314
368
  # == description
315
369
  # Function for finding out the application id for this test object
316
370
  # == returns
@@ -336,10 +390,12 @@ module MobyBehaviour
336
390
  # Returns a StateObject containing the current state of this test object as XML.
337
391
  # The state object is static and thus is not refreshed or synchronized etc.
338
392
  # == returns
339
- # StateObject:: State of this test object
393
+ # StateObject
394
+ # description: State of this test object
395
+ # example: -
340
396
  # == exceptions
341
397
  # ArgumentError
342
- # description: If the xml source for the object cannot be read
398
+ # description: If the xml source for the object cannot be read
343
399
  # == example
344
400
  # app_state = @sut.application( :name => "calculator" ).state #get the state object for the app
345
401
  # button_state = app_state.Button( :text => "Backspace" ) #get the state for test object button
@@ -350,15 +406,30 @@ module MobyBehaviour
350
406
 
351
407
  end
352
408
 
353
- # Function for translating all symbol values into strings using sut's translate method
354
- # Goes through all items in a hash and if a value is symbol then uses that symbol as a logical
355
- # name and tries to find a translation for that.
356
- # === params
357
- # hash:: Hash containing key, value pairs. The parameter will get modified if symbols are found from values
358
- # === raises
359
- # LanguageNotFoundError:: In case of language is not found
360
- # LogicalNameNotFoundError:: In case of logical name is not found for current language
361
- # MySqlConnectError:: In case problems with the db connectivity
409
+ # == nodoc
410
+ # == description
411
+ # Translates all symbol values in hash using SUT's translate method.
412
+ #
413
+ # == arguments
414
+ # hash
415
+ # Hash
416
+ # description: containing key and value pairs. The hash will get modified if symbols are found from values
417
+ # example: {:text=>:translate_me}
418
+ #
419
+ # == returns
420
+ # Hash
421
+ # description: Translated hash
422
+ # example: {:text=>'translated_text'}
423
+ # == exceptions
424
+ # LanguageNotFoundError
425
+ # description: In case of language is not found
426
+ #
427
+ # LogicalNameNotFoundError
428
+ # description: In case of logical name is not found for current language
429
+ #
430
+ # MySqlConnectError
431
+ # description: In case problems with the db connectivity
432
+ #
362
433
  def translate!( hash, file_name = nil, plurality = nil, numerus = nil, lengthvariant = nil )
363
434
 
364
435
  hash.each_pair do | _key, _value |
@@ -371,8 +442,9 @@ module MobyBehaviour
371
442
 
372
443
  end
373
444
 
445
+ =begin
374
446
  # == description
375
- # Creates a test object for a child object of this test object. Caller test object will be result (child) object's parent object.\n
447
+ # Creates a child test object of this test object. Caller object will be associated as child test objects parent.\n
376
448
  # \n
377
449
  # [b]NOTE:[/b] Subsequent calls to TestObject#child( rule ) always returns reference to same Testobject:\n
378
450
  # [code]a = to.child( :type => 'Button', :text => '1' )
@@ -391,7 +463,7 @@ module MobyBehaviour
391
463
  #
392
464
  # == exceptions
393
465
  # TypeError
394
- # description: raised if agument is not a Hash
466
+ # description: Wrong argument type %s for attributes (expected Hash)
395
467
  #
396
468
  # MultipleTestObjectsIdentifiedError
397
469
  # description: raised if multiple objects found that match the given attributes
@@ -404,13 +476,212 @@ module MobyBehaviour
404
476
  def child( attributes )
405
477
 
406
478
  # verify attributes argument format
407
- raise TypeError.new( 'Unexpected argument type (%s) for attributes, expecting %s' % [ attributes.class, "Hash" ] ) unless attributes.kind_of?( Hash )
408
-
479
+ #raise TypeError.new( 'Unexpected argument type (%s) for attributes, expecting %s' % [ attributes.class, "Hash" ] ) unless attributes.kind_of?( Hash )
480
+ attributes.check_type( Hash, "Wrong argument type $1 for attributes (expected $2)" )
481
+
482
+
409
483
  # retrieve child object
410
484
  get_child_objects( attributes )
411
485
 
412
486
  end
487
+
488
+ def child( attributes )
489
+
490
+ ###############################################################################################################
491
+ #
492
+ # NOTICE: Please do not add anything unnessecery to this method, it might cause a major performance impact
493
+ #
494
+
495
+ # verify attributes argument format
496
+ attributes.check_type( Hash, "Wrong argument type $1 for attributes (expected $2)" )
497
+
498
+ # store original hash
499
+ creation_hash = attributes.clone
500
+
501
+ dynamic_attributes = creation_hash.strip_dynamic_attributes!
502
+
503
+ # raise exception if wrong value type given for ;__logging
504
+ dynamic_attributes[ :__logging ].check_type(
505
+
506
+ [ TrueClass, FalseClass ],
507
+
508
+ "Wrong value type $1 for :__logging test object creation directive (expected $2)"
509
+
510
+ ) if dynamic_attributes.has_key?( :__logging )
511
+
512
+ # disable logging if requested, remove pair from creation_hash
513
+ MobyUtil::Logger.instance.push_enabled( dynamic_attributes[ :__logging ] || TDriver.logger.enabled )
514
+
515
+ # check if the hash contains symbols as values and translate those into strings
516
+ translate!( creation_hash, attributes[ :__fname ], attributes[ :__plurality ], attributes[ :__numerus ], attributes[ :__lengthvariant ] )
517
+
518
+ begin
519
+
520
+ # TODO: refactor me
521
+ child_test_object = @test_object_factory.make_object(
522
+
523
+ # current object as parent, can be either TestObject or SUT
524
+ :parent => self,
525
+
526
+ # test object identification hash
527
+ :object_attributes_hash => creation_hash,
528
+
529
+ :identification_directives => dynamic_attributes
530
+
531
+ )
532
+
533
+
534
+ rescue Exception => exception
535
+
536
+ if exception.kind_of?( MobyBase::MultipleTestObjectsIdentifiedError )
537
+
538
+ description = "Multiple child objects matched criteria."
539
+
540
+ elsif exception.kind_of?( MobyBase::TestObjectNotFoundError )
541
+
542
+ description = "The child object(s) could not be found."
543
+
544
+ elsif exception.kind_of?( MobyBase::TestObjectNotVisibleError )
545
+
546
+ description = "Parent test object no longer visible."
547
+
548
+ else
549
+
550
+ description = "Failed when trying to find child object(s)."
551
+
552
+ end
553
+
554
+ TDriver.logger.behaviour(
555
+
556
+ "%s;%s;%s;%s;%s" % [ "FAIL", description, identity, dynamic_attributes[ :__multiple_objects ] ? "children" : "child", attributes.inspect ]
557
+
558
+ )
559
+
560
+ Kernel::raise exception
561
+
562
+
563
+ ensure
564
+
565
+ # restore original logger state
566
+ MobyUtil::Logger.instance.pop_enabled
567
+
568
+ end
569
+
570
+ # return child test object
571
+ child_test_object
572
+
573
+ end
574
+
575
+ =end
576
+
577
+ # == description
578
+ # Creates a child test object of this test object. Caller object will be associated as child test objects parent.\n
579
+ # \n
580
+ # [b]NOTE:[/b] Subsequent calls to TestObject#child( rule ) always returns reference to same Testobject:\n
581
+ # [code]a = to.child( :type => 'Button', :text => '1' )
582
+ # b = to.child( :type => 'Button', :text => '1' )
583
+ # a.eql?( b ) # => true[/code]
584
+ # == arguments
585
+ # attributes
586
+ # Hash
587
+ # description: Hash object holding information for identifying which child to create
588
+ # example: { :type => :slider }
589
+ #
590
+ # == returns
591
+ # MobyBase::TestObject
592
+ # description: new child test object or reference to existing child
593
+ # example: -
594
+ #
595
+ # == exceptions
596
+ # TypeError
597
+ # description: Wrong argument type %s for attributes (expected Hash)
598
+ #
599
+ # MultipleTestObjectsIdentifiedError
600
+ # description: raised if multiple objects found that match the given attributes
601
+ #
602
+ # TestObjectNotFoundError
603
+ # description: raised if the child object could not be found
604
+ #
605
+ # TestObjectNotVisibleError
606
+ # description: rasied if the parent test object is no longer visible
607
+ def child( attributes )
608
+
609
+ # verify attributes argument format
610
+ attributes.check_type( Hash, "Wrong argument type $1 for attributes (expected $2)" )
611
+
612
+ get_child_objects( attributes )
613
+
614
+ end
615
+
616
+ # == description
617
+ # Function similar to child, but returns an array of children test objects that meet the given criteria
618
+ #
619
+ # == arguments
620
+ # attributes
621
+ # Hash
622
+ # description: object holding information for identifying which child to create
623
+ # example: { :type => :slider }
624
+ #
625
+ # find_all_children
626
+ # TrueClass
627
+ # description: Boolean specifying whether all children under the test node or just immediate children should be retreived
628
+ # example: true
629
+ # FalseClass
630
+ # description: Boolean specifying whether all children under the test node or just immediate children should be retreived
631
+ # example: false
632
+ #
633
+ # == returns
634
+ # Array
635
+ # description: An array of test objects
636
+ # example: [ MobyBase::TestObject, MobyBase::TestObject, MobyBase::TestObject, ... ]
637
+ #
638
+ # == exceptions
639
+ # TypeError
640
+ # description: raised if agument is not a Hash
641
+ #
642
+ # TestObjectNotFoundError
643
+ # description: raised if the child object could not be found
644
+ #
645
+ # TestObjectNotVisibleError
646
+ # description: rasied if the parent test object is no longer visible
647
+ def children( attributes, find_all_children = true )
648
+
649
+ # verify attributes argument format
650
+ attributes.check_type( Hash, "Wrong argument type $1 for attributes (expected $2)" )
651
+
652
+ # verify find_all_children argument format
653
+ find_all_children.check_type( [ TrueClass, FalseClass ], "Wrong argument type $1 for find_all_children (expected $2)" )
654
+
655
+ # If empty or only special attributes then add :type => "any" to search all
656
+ attributes.merge!( :type => "any" ) if attributes.select{ | key, value | key.to_s !~ /^__/ ? true : false }.empty?
657
+
658
+ # children method specific settings
659
+ attributes.merge!( :__multiple_objects => true, :__find_all_children => find_all_children )
413
660
 
661
+ # disable optimizer state if enabled
662
+ disable_optimizer
663
+
664
+ # retrieve child objects
665
+ result = get_child_objects( attributes )
666
+
667
+ # restore optimizer state if it was enabled
668
+ enable_optimizer
669
+
670
+ # return results
671
+ result
672
+
673
+ end
674
+
675
+
676
+
677
+
678
+
679
+
680
+
681
+
682
+
683
+
684
+ =begin
414
685
  # == description
415
686
  # Function similar to child, but returns an array of children test objects that meet the given criteria
416
687
  #
@@ -442,10 +713,13 @@ module MobyBehaviour
442
713
  #
443
714
  # TestObjectNotVisibleError
444
715
  # description: rasied if the parent test object is no longer visible
445
- def children( attributes, find_all_children = true )
716
+ def children( attributes, find_all_children = true )
717
+
718
+ # verify attributes argument format
719
+ #raise TypeError.new( 'Unexpected argument type (%s) for attributes, expecting %s' % [ attributes.class, "Hash" ] ) unless attributes.kind_of?( Hash )
720
+ attributes.check_type( Hash, "Wrong argument type $1 for attributes (expected $2)" )
446
721
 
447
722
  # verify attributes argument format
448
- raise TypeError.new( 'Unexpected argument type (%s) for attributes, expecting %s' % [ attributes.class, "Hash" ] ) unless attributes.kind_of?( Hash )
449
723
 
450
724
  # respect the original attributes variable value
451
725
  creation_attributes = attributes.clone
@@ -456,34 +730,50 @@ module MobyBehaviour
456
730
  # children method specific settings
457
731
  creation_attributes.merge!( :__multiple_objects => true, :__find_all_children => find_all_children )
458
732
 
733
+ disable_optimizer
459
734
 
460
- disable_optimizer
461
735
  # retrieve child objects
462
736
  kids = get_child_objects( creation_attributes )
463
- enable_optimizer
464
737
 
738
+ enable_optimizer
465
739
 
466
- kids
740
+ kids
467
741
 
468
742
  end
743
+ =end
469
744
 
470
745
  private
471
746
 
472
- def disable_optimizer
473
- #disable optimizer for this call since it will not work
474
- @_enable_optimizer = false
475
- if MobyUtil::Parameter[ @sut.id ][ :use_find_object, 'false' ] == 'true' and @sut.methods.include?('find_object')
476
- MobyUtil::Parameter[ @sut.id ][ :use_find_object] = 'false'
477
- @_enable_optimizer = true
478
- end
479
- @_enable_optimizer
480
- end
481
-
482
- def enable_optimizer
483
- MobyUtil::Parameter[ @sut.id ][ :use_find_object] = 'true' if @_enable_optimizer
484
- @_enable_optimizer = false
485
- end
747
+ # TODO: document me
748
+ def disable_optimizer
749
+
750
+ sut_parameters = MobyUtil::Parameter[ @sut.id ]
751
+
752
+ # disable optimizer for this call since it will not work
753
+ @_enable_optimizer = false
486
754
 
755
+ if sut_parameters[ :use_find_object, 'false' ] == 'true' and @sut.respond_to?( 'find_object' )
756
+
757
+ sut_parameters[ :use_find_object ] = 'false'
758
+
759
+ @_enable_optimizer = true
760
+
761
+ end
762
+
763
+ @_enable_optimizer
764
+
765
+ end
766
+
767
+ # TODO: document me
768
+ def enable_optimizer
769
+
770
+ MobyUtil::Parameter[ @sut.id ][ :use_find_object ] = 'true' if @_enable_optimizer
771
+
772
+ @_enable_optimizer = false
773
+
774
+ end
775
+
776
+ # TODO: document me
487
777
  # Tries to use the missing method id as a child object type and find an object based on it
488
778
  def method_missing( method_id, *method_arguments )
489
779
 
@@ -512,6 +802,128 @@ module MobyBehaviour
512
802
 
513
803
  end
514
804
 
805
+ # helper function to retrieve child oblect(s), used by child and children methods
806
+ def get_child_objects( attributes )
807
+
808
+ ###############################################################################################################
809
+ #
810
+ # NOTICE: Please do not add anything unnessecery to this method, it might cause a major performance impact
811
+ #
812
+
813
+ # store original hash
814
+ creation_hash = attributes.clone
815
+
816
+ dynamic_attributes = creation_hash.strip_dynamic_attributes!
817
+
818
+ # raise exception if wrong value type given for ;__logging
819
+ dynamic_attributes[ :__logging ].check_type(
820
+
821
+ [ TrueClass, FalseClass ],
822
+
823
+ "Wrong value type $1 for :__logging test object creation directive (expected $2)"
824
+
825
+ ) if dynamic_attributes.has_key?( :__logging )
826
+
827
+ # disable logging if requested, remove pair from creation_hash
828
+ MobyUtil::Logger.instance.push_enabled( dynamic_attributes[ :__logging ] || TDriver.logger.enabled )
829
+
830
+ # check if the hash contains symbols as values and translate those into strings
831
+ translate!( creation_hash, attributes[ :__fname ], attributes[ :__plurality ], attributes[ :__numerus ], attributes[ :__lengthvariant ] )
832
+
833
+ begin
834
+
835
+ # TODO: refactor me
836
+ child_test_object = @test_object_factory.get_test_objects(
837
+
838
+ # current object as parent, can be either TestObject or SUT
839
+ :parent => self,
840
+
841
+ # test object identification hash
842
+ :object_attributes_hash => creation_hash,
843
+
844
+ :identification_directives => dynamic_attributes
845
+
846
+ )
847
+
848
+ rescue Exception => exception
849
+
850
+ if exception.kind_of?( MobyBase::MultipleTestObjectsIdentifiedError )
851
+
852
+ description = "Multiple child objects matched criteria."
853
+
854
+ elsif exception.kind_of?( MobyBase::TestObjectNotFoundError )
855
+
856
+ description = "The child object(s) could not be found."
857
+
858
+ elsif exception.kind_of?( MobyBase::TestObjectNotVisibleError )
859
+
860
+ description = "Parent test object no longer visible."
861
+
862
+ else
863
+
864
+ description = "Failed when trying to find child object(s)."
865
+
866
+ end
867
+
868
+ TDriver.logger.behaviour(
869
+
870
+ "%s;%s;%s;%s;%s" % [
871
+ "FAIL",
872
+ description,
873
+ identity,
874
+ dynamic_attributes[ :__multiple_objects ] ? "children" : "child",
875
+ attributes.inspect
876
+ ]
877
+
878
+ )
879
+
880
+ Kernel::raise exception
881
+
882
+ ensure
883
+
884
+ # restore original logger state
885
+ MobyUtil::Logger.instance.pop_enabled
886
+
887
+ end
888
+
889
+ # return child test object
890
+ child_test_object
891
+
892
+ end
893
+
894
+ # == nodoc
895
+ # Changes the status of the test object to inactive, also deactivating all children
896
+ # Removes reference from @parent TestObject or SUT to this TestObject so that
897
+ # @parent.refresh does not refresh currrent TestObject
898
+ #
899
+ # Does nothing if TestObject is already deactivated
900
+ # == returns
901
+ # ?
902
+ def deactivate
903
+
904
+ return if !@_active
905
+
906
+ @_active = false
907
+
908
+ # iterate through all test objects child test objects
909
+ @child_object_cache.each_object{ | test_object |
910
+
911
+ # deactivate test object
912
+ #test_object.deactivate
913
+
914
+ test_object.instance_exec{ deactivate }
915
+
916
+ }
917
+
918
+ # remove test objects from children objects cache
919
+ @child_object_cache.remove_objects
920
+
921
+ # remove from parent objects children objects cache
922
+ @parent.instance_variable_get( :@child_object_cache ).remove_object( self )
923
+
924
+ end
925
+
926
+
515
927
  # TODO: refactor logging_enabled
516
928
  # try to reactivate test object if currently not active
517
929
  def reactivate_test_object( attributes )
@@ -532,6 +944,7 @@ module MobyBehaviour
532
944
 
533
945
  end
534
946
 
947
+ =begin
535
948
  # Strip dynamic attributes (such as :__timeout, :__logging) from hash and return those as hash
536
949
  # == returns
537
950
  # Hash:: Hash of dynamic attributes
@@ -557,11 +970,9 @@ module MobyBehaviour
557
970
 
558
971
  def get_cached_test_object!( object )
559
972
 
560
- object_hash = object.hash
561
-
562
- if @_child_object_cache.has_key?( object_hash )
973
+ if @child_object_cache.has_object?( object )
563
974
 
564
- object = @_child_object_cache[ object_hash ]
975
+ object = @child_object_cache[ object ]
565
976
 
566
977
  true
567
978
 
@@ -572,7 +983,10 @@ module MobyBehaviour
572
983
  end
573
984
 
574
985
  end
986
+ =end
987
+
575
988
 
989
+ =begin
576
990
  def get_child_objects( attributes )
577
991
 
578
992
  # create copy of attributes hash
@@ -589,18 +1003,29 @@ module MobyBehaviour
589
1003
 
590
1004
  find_all_children = MobyUtil::KernelHelper.to_boolean( dynamic_attributes[ :__find_all_children ], true )
591
1005
 
592
- # check if the hash contains symbols as values and translate those into strings
593
- file_name = dynamic_attributes[ :__fname ]
594
- plurality = dynamic_attributes[ :__plurality ]
595
- numerus = dynamic_attributes[ :__numerus ]
596
- lengthvariant = dynamic_attributes[ :__lengthvariant ]
597
- translate!( creation_data, file_name, plurality, numerus, lengthvariant )
1006
+ # check if the hash contains symbols as values and translate those into strings
1007
+ file_name = dynamic_attributes[ :__fname ]
1008
+ plurality = dynamic_attributes[ :__plurality ]
1009
+ numerus = dynamic_attributes[ :__numerus ]
1010
+ lengthvariant = dynamic_attributes[ :__lengthvariant ]
1011
+
1012
+ translate!( creation_data, file_name, plurality, numerus, lengthvariant )
598
1013
 
599
1014
  # use custom timeout if defined
600
1015
  timeout = ( dynamic_attributes[ :__timeout ] || @test_object_factory.timeout ).to_i
601
1016
 
602
1017
  # determine which application to refresh
603
- application_id_hash = ( creation_data[ :type ] == 'application' ? { :name => creation_data[ :name ], :id => creation_data[ :id ] } : { :id => get_application_id } )
1018
+ #application_id_hash = ( creation_data[ :type ] == 'application' ? { :name => creation_data[ :name ], :id => creation_data[ :id ] } : { :id => get_application_id } )
1019
+
1020
+ if creation_data[ :type ] == 'application'
1021
+
1022
+ application_id_hash = { :name => creation_data[ :name ], :id => creation_data[ :id ] }
1023
+
1024
+ else
1025
+
1026
+ application_id_hash = { :id => get_application_id }
1027
+
1028
+ end
604
1029
 
605
1030
  # add symbols to dynamic attributes list -- to avoid IRB bug
606
1031
  MobyUtil::DynamicAttributeFilter.instance.add_attributes( creation_data.keys )
@@ -608,7 +1033,7 @@ module MobyBehaviour
608
1033
  begin
609
1034
 
610
1035
  # try to reactivate test object if currently not active
611
- reactivate_test_object( creation_data ) unless @_active
1036
+ #reactivate_test_object( creation_data ) unless @_active
612
1037
 
613
1038
  # retrieve test objects from xml
614
1039
  child_objects = @test_object_factory.make_child_objects(
@@ -638,7 +1063,9 @@ module MobyBehaviour
638
1063
  child_object.creation_attributes = creation_data
639
1064
 
640
1065
  # add child to objects cache
641
- add_child( child_object ) unless found_in_cache
1066
+ #add_child( child_object ) unless found_in_cache
1067
+
1068
+ @child_object_cache.add_object( child_object ) unless found_in_cache
642
1069
 
643
1070
  }
644
1071
 
@@ -683,6 +1110,7 @@ module MobyBehaviour
683
1110
  end
684
1111
 
685
1112
  end
1113
+ =end
686
1114
 
687
1115
  # Creates a string identifying this test object: sut, type, attributes used when created
688
1116
  #
@@ -695,72 +1123,102 @@ module MobyBehaviour
695
1123
 
696
1124
  end
697
1125
 
1126
+ # TODO: document me
1127
+ # NOTE: this method should be called only internally, TestObject#attribute is end-user method that shouldn't be called inside framework
698
1128
  def find_attribute( name )
699
1129
 
700
1130
  # store xml data to variable, due to xml_data is a function that returns result of xpath to sut.xml_data
701
- _xml_data = nil
702
- begin
703
- _xml_data = xml_data
704
- rescue MobyBase::TestObjectNotFoundError
705
- #lets refresh if not found initially
706
- refresh_args = ( @creation_attributes[ :type ] == 'application' ? { :name => @creation_attributes[ :name ], :id => @creation_attributes[ :id ] } : { :id => get_application_id } )
707
-
708
- refresh( refresh_args)
709
- _xml_data = xml_data
710
- end
1131
+ _xml_data = nil
711
1132
 
712
- # convert name to string if variable type is symbol
713
- name = name.to_s if name.kind_of?( Symbol )
1133
+ # note: tries count represents total number of tries
1134
+ MobyUtil::Retryable.while( :tries => 2, :interval => 0 ) { | attempt |
714
1135
 
715
- # raise exception if attribute name variable type is other than string
716
- Kernel::raise ArgumentError.new( "Wrong argument type %s for attribute argument (expected String)" % name.class ) unless name.kind_of?( String )
1136
+ begin
1137
+
1138
+ begin
717
1139
 
718
- # raise eception if xml data is empty or nil
719
- Kernel::raise MobyBase::TestObjectNotInitializedError.new if _xml_data.nil? || _xml_data.to_s.empty?
1140
+ # retrieve xml data, performs xpath to sut xml_data
1141
+ _xml_data = xml_data
720
1142
 
721
- # retrieve attribute(s) from xml
722
- #nodeset = _xml_data.xpath( "attributes/attribute[translate(@name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='%s']" % name.downcase )
723
- nodeset = _xml_data.xpath( "attributes/attribute[translate(@name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='#{ name.downcase }']" )
1143
+ rescue MobyBase::TestObjectNotFoundError
724
1144
 
725
- # raise exception if no such attribute found
726
- Kernel::raise MobyBase::AttributeNotFoundError.new( "Could not find attribute '%s' for test object of type '%s'." % [ name, type ] ) if nodeset.empty?
1145
+ # attributes used to refresh parent application
1146
+ if @creation_attributes[ :type ] == 'application'
727
1147
 
728
- # Need to disable this for now #Kernel::raise MobyBase::MultipleAttributesFoundError.new( "Multiple attributes found with name '%s'" % name ) if nodeset.count > 1
1148
+ # use application name and id attributes
1149
+ refresh_args = { :name => @creation_attributes[ :name ], :id => @creation_attributes[ :id ] }
729
1150
 
730
- # return found attribute
731
- nodeset.first.content.strip
1151
+ else
732
1152
 
733
- end
1153
+ # test object if not type of application
1154
+ refresh_args = { :id => get_application_id }
734
1155
 
735
- # this method will be automatically invoked after module is extended to sut object
736
- def self.extended( target_object )
1156
+ end
737
1157
 
738
- target_object.instance_exec{
1158
+ #lets refresh if attribute not found on first attempt
1159
+ refresh( refresh_args )
739
1160
 
740
- initialize_settings
1161
+ # retrieve updated xml data
1162
+ _xml_data = xml_data
741
1163
 
742
- }
1164
+ end
743
1165
 
744
- end
1166
+ # raise eception if xml data is empty or nil
1167
+ Kernel::raise MobyBase::TestObjectNotInitializedError.new if _xml_data.nil? || _xml_data.to_s.empty?
1168
+
1169
+ begin
1170
+
1171
+ # retrieve attribute(s) from test object; never access ui state xml data directly from behaviour implementation
1172
+ TDriver::TestObjectAdapter.test_object_attribute( _xml_data, name )
745
1173
 
746
- def initialize_settings
1174
+ rescue MobyBase::AttributeNotFoundError
1175
+
1176
+ Kernel::raise MobyBase::AttributeNotFoundError.new(
1177
+
1178
+ "Could not find attribute #{ @name.inspect } for test object of type #{ @type.to_s }"
1179
+
1180
+ )
747
1181
 
748
- # defaults
749
- @_application_id = nil
750
- @creation_attributes = nil
1182
+ end
1183
+
1184
+ rescue MobyBase::AttributeNotFoundError
1185
+
1186
+ # add attribute to attribute filter whitelist only once
1187
+ if ( attempt == 1 )
1188
+
1189
+ # add to attribute filter
1190
+ MobyUtil::DynamicAttributeFilter.instance.add_attribute( name )
751
1191
 
752
- @_child_object_cache = {}
1192
+ # refresh test object ui state
1193
+ refresh
753
1194
 
754
- activate
1195
+ end
1196
+
1197
+ # raise exception and retry if attempts left
1198
+ raise
1199
+
1200
+ end
1201
+
1202
+ }
755
1203
 
756
1204
  end
757
1205
 
758
- # == description
759
- # Returns the actual test object that was used as the parent when this object instance was created. For getting the parent object in the UI object hierarchy,
760
- # see get_parent.
761
- #
762
- # == returns
763
- # TestObject:: test object that was used as parent when this object was created. Can also be of type SUT if sut was the parent (ie. application objects)
1206
+ # this method will be automatically invoked after module is extended to sut object
1207
+ def self.extended( target_object )
1208
+
1209
+ target_object.instance_exec{
1210
+
1211
+ # initialize cache object
1212
+ @child_object_cache = TDriver::TestObjectCache.new
1213
+
1214
+ # defaults
1215
+ @_application_id = nil
1216
+ @creation_attributes = nil
1217
+ @_active = true
1218
+
1219
+ }
1220
+
1221
+ end
764
1222
 
765
1223
  public
766
1224
 
@@ -773,6 +1231,14 @@ module MobyBehaviour
773
1231
  #
774
1232
  def parent_object()
775
1233
 
1234
+ # == description
1235
+ # Returns the actual test object that was used as the parent when this object instance was created.
1236
+ # Userd to retrieve the parent object in the UI object hierarchy,
1237
+ # see get_parent.
1238
+ #
1239
+ # == returns
1240
+ # TestObject:: test object that was used as parent when this object was created. Can also be of type SUT if sut was the parent (ie. application objects)
1241
+
776
1242
  $stderr.puts "warning: TestObject#parent_object is deprecated, please use TestObject#parent instead."
777
1243
 
778
1244
  @parent