You can change your Test Objects slightly. Edit the value of Property ‘package’ and ‘resource-id’ to have ${packageName} — this notation expresses a place holder to be interpolated with value specified runtime. See the following example:
You create a GlobalVariable named G_packageName with any value you want:
Finally, your test case will interpolate the ${packageName} with the GlobalVariable value.
TestObject tObjInterpolated = findTestObject(
'Object Repository/Application/android.widget.TextView - App - parameterized resource-id',
[('packageName'): GlobalVariable.G_packageName]
)
I printed the test object before interpolation. It was like this:
[
{"name":"class","condition":"equals","value":"android.widget.TextView","isActive":true},
{"name":"instance","condition":"equals","value":"3","isActive":true},
{"name":"text","condition":"equals","value":"App","isActive":true},
{"name":"resource-id","condition":"equals","value":"${packageName}:id/text1","isActive":true}
]
I printed the test object after interpolation. It was like this:
[
{"name":"class","condition":"equals","value":"android.widget.TextView","isActive":true},
{"name":"instance","condition":"equals","value":"3","isActive":true},
{"name":"text","condition":"equals","value":"App","isActive":true},
{"name":"resource-id","condition":"equals","value":"com.packagename:id/text1","isActive":true}
]
Sravya,
I think the test object after interpolation would work for you.
But you wrote:
It would be very helpful if there is any way to bind global variable directly in test object property instead following the parametrized test object procedure to access the global variable.
I am not sure what you mean here. Don’t you find the above mentioned approach satisfactory for you?
parameterized_resource-id.png
G_packageName.PNG