Rational Functional Tester는 테스트 중인 소프트웨어의 전체적 뷰를 제시하는 RootTestObject를 지원합니다. 글로벌 검색을 수행하려면 RootTestObject에서 찾기 메소드를 호출합니다. TestObject 찾기 메소드를 호출하면 TestObject의 하위만을 검색합니다.
찾기 메소드의 첫 번째 인수는 검색 특성의 부속 항목입니다. 두 번째 선택적 인수는 테스트 오브젝트 맵에 포함될 수 있는 하위만을 검색해야 하는지 표시하는 플래그입니다. 특성 부속 항목에 올바른 값은 다음과 같습니다.
다음을 포함하여 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을 사용하십시오.
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();
//unregister
tos9[0].unregister();
}
}