In the AUT, there are 3 screens in a business flow. Create, Preview and Submit.
So in the preview screen, as the name suggests, user will preview the information entered by him in the Create screen.
Similarly in Submit screen, a success message box is displayed at the top section of the screen and very high level details of the record created along with the status of it.
I follow the Page Object Model (POM) framework in my selenium script. So basically, I create a new class file for each screen in the AUT.
However In the above case, what different i did was, the Java class of 2nd screen was created as child class of Screen 1’s Java class. Similarly the Java class of 3rd screen was created as Child Class of Screen1’s Java class.
This helps in code maintenance. From your Test case, you need to pass the data values only for screen 1’s object. Java class of screen 2 and 3 can then access the variables in Screen 1 Java class and thus can be used directly.
Parent class – screen 1
public class POMCreateTransferPage {
WebDriver d;
WebElement elementsList;
String transferFrom, transferTo, transferAmount, transferDate, transferFrequency, transferRecSchd, transferRecNOP, transferTotalRecPayments, transferRecEndDate, transferOptions,transferMemo;
public POMCreateTransferPage(WebDriver driver){
this.d = driver;
}
public void createSingleTransfer(list of var from calling TC){
this.transferFrom = FromAccount;
this.transferTo = ToAccount;
this.transferAmount = amount;
this.transferDate = Date;
this.transferFrequency = frequency;
this.transferRecSchd = recSchd;
this.transferRecNOP = NOP;
this.transferTotalRecPayments = totalPayments;
this.transferRecEndDate = endDate;
this.transferOptions = Options;
this.transferMemo = Memo;
/*
Rest of the code
*/
Child Class#1 – Screen 2
public class POMPreviewAccountTransferPage extends POMCreateTransferPage {
public POMPreviewAccountTransferPage(WebDriver driver)
{ super(driver); }
/*
Rest of the code
*/
Test Case
Observe in the Test case that i created the object of child class and used it to call the method in parent class. I passed the parameters (data from the data sheet) only to the method of parent class. In this method of parent class, I use the values (passed from Test case) to initiate the class variables.
Thus when i call the method of child class, i’m not passing the parameters again.
public void sunView_FS(Variable list to catch data coming from DP){
//line of codes removed
l = new POMSunViewLoginPage(sunViewDriver);
t = new POMTreasuryDBPage(sunViewDriver);
ct = new POMPreviewAccountTransferPage(sunViewDriver);
l.loginToSunView();
sunViewDriver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
t.clickOnTransfers_SingleTransfer();
ct.createSingleTransfer(Variable list);
ct.PreviewTransfer();
//Rest of the code

