Skip to content
Closed
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
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BASE_URL=https://gxcapture-redbird-dc.galaxe.com:6500
USERNAME=slogan11
PASSWORD=Simlaworld@123
50 changes: 50 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Playwright Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
inputs:
base_url:
description: 'Base URL for testing'
required: false
default: 'https://gxcapture-redbird-dc.galaxe.com:6500'

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: npm ci

- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Run Playwright tests
run: npx playwright test
env:
BASE_URL: ${{ github.event.inputs.base_url || secrets.BASE_URL }}
USERNAME: ${{ secrets.TEST_USERNAME }}
PASSWORD: ${{ secrets.TEST_PASSWORD }}

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: test-results
path: test-results/
retention-days: 30
16 changes: 8 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/target/
.project
.classpath
/.settings/
/ExtentReports/
logfile.log
/test-output/
node_modules/
dist/
test-results/
playwright-report/
playwright/.auth/
blob-report/
.env
*.tsbuildinfo
252 changes: 165 additions & 87 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,87 +1,165 @@
selenium-testng-framework
---

---
A sample framework based on Page Object Model, Selenium, TestNG using Java.

This framework is based in **Page Object Model (POM).**

The framework uses:

1. Java
2. Selenium
3. TestNG
4. ExtentReport
5. Log4j
6. SimpleJavaMail

Steps to create test cases:
----
Let's say we want to automate Google search test.

1.Create GoogleSearchPage in **pages** package.
A page class typically should contain all the elements that are present on the page and corresponding action methods.

```
public class GooglePage extends BasePage {

@FindBy(name = "q")
private WebElement searchinput;

public GooglePage(WebDriver driver) {
super(driver);
}

public void searchText(String key) {
searchinput.sendKeys(key + Keys.ENTER);
}

}
```
2.Create the test class which class the methods of GoogleSearchPage

```
@Test(testName = "Google search test", description = "Test description")
public class GoogleSearchTest extends BaseTest {

@Test
public void googleSearchTest() {
driver.get("https://www.google.co.in/");
GooglePage googlePage = PageinstancesFactory.getInstance(GooglePage.class);
googlePage.searchText("abc");
Assert.assertTrue(driver.getTitle().contains("abc"), "Title doesn't contain abc : Test Failed");
}
}
```
3.Add the test class in testng.xml file under the folder `src/test/resources/suites/`

```
<suite name="Suite">
<listeners></listeners>
<test thread-count="5" name="Test" parallel="classes">
<classes>
<class name="example.example.tests.GoogleSearchTest" />
```
4.Execute the test cases by maven command `mvn clean test`

---

Reproting
---
The framework gives report in three ways,

1. Log - In file `logfile.log`.
2. A html report - Which is generated using extent reports, under the folder `ExtentReports`.
3. A mail report - For which the toggle `mail.sendmail` in `test.properties` should be set `true`. And all the properties such as `smtp host, port, proxy details, etc.,` should be provided correctly.

---

Key Points:
---

