-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f81d29c
commit e8bbed0
Showing
7 changed files
with
84 additions
and
27 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
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,8 @@ | ||
import { test, request } from "@playwright/test"; | ||
import { ApiHelper } from "../../../helper/api/apiHelper"; | ||
|
||
test("sample get requet", async () => { | ||
const apiContext = await request.newContext(); | ||
const apiHelper = new ApiHelper(apiContext); | ||
apiHelper.invokeGetApi(); | ||
}); |
This file was deleted.
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,31 @@ | ||
import { test, BrowserContext } from "@playwright/test"; | ||
import { WebHelper } from "../../../helper/web/webHelper.js"; | ||
|
||
let webContext: any; | ||
|
||
/* The `test.beforeAll()` function is a hook provided by the Playwright test framework. It is used to | ||
run a setup function before all the tests in a test file. In this hook, we will login into application and save login details in state.json file*/ | ||
test.beforeAll( | ||
"Login into web app through browser and save login detail in JSON", | ||
async ({ browser }) => { | ||
const browserContext = await browser.newContext(); | ||
const webPage = await browserContext.newPage(); | ||
const webHelper = new WebHelper(webPage, browserContext); | ||
webHelper.navigateToUrl("www.gmail.com"); | ||
|
||
//write code to login in gmail | ||
|
||
await browserContext.storageState({ path: "state.json" }); | ||
webContext = await browserContext.newContext({ | ||
storageState: "state.json", | ||
}); | ||
await webPage.close(); | ||
} | ||
); | ||
/* The code you provided is a test case that logs into a web application using the saved login state. */ | ||
test("Login into web app using saved login state", async () => { | ||
const webPage = await webContext.newPage(); | ||
|
||
const webHelper = new WebHelper(webPage, webContext); | ||
webHelper.navigateToUrl("www.gmail.com"); // Browser will open page using login details saved in test.beforeAll() step | ||
}); |
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
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
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,13 @@ | ||
import test from "@playwright/test"; | ||
|
||
test(`Generate HAR file`, async ({ page: Page }, testInfo) => { | ||
// To record HAR file, use "update:true", below code will create a directory named har and | ||
//store all the har related files in it | ||
await Page.routeFromHAR("har/example.har", { update: true }); | ||
|
||
/* The `await testInfo.attach(`HAR FILE`, { path: `../../../../har/example.har` });` line is | ||
attaching the generated HAR file to the test report. It allows the HAR file to be easily | ||
accessible and viewable alongside the test results. The `path` parameter specifies the location of | ||
the HAR file. */ | ||
await testInfo.attach(`HAR FILE`, { path: `../../../../har/example.har` }); | ||
}); |