Functional Tester는 RootTestObject를 지원하여 테스트 중엔 소프트웨어의 글로벌 보기를 나타냅니다. 테스트를 위한 SAP 응용프로그램을 사용하기 위해 RootTestObject에서 enableForTesting 메소드를 호출합니다. 글로벌 검색을 수행하려면 RootTestObject에서 찾기 메소드를 호출합니다. 찾기 메소드의 첫 번째 인수인 하위 항목의 올바른 값에는 atProperty, atChild, atDescendant 및 atList가 포함됩니다. .processName, .processID, .domain 등을 포함하여 RootTestObject.find에 적용되는 특수 특성이 있습니다. 이 하위 항목 및 특성을 모두 사용할 수 있습니다. 예를 들어, SAP 도메인을 검색하는 데 atChild 하위 항목과 SAP에 설정된 .domain 특성을 사용할 수 있습니다.
SAP 테스트 오브젝트를 찾아서 리턴하면 해당 오브젝트를 사용하여 SAP GUI 런타임 계층 구조로 되어 있는 다양한 오브젝트를 찾을 수 있습니다. 예를 들어, 다음과 같습니다.
활성 창 오브젝트를 가져오면 기본 창 테스트 오브젝트에서 GetChildren 메소드를 사용하여 GuiMainWindow에 있는 다양한 오브젝트를 찾아서 상호작용할 수 있습니다.
다음은 SAP 응용프로그램에서 오브젝트와 상호작용할을 수행할 수 있는 방법을 보여주는 예제입니다. 샘플 코드입니다.
예제:
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");
}
}
}
SAP 응용프로그램을 이미 사용 중인 경우 테스트에 SAP 응용프로그램을 명시적으로 사용하지 않아도 됩니다. 대신 다음 코드를 사용하여 사용 중인 SAP 응용프로그램을 찾을 수 있습니다.
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
}
}