In case you missed out on part 3, here you go:-
Basically there are two ways in which we can specify the properties of the objects that will be used in our script:-
1. Descriptive Programming – This is the approach that was demonstrated in the previous tutorial where we specified the object’s properties in the Test Method itself(by copying the object properties from the clipboard).
2. Application Model – Application Model is to LeanFT, what object repository is to UFT. Simply put together, its a collection of Test objects that we can use in our scripts. It acts as a centralized repository which can be shared across different scripts.
Which approach is better is a very subjective question and I will leave that to you to figure out which suits you best. Here is how we can create Application Models in LeanFT:-
1. When you navigate to New-> Other -> LeanFT, then you need to decide between the two:-
- Application Model Item – You need to create this if your Application model needs to be used inside the designated project only. This will be created just like a class inside a package in your project. If you want to use this in other classes in the same package, you can use it directly and if you want to use this in other class in different package, then you need to import the package of the Application Model and then you can use it.
- Application Model Project – You need to create this if your Application model needs to be used across multiple projects. For using this in another project, you just need to add your project to the build path and then import the corresponding package and start using the objects.
For the sake of this tutorial, I’ll be covering Application Model Item.
2. Define the name as well as the package of the model. After that, you will see an Application Model tsrx file is created. Now you can start adding objects to it.
3. There are two ways in which we can add the objects:-
a) Specify the object type and properties explicitly by clicking on the + icon on the top left corner:-
b) Open the Object Identification center from the App Model and after selecting the appropriate object and the identification properties, click on the add to App Model icon :-
After you have the required objects in the Application Model, you can refer to these objects as follows:-
One thing worth noticing here is that I need to pass the browser instance when I want to create an object of my application model. This will enable LeanFT to understand that all objects in my application model are to be identified with the passed browser object as the parent. Passing browser is required only in case of Web Automation scripts, for other technologies we can create the application model object without passing a context object.
So this is how you can add objects to the application model and use them in your scripts.
Happy Automating !