Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
abhaybharti committed Jan 21, 2024
1 parent c65cf6b commit d4ada0c
Show file tree
Hide file tree
Showing 35 changed files with 174 additions and 26 deletions.
46 changes: 22 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
## Playwright-Framework-Template
# Playwright-Framework-Template

Ultimate test automation for testing any application on any platform

> [!NOTE] Don't forget to \* the repository if you like it!
## Why was PlayWright-Framework-Template created?
## Introduction

In my career having vast experience in automating Api, Web Browsers and mobile apps, I have seen that people had to use different frameworks for automation Api, Web and Mobile applications which created a lot of chaos with respect to maintenance of dependencies and their respective code for test automation.

Expand All @@ -22,23 +18,17 @@ In my career having vast experience in automating Api, Web Browsers and mobile a
- Supports Allure report generation
- Support running functional test for load testing using Artillery

## Libraries Used For Test

- PlayWright for web automation
- PlayWright for Api automation
- Artillery for load testing
- Allure for reporting
- Appium for mobile app automation

## Libraries Used For Code Consistency

- `ESLint` it's a linting tool, designed to analyze your code, pinpoint issues and guide you in rectifying potential problems in both JavaScript and TypeScript.
- `Prettier` is a tool for formatting code & maintain consistent style throughout codebase.
## Tech Stack/Libraries Used

## Libraries Used For Enviornment Variable and Secrets

