shot-quill2.mjs 1.1 KB

1234567891011121314151617181920212223242526
  1. import { chromium } from 'playwright'
  2. const b = await chromium.launch()
  3. const ctx = await b.newContext({ viewport: { width: 1400, 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(2000)
  12. const r = await p.evaluate(() => {
  13. const fi = document.querySelector('.ql-toolbar')?.closest('.el-form-item')
  14. return {
  15. formItemHeight: fi ? getComputedStyle(fi).height : null,
  16. containerHeight: getComputedStyle(document.querySelector('.ql-container')).height,
  17. toolbarHeight: getComputedStyle(document.querySelector('.ql-toolbar')).height
  18. }
  19. })
  20. console.log(JSON.stringify(r))
  21. const tb = await p.$('.ql-toolbar')
  22. const box = await tb.boundingBox()
  23. await p.evaluate((y) => window.scrollTo(0, y - 200), box.y)
  24. await p.waitForTimeout(500)
  25. await p.screenshot({ path: 'scripts/shot-quill-fixed2.png' })
  26. await b.close()