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