public class LoginPage extends Page {
//WebElements
@FindBy(using = "user_name")
@CacheLookup
private WebElement userName;
@FindBy(using = "password")
@CacheLookup
private WebElement password;
@FindBy(css = ".btn.btn-success")
@CacheLookup
private WebElement loginbtn;
public LoginPage(WebDriver webDriver) {
super(webDriver);
PageFactory.initElements(webDriver, this);
}
//Methods
@Step
public HomePage login(String uName, String passw){
userName.sendKeys(uName);
password.sendKeys(passw);
loginbtn.click();
return new HomePage(webDriver);
}
}
A class should have one and only one reason to change, meaning that a class should have only one job.
Objects or entities should be open for extension but closed for modification.
Entities must depend on abstractions, not on concretions. It states that the high-level module must not depend on the low-level module, but they should depend on abstractions
D.R.Y - Don’t Repeat Yourself
Design Patterns are solutions to software design problems in real-world application development. Patterns are about reusable designs and interactions of objects.
The Gang of Four (GoF) patterns are generally considered the foundation for all other patterns. They are categorized into three groups: Creational, Structural, and Behavioral
Deal with object creation mechanisms and are used in situations when the basic form of object creation could result in design problems or increase the complexity of a code base
Ease the design by identifying a simple way to realize relationships between entities or defines a manner for creating relationships between objects
Explains how objects interact