8 reasons Page-Object Model is overrated

What is Page-Object model?

The pitfall

class LoginPage(Page):
def __init__(self, drv):
super().__init__(drv)
self._username_locator: Tuple[By, str] = (By.ID, "txtUsername")
self._password_locator: Tuple[By, str] = (By.ID, "txtPassword")
self._login_btn_locator: Tuple[By, str] = (By.ID, "btnLogin")
def insert_username(self, username: str, timeout: int = 10) -> None:
username_element = WebDriverWait(self._driver,
timeout).until(
EC.presence_of_element_located(self._username_locator)
)
username_element.send_keys(username)
def insert_password(self, password: str, timeout: int = 10) -> None:
username_element = WebDriverWait(self._driver,
timeout).until(
EC.presence_of_element_located(self._password_locator)
)
username_element.send_keys(password)
def click_login(self, timeout: int = 10) -> HomePage:
username_element = WebDriverWait(self._driver,
timeout).until(
EC.presence_of_element_located(self._login_btn_locator)
)
username_element.click()
hp = HomePage(self._driver)
return hp
def test_case(self):
login_page: LoginPage = LoginPage(self._driver)
login_page.insert_username("Admin")
login_page.insert_password("admin123")
home_page: HomePage = login_page.click_login()
self.assertAlmostEqual(home_page.welcome_message, "Welcome Paul")

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store