1

I want to use RFT to automate few operations on a webpage. I went through some links and codes and i tried just to open a browser say google using script in RFT.

I took some code, but thats not doing the job of opening a google page on a open browser.

I dont know if there is some setting required? Can anyone help me with this?

The code i have is:::

import resources.Script1Helper;
import com.rational.test.ft.*;
import com.rational.test.ft.object.interfaces.*;
import com.rational.test.ft.object.interfaces.SAP.*;
import com.rational.test.ft.object.interfaces.WPF.*;
import com.rational.test.ft.object.interfaces.dojo.*;
import com.rational.test.ft.object.interfaces.siebel.*;
import com.rational.test.ft.object.interfaces.flex.*;
import com.rational.test.ft.object.interfaces.generichtmlsubdomain.*;
import com.rational.test.ft.script.*;
import com.rational.test.ft.value.*;
import com.rational.test.ft.vp.*;
import com.ibm.rational.test.ft.object.interfaces.sapwebportal.*;


public class Script1 extends Script1Helper
{
ProcessTestObject pto = startBrowser("www.google.com");
}
nisha
  • 703
  • 2
  • 14
  • 28

1 Answers1

2

In RFT you can use startBrowser API as follows:

startBrowser("http://wwww.google.com"); //To launch google.com with default browser    

startBrowser("Internet Explorer","http://www.google.com");//To open google with internet explorer.Internet Explorer is the string that identifies the browser , it could be Mozialla Firefox and should be configured in the Enable Environment for testing wizard(in the browser tab)    

RFT also provides api loadUrl("urlstring") on the BrowserTestObject for eg:

 browser_htmlBrowser().loadUrl("http://www.google.com");//Here browser_htmlBrowser comes from the Object Map.

The above code will load google.com after first finding the browser test object.

You can also use Find() api to first find an existing browser and then all loadUrl() just like above. eg:

    TestObject[] browsers = find(atChild(".class","Html.HtmlBrowser"));
    if(browsers.length == 0)
    {
        System.err.println("No browsre found");
        return;
    }
    //Else take the first found object(browser) and load the url

    ((BrowserTestObject)browsers[0]).loadUrl("http://www.google.com");

    unregister(browsers);//Always clean up by calling unregister once done with the objects.

Hope that helps.

Prakash
  • 742
  • 7
  • 19
  • Hi Prakash,But yet this does not open a browser and type google on the url though the TC runs fine without any error but i want to see this happening on running the script.How can i do that? Is there any configuration setting that i am missing? – nisha Nov 14 '12 at 20:15
  • Hi, startBrowser("http://google.com"); would launch the default browser which is configured in the [Configure -> Enable Environment for Testing] . The scripts usually would execute the given statement and finish and depending on the code executed it may wait for some object to perform action. You may give some sleep after startBrowser() to let the browser load. In the sample script give above there is no code that "types google on the url" it simply launches the browser with the given url. – Prakash Nov 15 '12 at 15:48