Functional Tester 支援以 RootTestObject 來表示測試中軟體的廣域視圖。若要執行廣域搜尋,請在 RootTestObject 上呼叫 find 方法。呼叫 TestObject find 方法只會搜尋此 TestObject 的子項。
find 方法的第一個引數是搜尋內容的子項目。第二個選用引數是旗標,指出是否只搜尋可能併入測試物件對映中的子項。內容子項目的有效值如下:
有一些特殊內容適用於 RootTestObject.find,包括:
範例:
TestObject[] foundTOs ;
RootTestObject root = RootTestObject.getRootTestObject() ;
// 在 Windows 網域中尋找標題為 "My Document"
// 的所有 toplevel 視窗
CaptionText caption = new CaptionText("My Document") ;
foundTOs = root.find(atChild(".domain", "Win", ".caption",
caption)) ;
// 尋找任何對話框,然後傳回子項
// "OK" 按鈕。RegularExpression dialogRE = new
RegularExpression("*dialog", false) ;
RegularExpression buttonRE = new
RegularExpression("*button", false) ;
foundTOs = root.find(atList(atDescendant(".class",
dialogRE),
atChild(".class", buttonRE,".value",
"OK"))) ;
// 啟動「記事本」,動態啟用該程序,
// 然後尋找符合程序 ID 的頂層視窗,
// 並取得衍生的文字視窗。 ProcessTestObject p1 = StartApp("Notepad") ;
Integer pid = new Integer((int)p1.getProcessId()) ;
foundTOs = root.find(atList(atProperty(".processId",
pid), atDescendant(".class", ".text"))) ;
// 以提供的視窗控點來啟用 Windows app,並傳回
// 代表視窗的 TestObject。Long hWnd = getAppsHwnd();
foundTOs = root.find(atChild(".hwnd", hWnd, ".domain", "Win"));
// 以提供的視窗控點來啟用 .NET app,並傳回
// 代表視窗的 TestObject。Long handle = getAppsHwnd();
foundTOs = root.find(atChild("Handle", handle, ".domain", "Net"));