dom-probe.mjs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. import { chromium } from 'playwright'
  2. const b = await chromium.launch()
  3. const ctx = await b.newContext({ viewport: { width: 1600, height: 900 } })
  4. const p = await ctx.newPage()
  5. await p.goto('http://localhost:8080/')
  6. await p.fill('input[placeholder="请输入账号"]', 'admin')
  7. await p.fill('input[placeholder="请输入密码"]', '123456')
  8. await p.click('button.login-btn')
  9. await p.waitForTimeout(1500)
  10. await p.goto('http://localhost:8080/#/customization/hsbc/equity-products/add')
  11. await p.waitForTimeout(2500)
  12. // inspect first quill-editor
  13. const html = await p.evaluate(() => {
  14. const el = document.querySelector('.ql-toolbar')
  15. if (!el) return 'no toolbar'
  16. const root = el.parentElement
  17. return {
  18. rootTag: root.tagName,
  19. rootClass: root.className,
  20. rootStyle: getComputedStyle(root).cssText.slice(0, 400),
  21. childCount: root.children.length,
  22. children: Array.from(root.children).map(c => ({
  23. tag: c.tagName,
  24. cls: c.className,
  25. display: getComputedStyle(c).display,
  26. width: getComputedStyle(c).width,
  27. height: getComputedStyle(c).height
  28. }))
  29. }
  30. })
  31. console.log(JSON.stringify(html, null, 2))
  32. await b.close()