There are quite a few reasons to use the Applicaiton Model.
- You can use it in multiple tests
- It provides a single point for updating if the application changes
- It helps to clean up your code.
Find more information about [Application Models on the LeanFT Help Center][1].
Consider the below code samples which do the same thing. With Applicaiton Model: 10 lines of code vs. without Apllication Model: 56 lines of code.
//With Application Model
FlightApplicationModel FlightApp = new FlightApplicationModel();
FlightApp.MicroFocusMyFlightSampleApplicationWindow.UserName.SetText(''John'');
FlightApp.MicroFocusMyFlightSampleApplicationWindow.PasswordEditField.SetSecure(''5bea0947eb05a78de896''); //HP
FlightApp.MicroFocusMyFlightSampleApplicationWindow.OKButton.Click();
FlightApp.MicroFocusMyFlightSampleApplicationWindow.FINDFLIGHTSButton.Click();
FlightApp.MicroFocusMyFlightSampleApplicationWindow.FlightsDataGridTable.SelectRow(4);
FlightApp.MicroFocusMyFlightSampleApplicationWindow.SELECTFLIGHTButton.Click();
FlightApp.MicroFocusMyFlightSampleApplicationWindow.PassengerNameEditField.SetText(''John'');
FlightApp.MicroFocusMyFlightSampleApplicationWindow.ORDERButton.Click();
FlightApp.MicroFocusMyFlightSampleApplicationWindow.ORDERButton.Click();
//Without Application Model
var microFocusMyFlightSampleApplicationWindow = Desktop.Describe(new WindowDescription
{
FullType = @''window'',
ObjectName = @''Micro Focus MyFlight Sample Application'',
WindowTitleRegExp = @''Micro Focus MyFlight Sample Application''
});
var agentNameEditField = microFocusMyFlightSampleApplicationWindow.Describe(new EditFieldDescription
{
ObjectName = @''agentName''
});
agentNameEditField.SetText(''John'');
var passwordEditField = microFocusMyFlightSampleApplicationWindow.Describe(new EditFieldDescription
{
ObjectName = @''password''
});
passwordEditField.SetSecure(''5be9ff55937293c391ef'');
var wpfButtonButton = microFocusMyFlightSampleApplicationWindow.Describe(new ButtonDescription
{
ObjectName = @''okButton'',
Text = @''OK''
});
wpfButtonButton.Click();
var fINDFLIGHTSButton = microFocusMyFlightSampleApplicationWindow.Describe(new ButtonDescription
{
ObjectName = @''FIND FLIGHTS'',
Text = @''FIND FLIGHTS''
});
fINDFLIGHTSButton.Click();
var flightsDataGridTable = microFocusMyFlightSampleApplicationWindow.Describe(new TableDescription
{
ObjectName = @''flightsDataGrid''
});
flightsDataGridTable.SelectCell(5, 4);
var sELECTFLIGHTButton = microFocusMyFlightSampleApplicationWindow.Describe(new ButtonDescription
{
ObjectName = @''selectFlightBtn'',
Text = @''SELECT FLIGHT''
});
sELECTFLIGHTButton.Click();
var passengerNameEditField = microFocusMyFlightSampleApplicationWindow.Describe(new EditFieldDescription
{
ObjectName = @''passengerName''
});
passengerNameEditField.SetText(''John'');
var ORDERButton = microFocusMyFlightSampleApplicationWindow.Describe(new ButtonDescription
{
ObjectName = @''orderBtn'',
Text = @''ORDER''
});
ORDERButton.Click();
[1]: https://admhelp.microfocus.com/leanft/en/14.50-14.53/HelpCenter/Content/HowTo/TestObjects_AppModel.htm