IBM RFT – Descriptive Programming – Iteratively finding object in the application with time out.
In RFT we have waitforExistence() method to wait till the
application loads and object appears, but some time if the application itself
is not loaded, RFT waits for an indefinite time, and execution does not
proceeds. To overcome this issue we can find the object iteratively in application
considering some Timeout duration defined in Frameworks Environment Variable
file.
public TestObject[] find_object_iteratively (TestObject root_object,
String [] elem_attribute_name, String [] elem_attribute_value)
{
int
timeout=0;
double
sleep_time=0.1;
double
timeout_wait= 20.0; // this is hard coded value can be retrived from
environment variable file.
TestObject[]
reqObjects = root_object.find(atDescendant(elem_attribute_name[0].toString(),elem_attribute_value[0].toString(),elem_attribute_name[1].toString(),elem_attribute_value[1].toString()),
false);
while
(reqObjects.length == 0)
{
sleep(sleep_time);
timeout++;
reqObjects
= root_object.find(atDescendant(elem_attribute_name[0].toString(),elem_attribute_value[0].toString(),elem_attribute_name[1].toString(),elem_attribute_value[1].toString()),
false);
if
(timeout>=timeout_wait) {
timeout=0;break;
}
}
if
(html_element.length == 0)
{
logTestResult
("Object with Properties
:"+elem_attribute_name[0].toString()+":"+elem_attribute_value[0].toString()+","+elem_attribute_name[1].toString()+":"+elem_attribute_value[1].toString()+
" Not found in the screen",false);
return
null;
}
else
{
logTestResult
("Object with Properties
:"+elem_attribute_name[0].toString()+":"+elem_attribute_value[0].toString()+","+elem_attribute_name[1].toString()+":"+elem_attribute_value[1].toString()+
" found in the screen",true);
return
reqObjects;
}
}
No comments:
Post a Comment