-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
playwright test automation framework
- Loading branch information
0 parents
commit ddf9ff6
Showing
15 changed files
with
539 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ENV=qa | ||
URL=https://www.google.com/ | ||
USER_NAME=1234DF | ||
PASSWORD=DFGHJK67 | ||
|
||
API_BASE_URI=https://restful-booker.herokuapp.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Playwright Tests | ||
on: | ||
push: | ||
branches: [ main, master ] | ||
pull_request: | ||
branches: [ main, master ] | ||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Install Playwright Browsers | ||
run: npx playwright install --with-deps | ||
- name: Run Playwright tests | ||
run: npx playwright test | ||
- uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "playwrightbaseautomationframework", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": {}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@faker-js/faker": "^8.4.0", | ||
"@playwright/test": "^1.41.2", | ||
"@types/node": "^20.11.16" | ||
}, | ||
"dependencies": { | ||
"csv-parse": "^5.5.3", | ||
"dotenv": "^16.4.1", | ||
"luxon": "^3.4.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Inlcude playwright module | ||
const { expect } = require('@playwright/test') | ||
|
||
// create class | ||
exports.HomePage = class HomePage { | ||
|
||
/** | ||
* | ||
* @param {import ('@playwright/test').Page} page | ||
*/ | ||
constructor(page){ | ||
// Init page object | ||
this.page = page; | ||
|
||
// Elements | ||
this.searchTextbox = page.locator('#APjFqb'); | ||
} | ||
|
||
async goto(){ | ||
await this.page.setViewportSize({width:1366, height:728}) | ||
await this.page.goto(process.env.URL); | ||
} | ||
|
||
async searchKeywords(param1){ | ||
await expect(this.searchTextbox).toBeEnabled(); | ||
await this.searchTextbox.click(); | ||
await this.searchTextbox.fill(param1); | ||
await this.searchTextbox.press('Enter'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Inlcude playwright module | ||
const { expect } = require('@playwright/test') | ||
|
||
// create class | ||
exports.PlaylistPage = class PlaylistPage { | ||
|
||
/** | ||
* | ||
* @param {import ('@playwright/test').Page} page | ||
*/ | ||
constructor(page){ | ||
// Init page object | ||
this.page = page; | ||
|
||
// Elements | ||
this.videoLink = page.locator('#container > #thumbnail'); | ||
} | ||
|
||
async clickOnVideo(){ | ||
await this.page.waitForTimeout(3000); | ||
await expect(this.videoLink.first()).toBeEnabled(); | ||
await this.videoLink.first().click(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Inlcude playwright module | ||
const { expect } = require('@playwright/test') | ||
|
||
// create class | ||
exports.ResultPage = class ResultPage { | ||
|
||
/** | ||
* | ||
* @param {import ('@playwright/test').Page} page | ||
*/ | ||
constructor(page){ | ||
// Init page object | ||
this.page = page; | ||
|
||
// Elements | ||
this.playlistlink = page.getByRole('link',{name:'Playwright by Testers Talk'}); | ||
} | ||
|
||
async clickOnPlaylist(){ | ||
await expect(this.playlistlink.first()).toBeEnabled(); | ||
await this.playlistlink.first().click(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// @ts-check | ||
const { defineConfig, devices } = require('@playwright/test'); | ||
|
||
// Read environment variables from file. | ||
require('dotenv').config(); | ||
|
||
/** | ||
* @see more at https://bit.ly/playwright-tutorial-automation-testing | ||
*/ | ||
module.exports = defineConfig({ | ||
// test timeout | ||
timeout: 5 * 60 * 1000, | ||
|
||
testDir: './tests', | ||
/* Run tests in files in parallel */ | ||
fullyParallel: false, | ||
/* 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 : 1, | ||
// Reporter | ||
reporter:[ | ||
['html'], | ||
// ['allure-playwright'], | ||
['junit', { outputFile: 'test-results/e2e-junit-results.xml' }], | ||
], | ||
|
||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
// baseURL: 'http://127.0.0.1:3000', | ||
|
||
// launchOptions: { | ||
// args: ["--start-fullscreen"] | ||
// }, | ||
|
||
// video, screenshot, headless mode | ||
video:'on', | ||
screenshot: 'on', | ||
headless : false, | ||
|
||
// custom attribute | ||
testIdAttribute: 'autocomplete', | ||
|
||
// Collect trace when retrying the failed test | ||
trace: 'on', | ||
}, | ||
|
||
/* 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, | ||
// }, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"firstname": "testers talk playwright", | ||
"lastname": "testers talk api testing", | ||
"totalprice": 1000, | ||
"depositpaid": true, | ||
"bookingdates": { | ||
"checkin": "2024-01-01", | ||
"checkout": "2024-02-01" | ||
}, | ||
"additionalneeds": "super bowls" | ||
} |
Oops, something went wrong.