SAP TestObject 검색

Functional Tester를 사용하면, 오브젝트 맵을 사용하지 않고 지정된 검색 기준과 일치하는 하나 이상의 SAP TestObjects를 찾을 수 있습니다.

Functional Tester는 RootTestObject 클래스를 지원하여 테스트 중엔 소프트웨어의 글로벌 보기를 나타냅니다. 테스트를 위한 SAP 애플리케이션을 사용하기 위해 RootTestObject 클래스에서 enableForTesting 메소드를 호출합니다. 글로벌하게 검색하려면 RootTestObject 클래스에서 찾기 메소드를 호출합니다. 찾기 메소드의 첫 번째 인수인 부속 항목의 올바른 값에는 atProperty, atChild, atDescendantatList가 포함됩니다. .processName, .processID.domain 특성을 포함하여 RootTestObject.find에 적용되는 특수 특성이 있습니다. 부속 항목 및 특성 중 아무 값이나 사용할 수 있습니다. 예를 들어, SAP 도메인을 검색하려면 atChild 부속 항목과 SAP로 설정된 .domain 특성을 사용할 수 있습니다.

참고: SAP GUI 런타임 계층 구조에 대한 자세한 정보는 SAP GUI 스크립트 프레임워크 문서를 참조하십시오.

SAP 테스트 오브젝트를 찾아서 리턴하면 해당 오브젝트를 사용하여 SAP GUI 런타임 계층 구조로 되어 있는 다양한 오브젝트를 찾을 수 있습니다. 예를 들어, 다음과 같습니다.

활성 창 오브젝트를 가져오면 기본 창 테스트 오브젝트에서 GetChildren 메소드를 사용하여 GuiMainWindow 메소드에 있는 다양한 오브젝트를 찾아서 상호작용할 수 있습니다.

다음은 SAP 애플리케이션에서 오브젝트와 상호작용할을 수행할 수 있는 방법을 보여주는 예제입니다. 이 샘플 코드는 다음 조치를 수행합니다.

  1. 테스트를 위한 SAP 애플리케이션 사용
  2. 창을 나타내는 SAP 테스트 오브젝트를 리턴합니다.
  3. 이 오브젝트를 사용하여 SAP 도구 모음에 단추 이름 특성이 btn[48]로 설정되어 있는 역할 작성 단추를 검색할 수 있습니다.
  4. 역할 작성 단추를 클릭하십시오.

예제:

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
		}
	}
또한 dynamicfind() API를 선택하여 Functional Test 스크립트에서 SAP 텍스트 오브젝트를 찾고 SAP 텍스트 필드에서 setText를 수행할 수 있습니다.
public class SAPEditControl extends SAPEditControlHelper {
	/**
	 * Script Name : <b>SAPEditControl</b> Generated : <b>Aug 3, 2011 2:29:57
	 * PM</b> Description : Functional Test Script Original Host : WinNT Version
	 * 5.1 Build 2600 (S)
	 * 
	 * @since 2011/08/03
	 * @author IBM Rational
	 */
	public void testMain(Object[] args) {
		// Define a set of properties for a control (test object) to be searched
		Property Props[] = new Property[4];
		// property and value
		Props[0] = new Property(".class", "Html.TABLE");
		Props[1] = new Property(".customclass", "SAPEditControl");
		Props[2] = new Property(".id", "WD019E-r");
		Props[3] = new Property(".classIndex", "10");

		try {

			// Find and store test objects into array
			TestObject Obj[] = getRootTestObject().find(atDescendant(Props));

			// Perform a click on the very first object.
			((TextGuiSubitemTestObject) Obj[0]).click();

			// Set a text into SAP Edit Control
			((TextGuiSubitemTestObject) Obj[0]).setText("ClaimedAmount");

		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			//call unregisterAll to clear reference.
	args.addElement(subItem);
		}
	}

}

피드백