-
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
e8bbed0
commit 4c12123
Showing
7 changed files
with
207 additions
and
52 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
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,10 @@ | ||
import test from "@playwright/test"; | ||
import { Console, log } from "console"; | ||
|
||
test("iframe", async ({ page }) => { | ||
await page.goto("http://rahulshettyacademy.com/AutomationPractice/"); | ||
const framesPage = await page.frameLocator("#courses-iframe"); | ||
framesPage.locator("li a[href*='lifetime-access]:visible").click(); | ||
const textCheck = await framesPage.locator(".text h2").textContent(); | ||
console.log(textCheck); | ||
}); |
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 @@ | ||
import test from "@playwright/test"; | ||
import { ApiHelper } from "../../../helper/api/apiHelper"; | ||
|
||
let token: string; | ||
|
||
test.beforeAll(async ({ browser }) => { | ||
const context = await browser.newContext(); | ||
const apiContent = await context.newPage(); | ||
const apiHelper = new ApiHelper(apiContent); | ||
|
||
//save token value returned from getToken() function in token variable | ||
token = await apiHelper.getToken(); | ||
}); | ||
|
||
test("Network Test -> Inject token generated through API into browser", async ({ | ||
page, | ||
}) => { | ||
//executed JavaScript to inject token into browser | ||
page.addInitScript((value) => { | ||
window.localStorage.setItem("token", value); | ||
}, token); | ||
|
||
//when script hits URL, browser will open as logged in using above generated token | ||
await page.goto("https://www.xxxx.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,29 @@ | ||
import test from "@playwright/test"; | ||
|
||
let fakePayloadOrders = { data: [], message: "No Users" }; | ||
|
||
test("Intercept Network call and Fake API response", async ({ page }) => { | ||
await page.goto("http://xxxx.com"); | ||
await page.route("http://xxxx.com/abc/ird", async (route) => { | ||
//go the response | ||
const response = await page.request.fetch(route.request()); | ||
let body = JSON.stringify(fakePayloadOrders); | ||
|
||
//send response to browser and override respond body | ||
route.fulfill({ | ||
status: 200, | ||
body: body, | ||
}); | ||
}); | ||
}); | ||
|
||
test("Intercept Network request", async ({ page }) => { | ||
await page.goto("http://xxxx.com"); | ||
|
||
//intercept request send to server & respond by url value passed in route.continue | ||
await page.route("http://xxxx.com/abc/ird", async (route) => { | ||
route.continue({ | ||
url: "http://xxxx.com/abc/123455", | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.