c) 启动 SAP GUI Client(如图 6 SAP GUI Client 启动界面)。
Runtime.getRuntime().exec(“C:/ProgramFiles/sappc/SAPgui/saplogon.exe”) |
图 6. SAP GUI Client 启动界面

d) 通过 Find 方法查找 SAP GUI Logon 界面,点击 Logon 进入登录主界面:
TestObject[] sapApps = getRootTestObject().find(atChild(".name", "SAP Logon 710"));
|
在此不一一列出改进的方方面面,开发者要根据实际情况作相应的改进。
制作 RFT 脚本模板
根据总体架构的设计,需要根据脚本模板生成实际执行的 RFT 脚本,所以应该将 Draft 脚本中的原始数据用占位符替代,等到提交某个数据请求时,再替换回来。
清单 2. 改进后的 RFT 脚本模板
public void testMain(Object[] args)
{
Object[] allArgs = args;
String sapLogonExe = (String)allArgs[0];
String userName = (String)allArgs[1];
String password = (String)allArgs[2];
try {
Runtime.getRuntime().exec("Taskkill /F /T /IM saplogon.exe");
Runtime.getRuntime().exec(sapLogonExe);
} catch (IOException e) {
e.printStackTrace();
}
RationalTestScript.getRootTestObject().enableForTesting("saplogon.exe");
TestObject[] sapApps = getRootTestObject().find(atChild(".name", "SAP Logon 710"));
window_sap().maximize();
text_rsystbname().setText(userName);
text_rsystbcode().setText(password);
text_rsystbcode().setFocus();
text_rsystbcode().setCaretPosition(8);
window_sap().sendVKey(SAPTopLevelTestObject.VKEY_ENTER);
// Window: SAP Easy Access
comboBox_okcd().setText("va21");
window_sapEasyAccess().sendVKey(SAPTopLevelTestObject.VKEY_ENTER)
// Window: Create Quotation: Initial Screen
window_createQuotationInitialS().sendVKey(SAPTopLevelTestObject.VKEY_F4);
// Dialog: Sales document type
label_renwlQuoteForPA().setFocus();
label_renwlQuoteForPA().setCaretPosition(7);
dialog_salesDocumentType().sendVKey(SAPTopLevelTestObject.VKEY_F2);
// Window: Create Quotation: Initial Screen
text_vbakvkorg().setText("%SALES_ORG%");
text_vbakvtweg().setText("%DIS_CHANNEl%");
text_vbakspart().setText("%DIVISION%");
text_vbakvkbur().setText("%SALES_OFFICE%");
text_vbakvkbur().setFocus();
text_vbakvkbur().setCaretPosition(4);
window_createQuotationInitialS().maximize();
…
…
}
|