mirror of
https://github.com/web-infra-dev/midscene.git
synced 2025-07-24 01:12:14 +00:00
41 lines
960 B
TypeScript
41 lines
960 B
TypeScript
![]() |
import { AiAssert } from '@midscene/core/.';
|
||
|
import { expect } from 'playwright/test';
|
||
|
import { test } from './fixture';
|
||
|
|
||
|
test.beforeEach(async ({ page }) => {
|
||
|
await page.goto('https://www.saucedemo.com/');
|
||
|
await page.setViewportSize({ width: 1920, height: 1080 });
|
||
|
});
|
||
|
|
||
|
const CACHE_TIME_OUT = process.env.MIDSCENE_CACHE;
|
||
|
|
||
|
test('ai shop', async ({
|
||
|
ai,
|
||
|
aiInput,
|
||
|
aiAssert,
|
||
|
aiQuery,
|
||
|
aiTap,
|
||
|
generateMidsceneAgent,
|
||
|
page,
|
||
|
}) => {
|
||
|
if (CACHE_TIME_OUT) {
|
||
|
test.setTimeout(1000 * 1000);
|
||
|
}
|
||
|
// login
|
||
|
const agent = await generateMidsceneAgent(page);
|
||
|
await aiInput('standard_user', 'in user name input');
|
||
|
await aiInput('secret_sauce', 'in password input');
|
||
|
await agent.aiTap('Login Button');
|
||
|
|
||
|
// check the login success
|
||
|
await aiAssert('the page title is "Swag Labs"');
|
||
|
|
||
|
// add to cart
|
||
|
await aiTap('"add to cart" for black t-shirt products');
|
||
|
|
||
|
await aiTap({
|
||
|
prompt: 'click right top cart icon',
|
||
|
deepThink: true,
|
||
|
});
|
||
|
});
|