shinkan-jinkendo/test-shinkan.js
Lars 3b2c3605fd
All checks were successful
Deploy Development / deploy (push) Successful in 47s
Add Playwright tests for Shinkan login page
- Created test-login.js to automate testing of the Shinkan login page, including waiting for deployment, capturing page title, heading, and counting elements (buttons, forms, inputs).
- Implemented functionality to log button texts and input placeholders, and take a full-page screenshot.
- Created test-shinkan.js to streamline the login page testing process, removing the deployment wait and adding a preview of the page content.
2026-04-22 06:45:48 +02:00

57 lines
1.9 KiB
JavaScript

const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
console.log('=== Testing Shinkan Login Page ===\n');
try {
await page.goto('http://192.168.2.49:3098', { waitUntil: 'networkidle', timeout: 10000 });
const title = await page.title();
console.log('📄 Title:', title);
const h1 = await page.textContent('h1').catch(() => null);
console.log('🥋 Heading:', h1);
const buttons = await page.locator('button').count();
const forms = await page.locator('form').count();
const inputs = await page.locator('input').count();
console.log('\n🔍 Elements Found:');
console.log(' - Buttons:', buttons);
console.log(' - Forms:', forms);
console.log(' - Inputs:', inputs);
if (buttons > 0) {
console.log('\n🔘 Buttons:');
for (let i = 0; i < buttons; i++) {
const text = await page.locator('button').nth(i).textContent();
console.log(` ${i + 1}. "${text}"`);
}
}
if (inputs > 0) {
console.log('\n📝 Inputs:');
for (let i = 0; i < inputs; i++) {
const placeholder = await page.locator('input').nth(i).getAttribute('placeholder');
const type = await page.locator('input').nth(i).getAttribute('type');
console.log(` ${i + 1}. Type: ${type}, Placeholder: "${placeholder}"`);
}
}
const bodyText = await page.evaluate(() => document.body.innerText);
console.log('\n📝 Page Content Preview:');
console.log(bodyText.substring(0, 300));
await page.screenshot({ path: 'shinkan-login-screenshot.png', fullPage: true });
console.log('\n📸 Screenshot: shinkan-login-screenshot.png');
} catch (error) {
console.error('❌ Error:', error.message);
}
await browser.close();
})();