1. The class `WebDriverContext` is responsible for maintaining the same WebDriver instance throughout the test. So whenever you require a webdriver instance which has been using for current test (In current thread) always call `WebDriverContext.getDriver()`.
2. Always use `PageinstancesFactory.getInstance(type)` to get the instance of particular Page Object. (Of course you can use `new` but it's better use a single approach across the framework.

---

>For any query or suggestions please do comment or mail @ diggavibharathish@gmail.com
# GxCapture Redbird - Playwright Test Automation

Automated regression test suite for the GxCapture Redbird Benefits Management application using Playwright with TypeScript.

## Test Coverage

| Module | Test Cases | Spec File |
|--------|-----------|-----------|
| Portal Screen | TC#1-2 | `tests/portal/portal.spec.ts` |
| BM Landing Page | TC#3 | `tests/portal/bm-landing.spec.ts` |
| Manage Clients | TC#4-5 | `tests/manage-clients/manage-clients.spec.ts` |
| Manage Context | TC#6-7 | `tests/manage-context/manage-context.spec.ts` |
| Manage Definitions | TC#8 | `tests/manage-definitions/manage-definitions.spec.ts` |
| Hierarchy | TC#9 | `tests/hierarchy/hierarchy.spec.ts` |
| Templates | TC#10-13 | `tests/templates/templates.spec.ts` |
| Plans | TC#14-22 | `tests/plans/plans.spec.ts` |
| My Work Queue | TC#23-27 | `tests/my-work-queue/my-work-queue.spec.ts` |
| Roles & Privileges | TC#28-32 | `tests/roles-and-privileges/roles.spec.ts` |
| Plan Life Cycle | TC#33-46 | `tests/plan-lifecycle/plan-lifecycle.spec.ts` |
| Rules | TC#47-57 | `tests/rules/rules.spec.ts` |
| Load Definitions | TC#58-66, 70-71 | `tests/load-definitions/load-definitions.spec.ts` |
| Report Configuration | TC#67-68 | `tests/report-configuration/report-config.spec.ts` |
| Exports | TC#69 | `tests/exports/exports.spec.ts` |

**Total: 71 test cases automated across 15 modules**

## Project Structure

```
├── pages/ # Page Object Model classes
│ ├── LoginPage.ts
│ ├── PortalPage.ts
│ ├── DashboardPage.ts
│ ├── ManageClientsPage.ts
│ ├── ManageContextPage.ts
│ ├── ManageDefinitionsPage.ts
│ ├── HierarchyPage.ts
│ ├── TemplatesPage.ts
│ ├── PlansPage.ts
│ ├── MyWorkQueuePage.ts
│ ├── RolesAndPrivilegesPage.ts
│ ├── LoadDefinitionsPage.ts
│ ├── ReportConfigurationPage.ts
│ └── ValidationsPage.ts
├── tests/ # Test specifications
│ ├── auth.setup.ts # Authentication setup
│ ├── portal/
│ ├── manage-clients/
│ ├── manage-context/
│ ├── manage-definitions/
│ ├── hierarchy/
│ ├── templates/
│ ├── plans/
│ ├── my-work-queue/
│ ├── plan-lifecycle/
│ ├── rules/
│ ├── load-definitions/
│ ├── report-configuration/
│ └── exports/
├── utils/ # Helper utilities
│ ├── helpers.ts
│ └── test-config.ts
├── fixtures/ # Test data
│ └── test-data.json
├── playwright.config.ts # Playwright configuration
└── .github/workflows/ # CI/CD pipeline
└── playwright.yml
```

## Setup

### Prerequisites
- Node.js 18+
- Access to GxCapture Redbird application network

### Installation

```bash
# Install dependencies
npm install

# Install Playwright browsers
npx playwright install --with-deps
```

### Configuration

1. Copy `.env.example` to `.env`:
```bash
cp .env.example .env
```

2. Update `.env` with your credentials:
```env
BASE_URL=https://gxcapture-redbird-dc.galaxe.com:6500
USERNAME=your_username
PASSWORD=your_password
```

## Running Tests

```bash
# Run all tests
npm test

# Run tests with browser visible
npm run test:headed

# Run in debug mode (step through tests)
npm run test:debug

# Run specific module
npm run test:portal
npm run test:plans
npm run test:lifecycle
npm run test:templates
npm run test:clients
npm run test:context
npm run test:definitions
npm run test:hierarchy
npm run test:workqueue
npm run test:roles
npm run test:rules
npm run test:load
npm run test:reports
npm run test:exports

# View HTML report
npm run report
```

## CI/CD

The GitHub Actions workflow runs automatically on:
- Push to `main` branch
- Pull requests to `main`
- Manual trigger (workflow_dispatch)

### Required Secrets (GitHub Repository Settings)
- `BASE_URL` - Application base URL
- `TEST_USERNAME` - Test user username
- `TEST_PASSWORD` - Test user password

## Customization

### Updating Locators
Since this framework was built without live access to the application UI, some locators may need adjustment. Each Page Object class uses multiple locator strategies (role-based, text-based, CSS selectors) with fallbacks.

To update locators:
1. Run tests in headed mode: `npm run test:headed`
2. Use Playwright Inspector: `npm run test:debug`
3. Use Playwright Codegen: `npx playwright codegen <URL>`

### Adding New Test Cases
1. Create or update the appropriate spec file in `tests/`
2. If needed, add new Page Object methods in `pages/`
3. Follow the existing pattern of `test.describe` and `test()` blocks

## Architecture

- **Page Object Model (POM)**: Each page/screen has a dedicated class encapsulating locators and actions
- **Authentication**: Shared auth state via `storageState` - login happens once, all tests reuse the session
- **Cross-browser**: Configured for Chromium and Firefox
- **Auto-retry**: Failed tests retry once with trace capture
- **Screenshots/Videos**: Captured automatically on failure
45 changes: 45 additions & 0 deletions fixtures/test-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"testClients": {
"newClient": {
"name": "AutoTest_Client",
"description": "Client created by automated test"
}
},
"testContexts": {
"newContext": {
"name": "AutoTest_Context",
"description": "Context for automated testing"
}
},
"testDefinitions": {
"newDefinition": {
"name": "AutoTest_Definition",
"sourceType": "Excel"
}
},
"testTemplates": {
"newTemplate": {
"name": "AutoTest_Template"
}
},
"testPlans": {
"newPlan": {
"name": "AutoTest_Plan",
"context": "Default",
"template": "Default"
}
},
"testValidations": {
"rule1": {
"condition": "{Mail: Max Amount Due}=\" \"",
"message": "Max Amount cannot be blank"
}
},
"statusColors": {
"open": "grey",
"pendingReview": "orange",
"approved": "green",
"published": "darkgreen",
"rejected": "red"
}
}
Loading
Loading