简体   繁体   中英

IBM Rational Functional Tester Java

I am new to RFT and Java coding and I was trying to automate a web based application using IBM-RFT tool with Java. I have to click on a link within my HTML table cell. While playback it was able to click on links for some cells but for some it wasn't and was clicking above or below the hyperlink in the cell. It is able to recognize the link object and print out its properties like ".text", ".href" but while clicking it clicks on blank space within the cell instead of clicking on the link and this happens for some cells only.:( Is there any better way to handle this? Appreciate anyone's help on this.

TestObject[] tablename = root.find(atDescendant(".class", "Html.TABLE", ".id", table_name), true);
GuiTestObject tablename_obj=(GuiTestObject)tablename[0];
TestObject cellObj = tablename_obj.find(atList(atChild(".class" , "Html.TBODY"),atChild(".class" , "Html.TR",".rowIndex", row),atChild(".class" , "Html.TD",".cellIndex",col)), false)[0];
TestObject cellObjClick = cellObj.find(atDescendant(".class","Html.A"))[0];
((GuiTestObject)cellObjClick).click();

Please help!

I can try to give you some clues. The .click() method calculates the center of the object as the click point. Since you can get the .href property and it is correct, then you know you have the link you want to click on. It could be that somthing about the extent of the object (the rectangle surrounding the object that is used to calculate points within the object) is somehow incorrect coming from the DOM. It could be that the click point calculated does not actually click on any part of the link in the UI. Instead of .click(), you could try using a speciic x, y coordinate for the link object. Note the coordinate is relative to the upper left corner of the object. So you could try .click(atPoint(x,y)), choosing some value (pixels) for the x, y coordinate and see if you have any better luck. You could also try getting the rectangle of the link (the extent) fist to see if that looks correct. I have sometimes used .click(atPoint(1,1)). I'm not sure you can see the rectangle of the object in it's properties, using the object explorer in RFT (you could try this).

I prefer using SelectGuiSubItem like the example below sometimes to click ((SelectGuiSubitemTestObject) textObj).select("<>");

Try that out instead of a click()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM