What is the Page Object Model and Page Factory?

886    Asked by MaryannReller in QA Testing , Asked on Jan 6, 2020
Answered by Maryann Reller

Automation community which basically refers to the idea of mapping your test framework, or the model of your test framework to the model of your pages is called Page Object Model. For instance, in an application, you may have a series of different pages, a Login Page, Shopping Cart, and an Orders Page. Each page will have its own object like Login Page will have a Login Page object, a Shopping Cart object, and an Orders Page object. So the idea here is that, for example, Login Page, is going to be responsible for being able to get the elements that exist on that page, for example, a username field and a password field, as well as a login button, and it's going to manipulate that. It's going to work at the highest level possible. That's what makes a good automation framework. In short, Page Object Model is a coding pattern in which classes demonstrate the web pages. References of elements on the web page are stored under variables, and behaviours are implemented by methods. This allows an effective way of executing test cases that are both readable and flexible to maintain and extend in the future. Functions/methods include:

clickLoginButton();

setCredentials(user_name, user_password);

submitLoginForm();

Page Factory which is just enhancing the page object model where we have a constructor which initialize web elements using configrable “locators” with a reference to an element on the actual web page. For instance, @FindBy is the annotation used for searching elements. For example:

@FindBy(how=How.NAME, using="testUser")private WebElement user_name;



Your Answer

Interviews

Parent Categories