Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,11 @@ If this architecture helped you solve a problem or save time, consider supportin

[Visit TestShift.com for more Architectural Insights](https://www.test-shift.com)

</div>
</div>


## Enhancements by Me

- Added a `BasePage` to centralize reusable Playwright browser actions such as click and fill.
- Improved framework maintainability by following the Page Object Model design pattern.
- Extended the framework structure to support scalable test development.
41 changes: 41 additions & 0 deletions src/pages/base_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# BasePage for Playwright reusable actions

from playwright.sync_api import Page, expect


class BasePage:
"""
BasePage provides common Playwright actions
that can be reused across all Page Objects.
"""

def __init__(self, page: Page):
self.page = page

def open(self, url: str) -> None:
"""Navigate to a given URL"""
self.page.goto(url)

def click(self, locator: str) -> None:
"""Click on a web element"""
self.page.locator(locator).click()

def fill(self, locator: str, value: str) -> None:
"""Fill input field with value"""
self.page.locator(locator).fill(value)

def get_text(self, locator: str) -> str:
"""Return text of an element"""
return self.page.locator(locator).inner_text()

def is_visible(self, locator: str) -> bool:
"""Check if element is visible"""
return self.page.locator(locator).is_visible()

def wait_for(self, locator: str) -> None:
"""Wait until element is visible"""
self.page.locator(locator).wait_for()

def assert_text(self, locator: str, expected_text: str) -> None:
"""Assert exact text of an element"""
expect(self.page.locator(locator)).to_have_text(expected_text)