Page Object Model Flashcards

1
Q

What is a page object model in selenium?

A

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);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Can Page object model be used with frameworks?

A

(POM) can be used in any kind of framework such as modular, data-driven, keyword driven, hybrid framework etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the Page Factory Class?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the difference between Page Object Model (POM) and Page Factory?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Test Class?

A

Test Class, we will write an actual selenium test script. Here, we call Page Action and mentioned actions to be
performed on Web Pages.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is Page Action Class?

A

–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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Page Factory Class?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Can you write sample code for Page Factory Class?

A

@FindBy (xpath=”.//*[@id=’Email’]”)

publicWebElementgmailUserIDWebEdit;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Can you write sample code for Page Action Class?

A
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
}
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the advantages of using page object pattern?

A
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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you initialize Web Page Classes or Page Objects containing web elements?

A

through the use of initElements function on PageFactory:

LoginPage page = PageFactory.intElements(driver,LoginPage.class)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly