package com.seleniummaster.qa.framework.controller; import junit.framework.Assert; import com.seleniummaster.qa.model.*; import com.thoughtworks.selenium.Selenium; public class CalculateMonthlyPaymentControl { private Selenium selenium=null; private CalculatorMonthlyPaymentModel model; public CalculateMonthlyPaymentControl(Selenium selenium) { this.selenium=selenium; model=new CalculatorMonthlyPaymentModel(); }
public void calculatePayment(String homeValue,String creditProfile,String downPayment, String loanPurpose,String interestRate,String loanTerm,String startMonth,String startYear,String propertyTax,String pmi) { if(homeValue!=null) { selenium.type(model.HomeValueTextBox(), homeValue); } if(creditProfile!=null) { selenium.select(model.CreditProfileDropDownList(),"label="+creditProfile); } if(downPayment!=null) { selenium.type(model.downPaymentInputBox(),downPayment); } if(loanPurpose!=null) { selenium.select(model.LoanPurposeDropDownList(),"label="+loanPurpose); } if(interestRate!=null) { selenium.type(model.InterestRateTextBox(),interestRate); } if(loanTerm!=null) { selenium.type(model.LoanTermTextBox(),loanTerm); } if(startMonth!=null) { selenium.select(model.StartMonthDropDownList(),"label="+startMonth); } if(startYear!=null) { selenium.select(model.StartYearDropDownList(),"label="+startYear); } if(propertyTax!=null) { selenium.type(model.PropertyTaxTextBox(),propertyTax); } if(pmi!=null) { selenium.type(model.PMITextBox(),pmi); } } public void calculateNow() { selenium.click(model.CalculateButton()); } public void captureScreen(String filename) { selenium.captureScreenshot(filename); } public void verifyResult(String expected) { String actual=selenium.getText(model.resultvalue().toString()); System.out.println("The value is " + actual); Assert.assertEquals(expected, actual); } }
|