Modeling
Software Engineer in Test uses java Class primarily for representing actual web pages in their automation scripts. This practice of representing the web pages or any entity in Java code is known as Modeling.
In this code note, we will understand following terminology:
- Understanding Class
- Understanding Object
› Class¶
Class is used for the following purpose in Java programming :
- Code organization for related data
- Code organization for related methods
- Code representation or modeling of a data entity
Let's represent following actual web page we use on Trello in our Java program.
Trello Page
We can represent Trello pages in out Java code by implementing the followings:
- List of web element locations that users would interact on the page as a variables
- List of user's actions on the page as a method
› Object¶
An object is a complete copy of all the code you have in a Class you created. The only way to use the code you wrote in any Class is to create an object from it. Through the object, we can use the code we grouped in our Class.
The syntax for creating an Object from the Trello class
Here is the breakdown of the above code:
| Code | Description |
|---|---|
Trello pages |
a variable that holds the object notice the data type of the variable pages |
= |
assignment operator that assigns the data to the variable |
new Trello(); |
code that creates an object (complete code of the code) from the Trello class. |
Let's see an example of where we are using the codes we wrote in the Trello class.
| Trello object example | |
|---|---|
| |
In the above code, here is what we are doing:
- Creating an object from the
Trelloclass - The variable
pageis holding the object. - We use the methods we wrote in Class through the object.