Búsqueda de TestObjects de SAP

Functional Tester soporta una forma de ubicar uno o varios TestObjects de SAP haciendo coincidir un criterio de búsqueda especificado, incluso sin utilizar la Correlación de objetos.

Functional Tester soporta un RootTestObject que representa una vista global del software que se está probando. Para habilitar la prueba de la aplicación SAP, invoque al método enableForTesting en RootTestObject. Para efectuar una búsqueda global, invoque al método de búsqueda en RootTestObject. Los valores válidos para el subelemento, que es el primer argumento del método de búsqueda, incluyen atProperty, atChild, atDescendant, y atList. Existen propiedades especiales que se aplican a RootTestObject.find, incluyendo .processName, .processID, .domain, etc. Puede utilizar cualquiera de estos subelementos y propiedades. Por ejemplo, puede utilizar el subelemento atChild con la propiedad .domain establecida en SAP para buscar el dominio SAP.

Nota: Consulte la documentación SAP GUI Script Framework para obtener más información sobre la Jerarquía de tiempo de ejecución de la GUI de SAP.

Una vez haya encontrado y devuelto el objeto de prueba de SAP de nivel superior, podrá utilizar dicho objeto para buscar varios objetos de la jerarquía de tiempo de ejecución de la GUI de SAP. Por ejemplo:

Una vez tenga el objeto de ventana activa, puede utilizar el método GetChildren del objeto de prueba de la ventana principal para buscar e interactuar con varios objetos en GuiMainWindow.

A continuación encontrará un ejemplo de cómo establecer interacciones de usuario con objetos en la aplicación de SAP. Este código de ejemplo:

  1. habilita la aplicación de SAP para efectuar pruebas
  2. Devuelve el objeto de prueba de SAP que representa la ventana
  3. Utiliza este objeto para buscar el botón Crear rol, cuya propiedad de nombre de botón se establece en btn[48] en la barra de herramientas de SAP.
  4. Pulsa el botón Crear rol

Ejemplo:

import resources.HandCodingWithEnablementHelper;

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.siebel.*;
import com.rational.test.ft.script.*;
import com.rational.test.ft.value.*;
import com.rational.test.ft.vp.*;

/**
 * Description   : Functional Test Script
 * @author Administrator
 */
public class HandCodingWithEnablement extends HandCodingWithEnablementHelper
{
	/**
	 * Script Name   : HandCodingWithEnablement
	 * Generated     : Sep 5, 2006 10:03:51 AM
	 * Description   : Functional Test Script
	 * Original Host : WinNT Version 5.1  Build 2600 (S)
	 * 
	 * @since  2006/09/05
	 * @author Administrator
	 */
	public void testMain(Object[] args) 
	{
		// Searching for SAP Test Objects through Scripting 
		
		// This enables SAP to be tested by Functional Tester and 
		// returns all top-level test objects in the SAP domain
		getRootTestObject().enableForTesting("sapLogon");
		TestObject[] sapApps = getRootTestObject().find(atChild(".domain", "SAP"));
		
		// Get a handle to the SAP Application from the top-level SAP object
		if(sapApps.length > 0){
			SAPGuiApplicationTestObject theAPP = ((SAPTopLevelTestObject)sapApps[0]).getApplication();
			logInfo("Application Number:" + theAPP.getProperty("Id"));
			
			// Get a handle to the SAP Connection from the SAP Application Test object
			TestObject[] cons = (TestObject[])theAPP.getProperty("Connections");

			SAPGuiConnectionTestObject con = (SAPGuiConnectionTestObject)cons[0];
			logInfo("Connection Number:" + con.getProperty("Id"));
			
			// Get a handle to the SAP Session from the SAP Connection Test Object
			TestObject[] sessions = (TestObject[])con.getProperty("Sessions");
			SAPGuiSessionTestObject sess = (SAPGuiSessionTestObject)sessions[0];
			logInfo("Session Number:" + sess.getProperty("Id"));
	
			// Get a handle to the SAP Main Window from the SAP Session Test Object
			// and iterate over its children till the desired object is found
			SAPTopLevelTestObject mainWnd = (SAPTopLevelTestObject)sess.getProperty("ActiveWindow");			
						
			TestObject[] wndChild = mainWnd.getChildren();
			for (int i=0; i<wndChild.length; i++)
			{
				String name = (String)wndChild[i].getProperty("Name");
				if (name.compareTo("tbar[1]")== 0)
				{
					TestObject[] btn = (TestObject[])wndChild[i].getChildren();
					for (int j = 0; j< btn.length; j++)
					{
						System.out.println("ToolBar Buttons");
						String btnType = (String)btn[j].getProperty("Type");
						if (btnType.compareTo("GuiButton")==0)
						{
							SAPGuiToggleTestObject button = (SAPGuiToggleTestObject)btn[j];
							String btnName = (String)button.getProperty("Name");
							if (btnName.compareTo("btn[48]")== 0)
							{
								// Click on the "Create Role" button ("btn[48]") placed on the toolbar("tbar[1]")
								button.press();
								logInfo("Clicked on the Create Role button");
								break;
							}
						}
					}
				}
			}
		}else{
			logInfo("SAP Application not found");
		}
	}
}

Si la aplicación de SAP ya está habilitada, a continuación no será necesario que habilite la aplicación SAP de forma explícita para efectuar pruebas. En lugar de ello, puede utilizar el código siguiente para buscar la aplicación SAP habilitada.

DomainTestObject domains[] = getDomains();
	for  (int i =0; i < domains.length; i ++)
	{
		DomainTestObject domain = domains[i];
		String name = (String)domain.getName();
		if (name.compareTo("SAP") == 0)
		{
			// Returns all top-level test objects in the SAP domain
			TestObject[] sapApps = domains[i].getTopObjects();
				
			// Perform user interactions with the SAP objects
		}
	}

Comentarios