Skip to content

Commit

Permalink
ScreenshotTest
Browse files Browse the repository at this point in the history
  • Loading branch information
An5hul-Choudhary committed Apr 18, 2024
1 parent ca5023a commit de3ac16
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/ScreenshotTest.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const {test, expect} = require('@playwright/test');
const exp = require('constants');


test("More Validation test", async ({page}) => {

await page.goto("https://rahulshettyacademy.com/AutomationPractice/");

expect(await page.locator("#displayed-text")).toBeVisible();
await page.locator("#displayed-text").screenshot({path: 'elementScreenshot.png'});// Taking element screenshot

await page.locator("#hide-textbox").click();
await page.screenshot({path: 'screenshot.png'}); // Taking full page screenshot

expect(await page.locator("#displayed-text")).toBeHidden();

page.on('dialog', dialog => dialog.accept());
await page.locator("#confirmbtn").click();

await page.locator('#mousehover').hover();

const frameObj = page.frameLocator("#courses-iframe");
const students =await frameObj.locator(".count-text").first().textContent();
console.log('Total students are: ' + students);
const courses =await frameObj.locator(".count-text").nth(1).textContent();
console.log('Total courses are: ' + courses);
const projects =await frameObj.locator(".count-text").nth(3).textContent();
console.log('Total projects are: ' + projects);

})

test.only("Screenshot comparison", async({page}) => {

await page.goto("https://www.google.com/");
expect(await page.screenshot()).toMatchSnapshot('landing.png');

})

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit de3ac16

Please sign in to comment.