How to Develop Keyword-Driven Automation Scripts for a Claims Processing Web App
With business keywords, technical keywords, POM, soft/hard assertions, and Playwright - Python examples.
Keyword-driven automation is a powerful approach for complex business domains like insurance claims processing, where workflows are long, rule-driven, and often updated. By separating business-level keywords from technical keywords, automation becomes easy to read, maintain, and scale.
This guide walks you through 10 structured components - each with a description first, then illustrative examples, and finally domain-focused best practices.
What Is Playwright and Why Are We Using It?
Description
Playwright is a modern automation framework created by Microsoft for testing web applications. It supports multiple browsers, fast execution, auto-waiting, excellent debugging, and runs smoothly with Python. We choose Playwright because:
Using Playwright with Python gives us a powerful, scalable solution for building a keyword-driven automation framework.
Examples
# Example: Basic Playwright Setup
from playwright.async_api import async_playwright
async def run_test():
async with async_playwright() as p:
browser = await p.chromium.launch()
page = await browser.new_page()
await page.goto("https://claims-app.com")
await browser.close()
1. Start With a Clear Keyword Strategy (Business + Technical Keywords)
Description
A keyword-driven framework succeeds or fails based on keyword clarity. You need two classes of keywords:
Business keywords hide complexity and allow non-engineers to read test steps easily. Technical keywords keep UI operations reusable and maintainable.
Examples
Business Keywords:
Technical Keywords:
2. Build a Strong Folder Structure for Keyword-Driven Automation
Description
A clean folder structure prevents chaos. Business keywords, technical keywords, POM files, and test data should be separated clearly. This keeps your automation easy to navigate and modify as the application grows.
Example Structure
automation/
keywords/
business_keywords.py
technical_keywords.py
pages/
login_page.py
claim_page.py
tests/
test_create_claim.py
utils/
soft_assert.py
config.py
data/
claims_test_data.json
3. Define Page Objects for the Claims Portal (POM Layer)
Description
Page Object Model centralizes page locators and behaviors. All UI selectors stay in POM files - not in tests, not in keywords. This ensures any UI changes require edits in one place only.
Example
class LoginPage:
def __init__(self, page):
self.page = page
self.username = "#username"
self.password = "#password"
self.login_btn = "#loginBtn"
async def login(self, user, pwd):
await self.page.fill(self.username, user)
await self.page.fill(self.password, pwd)
await self.page.click(self.login_btn)
4. Create Technical Keywords (Reusable UI Actions)
Description
Technical keywords wrap low-level Playwright operations. They must be small, reusable, and handle waits, retries, and errors. They form the foundation on which business keywords are built.
Example
class TechnicalKeywords:
def __init__(self, page):
self.page = page
async def Click_Element(self, selector):
await self.page.click(selector)
async def Enter_Text(self, selector, text):
await self.page.fill(selector, text)
5. Build Business Keywords for Claims Workflows
Description
Business keywords represent multi-step functional actions common in claims processing. They combine multiple technical keywords and page object calls to simulate full business behavior.
Example
class BusinessKeywords:
async def Login_As_Adjuster(self, username, password):
await self.login_page.login(username, password)
async def Create_New_Claim(self, claim_data):
await self.claim_page.open_new_claim_form()
await self.claim_page.fill_claim_form(claim_data)
await self.claim_page.submit_claim()
6. Use Hard & Soft Assertions for Stable Scripts
Description
Claims workflows involve many interlinked screens and validations. Using both soft and hard assertions:
Soft assertions are particularly valuable for validations like claim status, messages, and optional fields.
Example
soft.assertions.verify(actual_status == expected_status,
"Status mismatch: Submitted vs Approved")
7. Add Data-Driven Testing for Claims Scenarios
Description
Claims involve many variants - different claim types, amounts, dates, or policy categories. Storing test data in JSON/YAML files helps run the same workflow with multiple datasets without editing code.
Example Test Data
{
"valid_claim": {
"claim_type": "Auto",
"policy_number": "POL12345",
"incident_date": "2024-12-01",
"amount": "3000",
"description": "Front bumper damage"
}
}
8. Build End-to-End Tests Using Keywords
Description
Once keywords, data, and POMs exist, test scripts become dramatically shorter and more readable. This improves clarity, reduces maintenance, and accelerates onboarding for new testers.
Example
async def test_create_claim(page):
soft = SoftAssert()
tech = TechnicalKeywords(page)
biz = BusinessKeywords(page, tech, soft)
data = load_json("valid_claim")
await biz.Login_As_Adjuster("adjuster1", "Pass@123")
await biz.Create_New_Claim(data)
await biz.Validate_Claim_Status("CLM1001", "Submitted")
soft.assert_all()
9. Build a Keyword Library for the Claims Domain
Description
A keyword library documents every available keyword with purpose, parameters, and usage. This helps maintain consistency across teams and prevents duplication.
Examples
Business Keywords:
Technical Keywords:
10. Guidelines to Keep Keyword-Driven Automation Maintainable
Description
Maintenance is the real test of automation maturity. The following guidelines ensure long-term framework stability:
Example
A good keyword: Approve_Claim A bad keyword: Approve_Claim_And_Validate_Status_And_Logout (too much happening)
Conclusion
A keyword-driven framework powered by Playwright (Python), Page Object Model, business + technical keywords, and soft/hard assertions becomes:
✔ Scalable ✔ Maintainable ✔ Readable ✔ Domain-aligned ✔ Resistant to UI changes
This approach is especially strong for complex systems like claims processing applications, where workflows evolve frequently.