check-html.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. const { chromium } = require('playwright');
  2. (async () => {
  3. const browser = await chromium.launch({ headless: true });
  4. const page = await browser.newPage();
  5. await page.goto('http://localhost:5173/#/pages/video-generator/create', {
  6. waitUntil: 'networkidle',
  7. timeout: 30000
  8. });
  9. await page.waitForTimeout(5000);
  10. // 获取页面HTML
  11. const html = await page.content();
  12. // 查找第一个 input 元素
  13. const inputMatch = html.match(/<input[^>]*class="form-input"[^>]*>/i);
  14. if (inputMatch) {
  15. console.log('找到 input 元素:');
  16. console.log(inputMatch[0]);
  17. // 检查是否有 disabled 或 hidden 属性
  18. const inputAttrs = inputMatch[0];
  19. if (inputAttrs.includes('disabled')) {
  20. console.log('\n⚠️ input 有 disabled 属性');
  21. }
  22. if (inputAttrs.includes('hidden')) {
  23. console.log('\n⚠️ input 有 hidden 属性');
  24. }
  25. } else {
  26. console.log('未找到带 form-input 类的 input 元素');
  27. }
  28. // 尝试用 JavaScript 检查
  29. const inputInfo = await page.evaluate(() => {
  30. const input = document.querySelector('input.form-input');
  31. if (!input) return { found: false };
  32. return {
  33. found: true,
  34. tagName: input.tagName,
  35. className: input.className,
  36. placeholder: input.placeholder,
  37. disabled: input.disabled,
  38. hidden: input.hidden,
  39. offsetWidth: input.offsetWidth,
  40. offsetHeight: input.offsetHeight,
  41. rect: input.getBoundingClientRect(),
  42. style: {
  43. display: getComputedStyle(input).display,
  44. visibility: getComputedStyle(input).visibility,
  45. opacity: getComputedStyle(input).opacity,
  46. width: getComputedStyle(input).width,
  47. height: getComputedStyle(input).height,
  48. },
  49. parentStyle: {
  50. display: getComputedStyle(input.parentElement).display,
  51. visibility: getComputedStyle(input.parentElement).visibility,
  52. }
  53. };
  54. });
  55. console.log('\nJavaScript 检查结果:');
  56. console.log(JSON.stringify(inputInfo, null, 2));
  57. await browser.close();
  58. })();