test-input-fixed.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. const { chromium } = require('playwright');
  2. (async () => {
  3. const browser = await chromium.launch({ headless: true });
  4. const page = await browser.newPage();
  5. console.log('=== 测试修复后的输入框 ===\n');
  6. await page.goto('http://localhost:5173/#/pages/video-generator/create', {
  7. waitUntil: 'networkidle',
  8. timeout: 30000
  9. });
  10. await page.waitForTimeout(3000);
  11. // 使用正确的选择器
  12. console.log('1. 使用 .form-input 选择器:');
  13. const inputByClass = await page.locator('.form-input').count();
  14. console.log(` 找到 ${inputByClass} 个元素`);
  15. console.log('\n2. 使用 .uni-input 选择器:');
  16. const inputByUni = await page.locator('.uni-input').count();
  17. console.log(` 找到 ${inputByUni} 个元素`);
  18. console.log('\n3. 使用 uni-input 选择器:');
  19. const inputByTag = await page.locator('uni-input').count();
  20. console.log(` 找到 ${inputByTag} 个元素`);
  21. // 尝试在输入框中输入文字
  22. console.log('\n4. 尝试输入文字:');
  23. try {
  24. // 使用原生 input 选择器
  25. await page.locator('input[type="text"]').first().fill('测试标题123');
  26. const value = await page.locator('input[type="text"]').first().inputValue();
  27. console.log(` ✅ 输入成功,值为: "${value}"`);
  28. } catch (e) {
  29. console.log(` ❌ 输入失败: ${e.message}`);
  30. }
  31. // 截图
  32. await page.screenshot({ path: 'input-test-result.png', fullPage: true });
  33. console.log('\n5. 已保存截图: input-test-result.png');
  34. await browser.close();
  35. })();