SAP TestObjects の検索

Functional Tester では、オブジェクト・マップを使用しなくても、指定した検索条件と一致する 1 つ以上の SAP TestObjects を探索する方法がサポートされています。

Functional Tester は、テスト対象のソフトウェアのグローバル・ビューを表す RootTestObject をサポートしています。 SAP アプリケーションをテスト用に使用可能にするには、RootTestObject に対して enableForTesting メソッドを呼び出します。 一括検索を実行するには、RootTestObject に関する検索メソッドを呼び出します。 検索メソッドの最初の引数になる副項目の有効な値には、atPropertyatChildatDescendant、および atList があります。.processName.processID.domain など、RootTestObject.find に適用される特殊なプロパティーもあります。これらの副項目とプロパティーはいずれか任意のものを使用できます。 例えば、atChild 副項目を、.domain プロパティーを SAP に設定して使用することにより、SAP ドメインを検索することができます。

注: SAP の GUI Runtime Hierarchy について詳しくは、SAP GUI Script Framework の資料を参照してください。

トップレベルの SAP Test Object が見つかって戻された後は、そのオブジェクトを使用して、SAP の GUI ランタイム階層のさまざまなオブジェクトを検索することができます。例:

アクティブ・ウィンドウ・オブジェクトを取得した後は、メインウィンドウ・テスト・オブジェクトに対して GetChildren メソッドを使用して、 GuiMainWindow のさまざまなオブジェクトを検索し、それと対話することができます。

以下に、SAP アプリケーション内のオブジェクトとのユーザー対話を実行する方法の例をリストします。このサンプル・コードは、以下のことを行います。

  1. SAP アプリケーションをテスト用に使用可能にする
  2. ウィンドウを表す SAP テスト・オブジェクトを戻す
  3. そのオブジェクトを使用して、SAP ツールバー上でボタンの name プロパティーが btn[48] に設定されている「Create Role」ボタンを検索する。
  4. 「Create Role」ボタンをクリックする

例:

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
		}
	}

フィードバック