.tmp-drawer.mjs 1.5 KB

123456789101112131415161718192021
  1. import { chromium } from 'playwright';
  2. const base = 'http://localhost:4200';
  3. const b = await chromium.launch({ channel: 'msedge' });
  4. const ctx = await b.newContext({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true,
  5. userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 Mobile/15E148 Safari/604.1' });
  6. const p = await ctx.newPage();
  7. await p.goto(base + '/login'); await p.waitForTimeout(900);
  8. await p.locator('input').nth(0).fill('13800000000');
  9. await p.getByRole('button', { name: /获取验证码/ }).first().click(); await p.waitForTimeout(400);
  10. await p.locator('input').nth(1).fill('123456');
  11. await p.getByRole('button', { name: /^登\s*录$/ }).first().click(); await p.waitForTimeout(3500);
  12. // 建一条会话
  13. await p.getByRole('button', { name: '新建对话' }).first().click(); await p.waitForTimeout(700);
  14. await p.locator('.pick-row').first().click(); await p.waitForTimeout(2500);
  15. await p.locator('textarea').first().fill('抽屉测试'); await p.locator('textarea').first().press('Enter'); await p.waitForTimeout(2500);
  16. await p.goto(base + '/mobile/chat-index'); await p.waitForTimeout(2500);
  17. const txt = await p.evaluate(() => document.body.innerText);
  18. console.log('LIST:', txt.slice(0, 200).replace(/\n/g, ' | '));
  19. await p.getByRole('button', { name: '打开会话抽屉' }).click(); await p.waitForTimeout(900);
  20. console.log('DRAWER:', (await p.evaluate(() => document.body.innerText)).slice(0, 300).replace(/\n/g, ' | '));
  21. await b.close();