-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Request aborts and getting the api for request and
response
- Loading branch information
1 parent
3e1acf7
commit ca5023a
Showing
3 changed files
with
64 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
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 @@ | ||
const { test,expect } = require('@playwright/test'); | ||
|
||
|
||
test('@QW Security test request intercept', async ({ page }) => { | ||
|
||
//login and reach orders page | ||
await page.goto("https://rahulshettyacademy.com/client"); | ||
await page.locator("#userEmail").fill("anshika@gmail.com"); | ||
await page.locator("#userPassword").type("Iamking@000"); | ||
await page.locator("[value='Login']").click(); | ||
await page.waitForLoadState('networkidle'); | ||
await page.locator(".card-body b").first().waitFor(); | ||
|
||
await page.locator("button[routerlink*='myorders']").click(); | ||
await page.route("https://rahulshettyacademy.com/api/ecom/order/get-orders-details?id=*", | ||
route => route.continue({ url: 'https://rahulshettyacademy.com/api/ecom/order/get-orders-details?id=621661f884b053f6765465b6' })) | ||
await page.locator("button:has-text('View')").first().click(); | ||
await expect(page.locator("p").last()).toHaveText("You are not authorize to view this order"); | ||
|
||
}) |
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,43 @@ | ||
const {test, expect} = require('@playwright/test'); | ||
const { timeLog } = require('console'); | ||
const exp = require('constants'); | ||
|
||
|
||
|
||
test('First Playwright test without cookies', async ({ page }) => { | ||
|
||
const userName = page.locator('#username'); | ||
const passWord = page.locator("input[id='password']"); | ||
const signIn = page.locator("[name='signin']"); | ||
const cardTitles = page.locator(".card-body a"); | ||
|
||
page.route('**/*.{png,jpg,jpeg}', route => route.abort()); | ||
|
||
page.on('request', request => console.log(request.url())); | ||
page.on('response', response => console.log(response.url(), response.status())); | ||
await page.goto("https://rahulshettyacademy.com/loginpagePractise/"); | ||
console.log(await page.title()); | ||
// await expect(page).toHaveTitle("Google"); | ||
|
||
//#username or //input[@id='username'] | ||
await userName.fill("rahulshetty") | ||
//#password or //input[@id='password'] | ||
await passWord.fill("learning"); | ||
|
||
await signIn.click(); | ||
console.log(await page.locator("[style*='block']").textContent()); | ||
await expect(page.locator("[style*='block']")).toContainText('Incorrect'); | ||
|
||
// Enterning correct details now | ||
await userName.fill(""); | ||
await userName.fill("rahulshettyacademy"); | ||
await signIn.click(); | ||
|
||
console.log(await cardTitles.nth(0).textContent()); // it will wait until the DOM is attached so after this the next step of displaying all card titles is not failing | ||
const allTitles = await cardTitles.allTextContents(); //allTextContent returns array it can return 0 and many elements but playwright will not be able to understand how much to wait but in above it is sure that it will return one element only so it waits for that | ||
console.log(allTitles); | ||
|
||
|
||
|
||
}); | ||
|