Defining data for POM pages elements
Rules for POJO in java
1. Class needs to be Public
2. Properties are Private
3. Every property should have public getter and setters
4. Public default constructor Mandatory
5. Can have optional arguments constructor
6. Public static getData(HashMap map) to set each element value (based on HashMap values)
Step 1: Create a POJO for all elements on a page with following capabilities
public class Account {
private String network;
public String getNetwork() {
return network;
}
public void setNetwork(String network) {
this.network = network;
}
public static LoroAccount getAccount(Map
Account acct = new Account();
acct.setNetwork(map.get(“Network”));
return loroAccount;
}
}
Step 2: How to set values of elements in above POJO
Create a map which represents all the elements of properties for given class:
Map
public void navigateToLoroAccountPage()
stMap = excelUtils.readTestData(WorkSheetName);
map = new HashMap<>();
map = stMap.get(TestCaseID);
}
Step 3: Initialize POJO Values by using above map
@When(“User creates account”)
public void createAccount() {
createAccount(Account.geAccount(map));
}
0 comments