I am writing an RFT script using java.
I wanted to know if there is any way in which we can write a java code in script for searching a particular string in the webpage and recognize that object and then click on it.
I am writing an RFT script using java.
I wanted to know if there is any way in which we can write a java code in script for searching a particular string in the webpage and recognize that object and then click on it.
To find a test object dynamically, you can use the TestObject.find()
method. If you have some object in your object map which is a parent object of the object to find (e.g. a document object), you can use this example:
TestObject[] found = document().find(atDescendant(".text", "your particular string"));
GuiTestObject yourLink = (GuiTestObject)found[0];
yourLink.click();
Alternatively you can get all links on the page and do something with them:
TestObject[] links = document().find(atDescendant(".class", "Html.A"));
for (TestObject link : links)
if (link.getProperty(".text").toString().equals("your string"))
((GuiTestObject)link).click();
You can find more information about the find method in this article on the IBM developerWorks page.