Búsqueda de objetos de prueba

Rational Functional Tester soporta una forma de ubicar uno o varios TestObjects que coincidan con criterios de búsqueda especificados. La búsqueda se basa en pares de nombre/valor que representan las propiedades de TestObject o TestObjects que busca. La búsqueda puede ser global o limitarse a hijos de un padre TestObject.

Rational Functional Tester soporta un RootTestObject que representa una vista global del software que se está sometiendo a prueba. Para efectuar una búsqueda global, invoque al método de búsqueda en RootTestObject. Si invoca al método de búsqueda TestObject, sólo se buscarán los hijos de dicho TestObject.

El primer argumento del método de búsqueda es un subelemento para las propiedades de búsqueda. El segundo argumento opcional es un distintivo que indica si sólo se deben buscar los hijos que podrían estar incluidos en la correlación de objetos de prueba. Los valores válidos para los subelementos de propiedad son:

Existen propiedades especiales que se aplican a RootTestObject.find, incluidas:

Ejemplos:
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"));

Las aplicaciones Windows y .NET se habilitan dinámicamente mediante Rational Functional Tester y la propiedad utilizada para habilitar estas aplicaciones es .processName. Para encontrar el objeto de prueba necesario en una aplicación Windows o .NET, utilice .processName en la consulta.

Ejemplo: el ejemplo de código siguiente sirve para buscar el botón 9 en una calculadora y pulsarlo.
 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();
            }
        }

Comentarios