Files
OHTU-German-learning-website/gradesa/playwright/e2e/page-analyzer.spec.js
T
2026-09-01 13:35:42 +00:00

60 lines
1.9 KiB
JavaScript

import { test } from "@playwright/test";
import { elementExists } from "./utils/helpers.js";
test.describe("Page Structure Analysis", () => {
test("analyze homepage structure", async ({ page }) => {
test.setTimeout(60000);
await page.goto("", { waitUntil: "domcontentloaded", timeout: 60000 });
await page.screenshot({ path: "tests/e2e/screenshots/homepage.png" });
console.log("Page title:", await page.title());
const hasNav = await elementExists(page, "nav");
console.log("Has navigation:", hasNav);
const hasMain = await elementExists(page, "main");
console.log("Has main content:", hasMain);
const hasFooter = await elementExists(page, "footer");
console.log("Has footer:", hasFooter);
const links = await page.locator("a").all();
console.log("Number of links:", links.length);
// Log first 10 links to avoid overwhelming output
for (const link of links.slice(0, 10)) {
const href = await link.getAttribute("href");
const text = await link.textContent();
const isVisible = await link.isVisible();
console.log(
`Link: href="${href}", text="${text?.trim()}", visible=${isVisible}`
);
}
});
test("analyze learning page structure", async ({ page }) => {
test.setTimeout(60000);
await page.goto("learning", {
waitUntil: "domcontentloaded",
timeout: 60000,
});
await page.screenshot({ path: "tests/e2e/screenshots/learning.png" });
console.log("Page title:", await page.title());
const hasH1 = await elementExists(page, "h1");
console.log("Has h1:", hasH1);
const hasLanguageToggle = await elementExists(
page,
'[role="group"][aria-label="Choose language"]'
);
console.log("Has language toggle group:", hasLanguageToggle);
const hasButtons = await elementExists(page, "button");
console.log("Has buttons:", hasButtons);
});
});