Listen to this blog |
Page objects are commonly used for testing, but should not make assertions themselves. Their responsibility is to provide access to the state of the underlying page. It’s up to test clients to carry out the assertion logic.
In this blog article, you will learn how to implement Page Object Pattern using PyPOM package.
Installation
pip install PyPOM
[/code]
Sample Code
from pypom import Page from selenium import webdriver from selenium.webdriver.common.by import By driver = webdriver.Chrome(executable_path='driverschromedriver.exe') class Home(Page): _contact_us_locator = (By.ID, 'menu-item-54') @property def fill_contact_us_form(self): self.find_element(*self._contact_us_locator).click() base_url = 'https://www.codoid.com' home_page = Home(driver, base_url).open() home_page.fill_contact_us_form driver.quit()
In Conclusion:
We have other page object model packages in Python. We will review them in our subsequent articles. Please feel free to contact us if you face any issues with PyPOM implementation.
Comments(0)