1

RFT を使用して、Web ページでのいくつかの操作を自動化したいと考えています。私はいくつかのリンクとコードを調べて、RFTでスクリプトを使用してGoogleと言うブラウザを開こうとしました。

私はいくつかのコードを取りましたが、それは開いているブラウザーで Google ページを開くという仕事をしていません。

設定が必要かどうかわかりませんか?誰でもこれで私を助けることができますか?

私が持っているコードは:::です

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");
}
4

1 に答える 1

2

RFT では、次のように startBrowser API を使用できます。

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 は、次のような BrowserTestObject で api loadUrl("urlstring") も提供します。

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

上記のコードは、最初にブラウザー テスト オブジェクトを見つけた後に google.com を読み込みます。

Find() API を使用して、最初に既存のブラウザーを検索し、次にすべての loadUrl() を上記のように検索することもできます。例えば:

    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.

それが役立つことを願っています。

于 2012-11-09T06:08:45.597 に答える