talent-login-verify.spec.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { test, expect, Page } from '@playwright/test';
  2. test.describe('人才小程序登录页面验证', () => {
  3. test('截图并验证登录页面', async ({ page }) => {
  4. // 使用移动端视口
  5. await page.setViewportSize({ width: 375, height: 667 });
  6. console.log('导航到人才小程序登录页面...');
  7. await page.goto('http://localhost:10087', {
  8. waitUntil: 'networkidle',
  9. timeout: 30000
  10. });
  11. // 等待页面加载
  12. await page.waitForTimeout(3000);
  13. console.log('截取页面截图...');
  14. await page.screenshot({
  15. path: '/mnt/code/188-179-template-6/talent-login-screenshot.png',
  16. fullPage: true
  17. });
  18. // 获取页面文本内容
  19. const bodyText = await page.evaluate(() => document.body.innerText);
  20. console.log('页面文本内容预览:', bodyText.substring(0, 500));
  21. // 检查是否有用户协议和隐私政策相关文字
  22. const hasUserAgreement = bodyText.includes('用户协议');
  23. const hasPrivacyPolicy = bodyText.includes('隐私政策');
  24. console.log('包含"用户协议":', hasUserAgreement);
  25. console.log('包含"隐私政策":', hasPrivacyPolicy);
  26. // 验证用户协议和隐私政策不应该出现(应该被注释掉了)
  27. expect(hasUserAgreement).toBe(false);
  28. expect(hasPrivacyPolicy).toBe(false);
  29. });
  30. });