0% found this document useful (0 votes)
0 views

import java (2)

The document discusses the Page Object Model (POM) and its advantages, such as separation of concerns and easier updates. It explains the structure of POM, including the definition of page classes and their methods for interacting with web elements. Additionally, it introduces Page Factory as an extension of POM that simplifies element initialization using annotations.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

import java (2)

The document discusses the Page Object Model (POM) and its advantages, such as separation of concerns and easier updates. It explains the structure of POM, including the definition of page classes and their methods for interacting with web elements. Additionally, it introduces Page Factory as an extension of POM that simplifies element initialization using annotations.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

// Perform login actions loginPage.

enterUsername("testuser");
loginPage.enterPassword("testpassword"); loginPage.clickLogin(); // Add assertions or
further actions here // Close the browser driver.quit(); } } Advantages of Using POM •
Separation of Concerns: UI interactions are separated from test logic. • Easier Updates: If
an element's locator changes, you only need to update it in one place. • Clear Structure:
The code structure is clear, making it easier for new team members to understand. POM
VS Page Factory Page Object Model (POM) 1. Definition: POM is a design pattern that
creates an object repository for web UI elements. Each web page in the application has a
corresponding class that contains methods to interact with the elements on that page. 2.
Structure: • Each page class contains locators for web elements and methods that
perform actions on those elements. • The locators are defined using the By class. 3.
Initialization: • Objects of page classes must be initialized individually in the test scripts. •
It does not provide lazy initialization, meaning that all elements are found at the time of
method execution. 4. Advantages: • Reduces code duplication and improves test
maintenance. • Makes the code cleaner and easier to understand by separating UI
operations from test logic. 5. Example: public class LoginPage { private WebDriver driver; //
Locators private By username = By.id("username"); private By password =
By.id("password"); private By loginButton = By.id("login"); public LoginPage(WebDriver
driver) { this.driver = driver; } public void enterUsername(String user)
{ driver.findElement(username).sendKeys(user); } public void enterPassword(String pass)
{ driver.findElement(password).sendKeys(pass); } public void clickLogin()
{ driver.findElement(loginButton).click(); } } Page Factory 1. Definition: Page Factory is an
extension of the Page Object Model provided by Selenium WebDriver. It simplifies the
process of creating Page Objects by using annotations to initialize web elements.

You might also like