Skip to content
Snippets Groups Projects
Commit 2878ccbe authored by Jens Grochtdreis's avatar Jens Grochtdreis
Browse files

Screenshot Spec erweitert und korrigiert

parent 9f1bc24f
No related branches found
No related tags found
No related merge requests found
const playwright = require('playwright');
const { test} = require('@playwright/test');
const { test,expect} = require('@playwright/test');
test("Screenshot Marketingseite", async({ page }) => {
await page.goto("https://www.tatort-game.de/index.html");
......@@ -8,8 +8,12 @@ test("Screenshot Marketingseite", async({ page }) => {
test("SWR Startseite", async({ page }) => {
await page.goto("https://www.swr.de/index.html");
await page.screenshot({ path: "screenshots/swr/startseite-full.png", fullPage: true });
await page.screenshot({ path: "screenshots/swr/startseite.png", fullPage: false });
// Chill until the network is idle
await page.waitForLoadState('networkidle');
await page.evaluate(scroll, {direction: "down", speed: "slow"});
// await page.evaluate(scroll, {direction: "up", speed: "fast"});
await expect(page).toHaveScreenshot({ path: "screenshots/swr/startseite.png", fullPage: false });
await expect(page).toHaveScreenshot({ path: "screenshots/swr/startseite-full.png", fullPage: true });
})
test("SWR Logo", async({ page }) => {
......@@ -31,4 +35,19 @@ test("SWR Logo - multipel", async({ page }) => {
test("Pagination", async({ page }) => {
await page.goto("http://localhost:3020/components/preview/pagination--default");
await page.locator('.pagination').screenshot({ path: 'screenshots/swr/module/pagination/pagination.png' });
})
\ No newline at end of file
})
let scroll = async (args) => {
const {direction, speed} = args;
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
const scrollHeight = () => document.body.scrollHeight;
const start = direction === "down" ? 0 : scrollHeight();
const shouldStop = (position) => direction === "down" ? position > scrollHeight() : position < 0;
const increment = direction === "down" ? 100 : -100;
const delayTime = speed === "slow" ? 50 : 10;
console.error(start, shouldStop(start), increment)
for (let i = start; !shouldStop(i); i += increment) {
window.scrollTo(0, i);
await delay(delayTime);
}
};
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment