Showing posts with label RFT. Show all posts
Showing posts with label RFT. Show all posts

Simple RFT script to test Google home page

Here is Simple dynamic RFT script which will launch a browser and then opens google home page and enters some thing in the search text box and searches for the same ...
Here is the RFT code to make it work

public void testMain(Object[] args)
    {
        startBrowser("http://google.co.in");
        sleep(25);
        TestObject[] to = getRootTestObject().find(
                atDescendant(".class","Html.INPUT.text",".title","Google Search"));
        // print dialog test object properties to console
        /*for (int i = 0; i < to.length; i++) {
           System.out.println (to[i].getProperties());
        }*/
        GuiTestObject contactLink = new GuiTestObject(to[0]);
        contactLink.click();
        BrowserTestObject b = findBrowser();
        b.inputChars("How to use RFT find method");
        TestObject[] to1 = getRootTestObject().find(
                atDescendant(".class","Html.INPUT.submit",".value","Google Search"));
        GuiTestObject searchButton = new GuiTestObject(to1[0]);
        searchButton.click();
        sleep(20);
        b.close();
    }
    private BrowserTestObject findBrowser(){
        TestObject[] foundTOs = find(atDescendant(".class", "Html.HtmlBrowser"));
        BrowserTestObject browser = (BrowserTestObject) foundTOs[0];
        return browser;
    }
}