Page Object Model
Page Object Model
QUESTIONS(Theory)
1. What is meant by POM?
*Page Object Model, also known as POM, is a design pattern in Selenium that creates an object
repository for storing all web elements.
*It is useful in reducing code duplication and improves test case maintenance.
2. What are the types of POM?
*With PageFactory
*Without PageFactory
3. What is meant by Annotations?
Annotations are the lines of codes that can control how the method below them will be executed.
*They are used to provide supplement information about the program.
*Annotation Start with "@" Annotation do not change action of a compiled program .
*Annotation help to associate metadata to the program elements i.e. instance variable,
constructors, methods, classes.
list of annotations
@FindBy
@FindBys
@FindAll
@cacheLookup
4. What are the page factory Annotations?
In Page Factory, Annotations are used to give descriptive names for WebElements to improve
code readability. And annotation @FindBy is used to identify Web Elements in the page.
*PageFactory is a way of implementing the “Page Object Model”.
*Here, we follow the principle of separation of Page Object Repository and Test Methods.
*It is an inbuilt concept of Page Object Model which is very optimized.
5.What is mean by pojo class?
*POJO stands for Plain Old Java Object. It is an ordinary Java object, not bound by any special
restriction other than those forced by the Java Language Specification and not requiring any
classpath.
*POJOs are used for increasing the readability and re-usability of a program.
*POJOs have gained the most acceptance because they are easy to write and understand.
}
//generate the getter
public String EmpName() {
return this. EmpName+ " " + this.EmpName;
}
public String EmpAddress() {
return this.EmpAddress+ " " + this.EmpAddress;
}
}
7.Write the folder Structure used in POM?
*maven-project/pom. ...
*maven-project/src/main – contains source code and resources that become part of the artifact.
*maven-project/src/test – holds all the test code and resources.
*maven-project/src/it – usually reserved for integration tests used by the Maven Failsafe Plugin.
Example
@FindBy
@FindBy(id="email")
private WebElement txtUserName;
@FindBy(id="pass")
private WebElement txtPassword;
@FindBy(name="login")
private WebElement btnClicklogin;
@FindAll
* We can pass more than one locator it is behaviour like OR operator.
*If any one locator mistakes it will enter the value.
@FindAll
@FindBy(id="email")
private WebElement txtUserName;
@FindBy(id="pass")
private WebElement txtPassword;
@FindBy(name="login")
private WebElement btnClicklogin;