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.
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:
Ejemplo:
#Region " Script Header " ' Functional Test Script ' author Administrator Imports Microsoft.VisualBasic Imports Rational.Test.Ft Imports Rational.Test.Ft.Object.Interfaces Imports Rational.Test.Ft.Object.Interfaces.SAP Imports Rational.Test.Ft.Object.Interfaces.Siebel Imports Rational.Test.Ft.Script Imports Rational.Test.Ft.Value Imports Rational.Test.Ft.Vp #End Region Public Class HandCodingWithEnablement Inherits HandCodingWithEnablementHelper 'Script Name : HandCodingWithEnablement 'Generated : Sep 5, 2006 10:53:54 AM 'Description : Functional Test Script 'Original Host : Windows XP x86 5.1 build 2600 Service Pack 2 'since 2006/09/05 'author Administrator Public Function TestMain(ByVal args() As Object) As Object Dim sapApps() As TestObject Dim app As SAPTopLevelTestObject Dim theAPP As SAPGuiApplicationTestObject Dim cons() As TestObject Dim sessions() As TestObject Dim con As SAPGuiConnectionTestObject Dim sess As SAPGuiSessionTestObject Dim mainWnd As SAPTopLevelTestObject Dim wndChild() As TestObject Dim btns() As TestObject Dim btn As SAPGuiToggleTestObject Dim i, j As Integer Dim Len1, Len2 As Integer ' 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") sapApps = GetRootTestObject().Find(AtChild(".domain", "SAP")) ' Get a handle to the SAP Application from the top-level SAP object If (sapApps.GetLength(0) > 0) Then app = sapApps(0) theAPP = app.GetApplication LogInfo("Application Number:" + theAPP.GetProperty("Id")) ' Get a handle to the SAP Connection from the SAP Application Test object cons = theAPP.GetProperty("Connections") con = cons(0) LogInfo("Connection Number:" + con.GetProperty("Id")) ' Get a handle to the SAP Session from the SAP Connection Test Object sessions = con.GetProperty("Sessions") sess = 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 mainWnd = sess.GetProperty("ActiveWindow") wndChild = mainWnd.GetChildren() Len1 = wndChild.GetLength(0) - 1 For i = 0 To Len1 Dim name As String = wndChild(i).GetProperty("Name") If (name.CompareTo("tbar[1]") = 0) Then btns = wndChild(i).GetChildren Len2 = btns.GetLength(0) - 1 For j = 0 To Len2 Dim btnType As String = btns(j).GetProperty("Type") If (btnType.CompareTo("GuiButton") = 0) Then btn = CType(btns(j), SAPGuiToggleTestObject) Dim btnName As String = btn.GetProperty("Name") If (btnName.CompareTo("btn[48]") = 0) Then ' Click on the "Create Role" button ("btn[48]") placed on the toolbar("tbar[1]") btn.Press() LogInfo("Clicked on the Create Role button") Return Nothing End If End If Next j End If Next i Else LogInfo("SAP Application not found") End If Return Nothing End Function End Class
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.
Dim domains As DomainTestObject() Dim domain As DomainTestObject Dim sapApps() As TestObject Dim name As String Dim domainsCount As Integer Dim i As Integer domains = GetDomains() domainsCount = domains.GetLength(0) - 1 For i = 0 To domainsCount domain = domains(i) name = domain.GetName() If (name.CompareTo("SAP") = 0) Then ' Returns all top-level test objects in the SAP domain sapApps = domain.GetTopObjects ' Perform user interactions with the SAP objects End If Next i