Documente Academic
Documente Profesional
Documente Cultură
WHITE PAPER
On
IMPLIMENTING REGION IMAGE COMPARISION V1.0 IN RFT 7.0.0:
Extending Functional Tester functionality using java scripting
KRISHNAKANT VISHWAKARMA
(krishnakant27@yahoo.com)
WHITE PAPER
On
IMPLIMENTING REGION IMAGE COMPARISION V1.0 IN RFT 7.0.0:
Extending Functional Tester functionality using java scripting
Introduction
RFT is one of the best automation testing tool that IBM has given to the software testing
industry .I have seen many blogs ,forums ,web sites for article ,questions ,differences or
features of RFT with respect to other tools . The only thing which is highlighted is “RFT
doesn't have IMAGE COMPARISION verification point (VP)”.
But the best thing about RFT is tool limitation is not the tester's limitation. This is
because of RTS (Rational Test Script) framework.
This paper also focuses on how RTS eases a tester's job in test development phase for
automation testing by providing the JAVA power with Eclipse IDE for RFT .How easily
Functional Tester functionality can be extend to implement image comparison VP in the
script.
Let's first see why this verification is so much of interest to an automation test engineer.
1. Sometimes tool is not able to recognize the object because of that one is not able
to validate the state of that object through any of the verification point. At this
time every action performed on the object (while recording) the information is
stored in terms of screen coordinates in the test script.
At this point IMAGE COMPARISION verification point comes into picture. This
doesn't need exact object reference to object map to capture image of that
particular unrecognized object.
We want to convert a statement of manual test case into automated test script:
It simply means either tool is not able to capture/recognize the object or there
can be some problem with the application itself which is stopping us to
automate STEP 3.
Here a simple solution is to put region image verification point and capture the
region of the screen containing “Quantity:” edit box.
Let's see what happens when we perform some action on such objects.
STEP 10: On Member Logon window Select New Customer radio button.
memberLogon().click(atPoint(80,100));
ok().click();
Listing 1.0: showing recording (when tool is not able to recognize New
Customer radio button)
newCustomer().click();
ok().click();
Listing 1.1: showing recording (when tool is able to recognize New Customer
radio button)
This reveals that even if tool fails to recognize a particular object , action
performed on it are recorded as low level actions in terms of screen coordinates
with reference to the parent test object.
2. One case would be that when we actually want to have IMAGE COMPARISION a
possible case may be client's logo, or any image. Here we need to compare pixel
by pixel between expected and actual.
MAIN IDEA:
Basic principle:
Get coordinate information of the region of interest. Call custom methods created in the
Helper Super class and provide the recorded coordinate information. This method uses
some methods from a plain JAVA class called Robot class (Thanks to SUN developers to
show special interest for testers also).
There are two important method which I have used one to capture image and another is
to compare it.
Play it. See the log for comparison result or result of region image verification point.
Implementation:
Assumptions and scenario considered:
• The project has super_image_comparator Helper Super Class defined in the
separate folder.
• We need to validate that the place order button in old built (classicsJavaA) is
present at the same location in next built (classicsJavaB).
There are eight basic steps to be followed for implementing Region Image Verification
Point.
STEP 4: Move mouse pointer to position just above the left corner of the target object
press left button of mouse drag it to just below the right corner of the targeted object
(As shown in fig 1.0).Such that recording monitor shows code like listing 1.2.
Fig 1.0: Showing how to capture image for region image verification point.
classicsJava().dragToScreenPoint(atPoint(384,292),
toScreenPoint 539, 361));
listing1.2: Showing the recorded action after STEP 4 on the Recording monitor window.
STEP 6: Repeat STEP 3 AND STEP 4 for classicsJavaB application. Stop recording .And see
the recorded script, it should look something like listing 1.3:
startApp("ClassicsJavaA");
// Frame: ClassicsCD
classicsJava().dragToScreenPoint(atPoint(384,292),
toScreenPoint(539, 361));
classicsJava(ANY,MAY_EXIT).close();
startApp("ClassicsJavaB");
classicsJava(ANY,MAY_EXIT).close();
Listing 1.3: Showing the recorded action after STEP 6 on the java editor of RFT .
startApp("ClassicsJavaA");
sleep(4);
// Frame: ClassicsCD
/*classicsJava().dragToScreenPoint(atPoint(384,292),
* toScreenPoint(539, 361));
*/
classicsJava(ANY,MAY_EXIT).close();
sleep(3);
startApp("ClassicsJavaB");
sleep(5);
// Frame: ClassicsCD
classicsJava(ANY,MAY_EXIT).close();
try {
} catch (Exception e) {
System.err.println(e);
Listing 1.4: Showing the modification to be done in recorded script after STEP 6.
STEP 8: Play it. And see the log for result (log result for this script is shown in fig 1.2):
Fig 1.2: log showing expected image, actual image, result of verification point, and
comparator result output image (notice the additional_info which shows why
verification point failed and what the warning threshold was also notice the red marks
on the result image which shows difference in actual from expected)
Ø Variables passed :4
• GuiTestObject o:
• int i:
• int j:
• int k:
• int l:
Ø Variables returned:1
• Long ex:
2. capture_actual ()
Ø Variables passed :4
• GuiTestObject o:
• int i:
• int j:
• int k:
• int l:
Ø Variables returned:1
• Long ac:
3. compare()
Ø Variables passed :5
• long ex:
• long ac:
• int min:
• int max:
• boolean only_diff:
Ø Variables returned:1
• boolean result:
Features:
1. Pixel by pixel comparison: even if there is small change in brightness or
contents such as text, it will be notified in the log (provided proper
warning threshold is set) .
5. With the help of Helper Super Class front end (functional test script) is
easily modified in the specified way .I.e. it is easy to use. A tester
doesn't have to bother about Helper Super Class.
7. Log file is used as to show the images expected, actual, comparison result
output, which can be viewed any time from the project explorer log.
Limitations:
1. Sensitive to screen coordinates: if in next built same window appears at
different position the comparison fails.
2. It is not always possible to left click or right click or drag mouse to capture
the screen coordinates of the target area.
Conclusion:
1. RFT provides JAVA power because of which tool limitation is not the
tester's limitation.
2. RTS is rich of pre defined custom JAVA methods which helps tester to
test whatever he needs.
3. This idea has got limitation but still region image verification point can be
implemented which can solves a testers problem at major extent.