- `Dotenv` to load environment variables from .env file
- `Secrets` to load secrets from AWS Secrets Manager
- [PlayWright](https://playwright.dev/) - for web automation
- [PlayWright](https://playwright.dev/) - for Api automation
- [Artillery](https://www.artillery.io/) - for load testing
- [Allure](https://allurereport.org/) - Allure for reporting
- [Appium](https://appium.io/docs/en/2.4/) - for mobile app automation
- [ESLint](https://eslint.org/) - pinpoint issues and guide you in rectifying potential problems in both JavaScript and TypeScript.
- [Prettier](https://prettier.io/) - for formatting code & maintain consistent style throughout codebase
- [Dotenv](https://www.dotenv.org/) - to load environment variables from .env file
- [Secrets](https://github.com/du5rte/secrets) - to load secrets from AWS Secrets Manager

## How to use

Expand Down Expand Up @@ -106,6 +96,14 @@ This will start running script in debug mode & open PlayWright inspector

#### Run & Generate Report

### Further Reading
## Contributing

We love our contributors! Here's how you can contribute:

- [Open an issue](https://github.com/abhaybharti/playwright-framework-template/issues) if you believe you've encountered a bug.
- Make a [pull request](https://github.com/abhaybharti/playwright-framework-template/pulls) to add new features/make quality-of-life improvements/fix bugs.

<a href="https://github.com/abhaybharti/playwright-framework-template/graphs/contributors">
<img src="https://contrib.rocks/image?repo=abhaybharti/playwright-framework-template" />
</a>

https://medium.com/@oroz.askarov/building-a-robust-automation-framework-in-playwright-typescript-version-b13be4e4bf56 https://github.com/alapanme/Playwright-Automation/blob/master/tests/2-checkBox.spec.ts
3 changes: 3 additions & 0 deletions notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Further Reading

https://medium.com/@oroz.askarov/building-a-robust-automation-framework-in-playwright-typescript-version-b13be4e4bf56 https://github.com/alapanme/Playwright-Automation/blob/master/tests/2-checkBox.spec.ts
Empty file removed src/api/utils/dbQueries.ts
Empty file.
Empty file removed src/api/utils/payloadBuilder.ts
Empty file.
Empty file removed src/api/utils/types.ts
Empty file.
Empty file removed src/api/utils/urlBuilder.ts
Empty file.
Empty file removed src/globals/global-setup.ts
Empty file.
Empty file removed src/globals/global-teardown.ts
Empty file.
Empty file removed src/globals/healthcheckup.setup.ts
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file removed src/load/loadTest.spect.ts
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppiumHelper } from "./utils/appiumHelper";
import { AppiumHelper } from "../../../helper/mobile/appiumHelper";

const androidCapabilities = {
platformName: "Android",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppiumHelper } from "./utils/appiumHelper";
import { AppiumHelper } from "../../../helper/mobile/appiumHelper";

const iOSVersion = "16.4";

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file removed src/ui/data/mock.ts
Empty file.
Empty file removed src/ui/pages/home.page.ts
Empty file.
Empty file removed src/ui/tests/homeUI.spect.ts
Empty file.
Empty file removed src/ui/tests/loginUI.spec.ts
Empty file.
Empty file removed src/ui/utils/uiConstants.ts
Empty file.
Empty file removed src/ui/utils/uiHelpers.ts
Empty file.
Empty file removed src/ui/utils/uiUtils.ts
Empty file.
87 changes: 87 additions & 0 deletions src/utils/config/azure/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { defineConfig, devices } from "@playwright/test";
import * as dotenv from "dotenv";

switch (process.env.NODE_ENV) {
case "local":
dotenv.config({ path: "./environments/local.env" });
break;
case "dev":
dotenv.config({ path: "./environments/local.env" });
break;
case "qa":
dotenv.config({ path: "./environments/qa.env" });
break;
case "prod":
dotenv.config({ path: "./environments/prod.env" });

break;

default:
break;
}
export default defineConfig({
testDir: "./src",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
},

/* Configure projects for major browsers */
projects: [
// {
// name: "chromium",
// use: { ...devices["Desktop Chrome"] },
// },

// {
// name: "firefox",
// use: { ...devices["Desktop Firefox"] },
// },

// {
// name: "webkit",
// use: { ...devices["Desktop Safari"] },
// },

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
{
name: "Microsoft Edge",
use: { ...devices["Desktop Edge"], channel: "msedge" },
},
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});
60 changes: 60 additions & 0 deletions src/utils/config/azure/playwright.service.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* This file enables Playwright client to connect to remote browsers.
* It should be placed in the same directory as playwright.config.ts.
*/

import { defineConfig } from "@playwright/test";
import config from "./playwright.config";
import dotenv from "dotenv";

// Define environment on the dev box in .env file:
// .env:
// PLAYWRIGHT_SERVICE_ACCESS_TOKEN=XXX
// PLAYWRIGHT_SERVICE_URL=XXX

// Define environment in your GitHub workflow spec.
// env:
// PLAYWRIGHT_SERVICE_ACCESS_TOKEN: ${{ secrets.PLAYWRIGHT_SERVICE_ACCESS_TOKEN }}
// PLAYWRIGHT_SERVICE_URL: ${{ secrets.PLAYWRIGHT_SERVICE_URL }}
// PLAYWRIGHT_SERVICE_RUN_ID: ${{ github.run_id }}-${{ github.run_attempt }}-${{ github.sha }}

dotenv.config();

// Name the test run if it's not named yet.
process.env.PLAYWRIGHT_SERVICE_RUN_ID = process.env.PLAYWRIGHT_SERVICE_RUN_ID || new Date().toISOString();

// Can be 'linux' or 'windows'.
const os = process.env.PLAYWRIGHT_SERVICE_OS || "linux";

export default defineConfig(config, {
// Define more generous timeout for the service operation if necessary.
// timeout: 60000,
// expect: {
// timeout: 10000,
// },
workers: 20,

// Enable screenshot testing and configure directory with expectations.
// https://learn.microsoft.com/azure/playwright-testing/how-to-configure-visual-comparisons
ignoreSnapshots: false,
snapshotPathTemplate: `{testDir}/__screenshots__/{testFilePath}/${os}/{arg}{ext}`,

use: {
// Specify the service endpoint.
connectOptions: {
wsEndpoint: `${process.env.PLAYWRIGHT_SERVICE_URL}?cap=${JSON.stringify({
// Can be 'linux' or 'windows'.
os,
runId: process.env.PLAYWRIGHT_SERVICE_RUN_ID,
})}`,
timeout: 30000,
headers: {
"x-mpt-access-key": process.env.PLAYWRIGHT_SERVICE_ACCESS_TOKEN!,
},
// Allow service to access the localhost.
exposeNetwork: "<loopback>",
},
},
// Tenmp workaround for config merge bug in OSS https://github.com/microsoft/playwright/pull/28224
projects: config.projects ? config.projects : [{}],
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file removed src/utils/constants.ts
Empty file.
Empty file removed src/utils/dbUtils.ts
Empty file.
Empty file removed src/utils/types.ts
Empty file.
Empty file removed src/utils/utils.ts
Empty file.

0 comments on commit d4ada0c

Please sign in to comment.