1

While executing my script in RFT, my script got failed due to the slight position change of a button. (This button's position slightly changes according to the option selected for previous combo box due to the label appearing near the button) As there are 2 positions for this button in window, one of my script fails while other passes. Please suggest how to identify this same object in 2 different places in RFT?

Machavity
  • 30,841
  • 27
  • 92
  • 100
Nim92
  • 11
  • 1
  • 2

3 Answers3

1

If you're alright with not using pre-mapped values and instead work with objects directly in code (which I've personally found to be extremely useful... it's allowed me to do great and wondrous things with RFT :), the following ought to work fine:

private void clickObject(String uniqueIdentifier) {

    // Find object
    RootTestObject root = RootTestObject.getRootTestObject();
    TestObject[] matchingObjs = root.find(atProperty(".id", uniqueIdentifier));

    if (matchingObjs.length > 0) {
        // Click the object
        ((GuiTestObject) matchingObjs[0]).click();
    }

    // Clean-up
    unregister(matchingObjs);
}

Feel free to replace ".id" with whatever property is best suited for the situation... since I work primarily with a web application, the ".id" property has worked splendidly for me.

Because the method finds the object anew each time, it'll grab the object's position wherever it's at at the time the method's called. The clean-up will also prevent any weird, horrible, and otherwise unfortunate UnregisteredObjectExceptions from cropping up.

  • I agree that fleeing from creating TestObjects in the interface to work with them directly in code will make your test scripts much more sane and robust. You must work with your developers to make them put ids in every screen element. – neves Mar 16 '16 at 19:15
0

Without looking at your pages I cannot be sure, but I think the buttons are actually two different buttons. Maybe they are generated by javascript, or they are just un-hidden after the option you select in the combobox.

If they are two different buttons (record them both and look at the recognition properties) you can either replace some properties with a regular expression or check wich button is visible/exists and then click it:

if (btn_button1.exists()) {
    btn_button1.click();
} else if (btn_button2.exists()) {
    btn_button1.click();
}

Here's a more complete tutorial on Object Recognition.

Alessandro Da Rugna
  • 4,571
  • 20
  • 40
  • 64
  • Alessandro, thanks! But they are not different buttons. What happens is for the first combo box option, there's no description appearing with a label. So, the button is in 1 position.(This is what i recorded) But when I select second combo box option, a label appears with selected option's description. To give space for this label, button slightly moves down. Hence the position changes & it's doesn't identify by RFT. – Nim92 Nov 14 '13 at 09:52
  • @Nim92 Have you tried recording the button again? Are you 100% sure it is the exact same button? See where RFT "thinks" the button is using this code: http://www-01.ibm.com/support/docview.wss?uid=swg21402481 (will show a red rectangle around the button), or just right click it in RFT and select "highlight". If the highlight rectangle is misplaced you need somehow to "refresh" the object. Another good idea would be to dynamically find it after the selection instead of recording it. – Alessandro Da Rugna Nov 14 '13 at 10:02
  • The tutorial link is broken – neves Nov 23 '15 at 21:17
0

You can increase the tolerance of Rational Performance Tester AssureScript in the properties tab or you could set the description but hide the value. You can also make a custom code that updates the object map to prepare for this change in a java IF structure