Page Object Model Flashcards
What is a page object model in selenium?
an object design pattern where web pages are represented as classes, and the various elements on the page are defined as variables on the class.
It enhances test maintenance and reducing code duplication.
clickLoginButton();
setCredentials(user_name,user_password);
Can Page object model be used with frameworks?
(POM) can be used in any kind of framework such as modular, data-driven, keyword driven, hybrid framework etc.
What is the Page Factory Class?
an extension to the Page Object design pattern.
It is used to initialize the elements of the Page Object or instantiate the Page Objects itself.
What is the difference between Page Object Model (POM) and Page Factory?
Page Object is a class that represents a web page and hold the functionality and members.
Page Factory is a way to initialize the web elements you want to interact with within the page object when you create an instance of it.
What is Test Class?
Test Class, we will write an actual selenium test script. Here, we call Page Action and mentioned actions to be
performed on Web Pages.
What is Page Action Class?
–In Page Action Class, we can write all web pages action as per the pages and functionality.
Under Page Action component, for each page in the application, we have corresponding Page class.
What is Page Factory Class?
Page Factory will initialize every WebElement variable with a reference to a corresponding element on the actual web page based on configured “locators”.
This is done through the use of @FindBy annotations.
Can you write sample code for Page Factory Class?
@FindBy (xpath=”.//*[@id=’Email’]”)
publicWebElementgmailUserIDWebEdit;
Can you write sample code for Page Action Class?
Page Action Class publicclassPageActions_Login { WebDriver driver; PageObjects_Loginpo; // Create Instance to Page Factory class publicPageActions_Login(WebDriver driver) { this.driver = driver; // set webDriver for current Page Action } }
What are the advantages of using page object pattern?
Easy to maintain. Easy readability of scripts Eliminate redundancy – Re-usability of code Reliability. Test coverage is more Performance of each test can be known. The changes is to be made only in Page Factory class if any locator changes
How do you initialize Web Page Classes or Page Objects containing web elements?
through the use of initElements function on PageFactory:
LoginPage page = PageFactory.intElements(driver,LoginPage.class)