テスト・オブジェクトの検索

Rational Functional Tester では、指定した検索条件と一致する 1 つ以上の TestObjects を検索する方法がサポートされています。探索対象の 1 つ以上の TestObject のプロパティーを表す名前/値のペアに基づいて、検索が行われます。 検索は、グローバルに行うこともでき、親 TestObject の子に制限することもできます。

Rational Functional Tester は、テスト対象ソフトウェアのグローバル・ビューを表す RootTestObject をサポートしています。一括検索を実行するには、RootTestObject に関する検索メソッドを呼び出します。 TestObject 検索メソッドを呼び出すと、TestObject の子のみ検索されます。

検索メソッドの最初の引数は、検索プロパティーの副項目です。2 つ目のオプション引数は、テスト・オブジェクト・マップに組み込まれている子のみ検索する必要があるかどうかを示すフラグです。プロパティーの副項目の有効な値は以下のとおりです。

RootTestObject.find に適用される特殊なプロパティーは、以下のとおりです。

例:
TestObject[] foundTOs ;
RootTestObject root = RootTestObject.getRootTestObject() ;
// Find all toplevel windows in the Windows domain with caption "My
// Document"
CaptionText caption = new CaptionText("My Document") ;
foundTOs = root.find(atChild(".domain", "Win", ".caption",
     caption)) ;

// Find any dialogs, then return their children
// "OK" buttons.
RegularExpression dialogRE = new
     RegularExpression("*dialog", false) ;
RegularExpression buttonRE = new
     RegularExpression("*button", false) ;
foundTOs = root.find(atList(atDescendant(".class",
                     dialogRE), 
                     atChild(".class", buttonRE,".value", 
                     "OK"))) ;

// Start Notepad, dynamically enable that process,
// find its top-level window that matches the process id
// and get its descendant text window.
	ProcessTestObject p1 = StartApp("Notepad") ;
	Integer pid = new Integer((int)p1.getProcessId()) ;
	foundTOs = root.find(atList(atProperty(".processId",
     pid), atDescendant(".class", ".text"))) ;
 
// This enables a Windows app with the provided window handle and returns a
// TestObject representing the window.
Long hWnd = getAppsHwnd();
foundTOs = root.find(atChild(".hwnd", hWnd, ".domain", "Win"));

// This enables a .NET app with the provided window handle and returns a
// TestObject representing the window.
Long handle = getAppsHwnd();
foundTOs = root.find(atChild("Handle", handle, ".domain", "Net"));

Windows および .NET アプリケーションは Rational Functional Tester によって動的に使用可能にされます。これらのアプリケーションを使用可能にするために使用されるプロパティーは .processName です。Windows または .NET アプリケーションで必須のテスト・オブジェクトを検索するには、クエリーで .processName を使用します。

例: 以下のサンプル・コードは、電卓のボタン 9 を探し、それをクリックするものです。
 Property[] props = new Property[4];
        // find toplevel window of calculator app
        props[0] = new Property(".processName", "calc.exe");
        props[1] = new Property(".class","SciCalc");
        props[2] = new Property(".name", "Calculator");
        props[3] = new Property(".text", "Calculator");
        TestObject[] tos = find(atChild(props));
       
        if(tos.length > 0)
        {
            // find button with text 9
            props = new Property[3];
            props[0] = new Property(".class","Button");
            props[1] = new Property(".name", "9");
            props[2] = new Property(".text", "9");
            TestObject[] tos9 = tos[0].find(atChild(props));

            if(tos9.length > 0)
            {
                // Click button 9
                ((GuiTestObject)tos9[0]).click();
            }
        }

フィードバック