|
|
@@ -0,0 +1,96 @@
|
|
|
+const { chromium } = require('playwright');
|
|
|
+const fs = require('fs');
|
|
|
+const path = require('path');
|
|
|
+
|
|
|
+(async () => {
|
|
|
+ const browser = await chromium.launch();
|
|
|
+ const page = await browser.newPage();
|
|
|
+
|
|
|
+ try {
|
|
|
+ await page.goto('http://localhost:8080/talent-mini/', { waitUntil: 'networkidle', timeout: 30000 });
|
|
|
+
|
|
|
+ // Wait for page to be fully loaded
|
|
|
+ await page.waitForTimeout(2000);
|
|
|
+
|
|
|
+ // Get page text content
|
|
|
+ const pageText = await page.textContent('body');
|
|
|
+
|
|
|
+ // Check for agreement text
|
|
|
+ const hasAgreement = pageText.includes('用户协议') || pageText.includes('隐私政策');
|
|
|
+ const hasLoginPage = pageText.includes('人才登录') || pageText.includes('登录');
|
|
|
+ const hasTalentPlatform = pageText.includes('人才服务平台');
|
|
|
+ const hasWelcome = pageText.includes('欢迎回来');
|
|
|
+
|
|
|
+ // Get form elements
|
|
|
+ const identifierInput = await page.$('[data-testid="talent-identifier-input"]');
|
|
|
+ const passwordInput = await page.$('[data-testid="talent-password-input"]');
|
|
|
+ const loginButton = await page.$('[data-testid="talent-login-button"]');
|
|
|
+
|
|
|
+ // Check for "忘记密码" text
|
|
|
+ const forgotPasswordText = await page.evaluate(() => {
|
|
|
+ const elements = Array.from(document.querySelectorAll('*'));
|
|
|
+ return elements.some(el => el.textContent && el.textContent.includes('忘记密码'));
|
|
|
+ });
|
|
|
+
|
|
|
+ // Get page title
|
|
|
+ const title = await page.title();
|
|
|
+
|
|
|
+ console.log('========================================');
|
|
|
+ console.log('人才小程序登录页面验证结果');
|
|
|
+ console.log('========================================');
|
|
|
+ console.log('页面标题:', title);
|
|
|
+ console.log('');
|
|
|
+ console.log('【内容验证】');
|
|
|
+ console.log(' ✓ 包含"人才服务平台":', hasTalentPlatform ? '是' : '否');
|
|
|
+ console.log(' ✓ 包含"欢迎回来":', hasWelcome ? '是' : '否');
|
|
|
+ console.log(' ✓ 包含"人才登录":', hasLoginPage ? '是' : '否');
|
|
|
+ console.log(' ✗ 包含"用户协议"或"隐私政策":', hasAgreement ? '是(未注释,需处理)' : '否(已正确注释)');
|
|
|
+ console.log('');
|
|
|
+ console.log('【表单元素验证】');
|
|
|
+ console.log(' ✓ 身份证/手机号输入框:', identifierInput ? '存在' : '不存在');
|
|
|
+ console.log(' ✓ 密码输入框:', passwordInput ? '存在' : '不存在');
|
|
|
+ console.log(' ✓ 登录按钮:', loginButton ? '存在' : '不存在');
|
|
|
+ console.log(' ✓ 忘记密码链接:', forgotPasswordText ? '存在' : '不存在');
|
|
|
+ console.log('========================================');
|
|
|
+
|
|
|
+ // Save screenshot to project directory
|
|
|
+ const screenshotPath = '/mnt/code/188-179-template-6/talent-login-verify.png';
|
|
|
+ await page.screenshot({ path: screenshotPath, fullPage: true });
|
|
|
+ console.log('截图已保存:', screenshotPath);
|
|
|
+
|
|
|
+ // Additional checks - verify the specific elements are visible
|
|
|
+ const pageTitleVisible = await page.isVisible('[data-testid="talent-page-title"]');
|
|
|
+ const loginBtnText = await loginButton ? page.textContent('[data-testid="talent-login-button"]') : 'N/A';
|
|
|
+
|
|
|
+ console.log('');
|
|
|
+ console.log('【详细元素状态】');
|
|
|
+ console.log(' 页面标题可见:', pageTitleVisible);
|
|
|
+ console.log(' 登录按钮文字:', loginBtnText);
|
|
|
+
|
|
|
+ // Determine overall result
|
|
|
+ const allGood =
|
|
|
+ hasTalentPlatform &&
|
|
|
+ hasLoginPage &&
|
|
|
+ !hasAgreement &&
|
|
|
+ identifierInput &&
|
|
|
+ passwordInput &&
|
|
|
+ loginButton &&
|
|
|
+ forgotPasswordText;
|
|
|
+
|
|
|
+ console.log('');
|
|
|
+ console.log('========================================');
|
|
|
+ if (allGood) {
|
|
|
+ console.log('✓ 验证通过:登录页面显示正常,用户协议/隐私政策已正确注释');
|
|
|
+ } else if (hasAgreement) {
|
|
|
+ console.log('✗ 验证失败:用户协议/隐私政策未被注释');
|
|
|
+ } else {
|
|
|
+ console.log('△ 部分验证通过:请检查上述元素状态');
|
|
|
+ }
|
|
|
+ console.log('========================================');
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
+ console.error('验证过程中出错:', error.message);
|
|
|
+ } finally {
|
|
|
+ await browser.close();
|
|
|
+ }
|
|
|
+})();
|