Skip to content

Commit

Permalink
feat: update quick-start
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyutaotao committed Aug 6, 2024
1 parent 35cb07d commit 4d8fe7d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
15 changes: 11 additions & 4 deletions apps/site/docs/en/docs/getting-started/quick-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ import { expect } from "@playwright/test";
import { test } from "./fixture";

test.beforeEach(async ({ page }) => {
page.setViewportSize({ width: 400, height: 905 });
page.setViewportSize({ width: 1280, height: 800 });
await page.goto("https://www.ebay.com");
await page.waitForLoadState("networkidle");
});

test("search headphone on ebay", async ({ ai, aiQuery }) => {
test("search headphone on ebay", async ({ ai, aiQuery, aiAssert }) => {
// 👀 type keywords, perform a search
await ai('type "Headphones" in search box, hit Enter');

Expand All @@ -72,7 +72,10 @@ test("search headphone on ebay", async ({ ai, aiQuery }) => {
);

console.log("headphones in stock", items);
expect(items?.length).toBeGreaterThan(1);
expect(items?.length).toBeGreaterThan(0);

// 👀 assert by AI
await aiAssert("There is a category filter on the left");
});

```
Expand Down Expand Up @@ -138,19 +141,23 @@ Promise.resolve(
);
console.log("headphones in stock", items);

// 👀 assert by AI
await mid.aiAssert("There is a category filter on the left");

await browser.close();
})()
);
```

:::tip
You may have noticed that the key lines of code for this only consist of two lines. They are all written in plain language.
You may have noticed that the key lines of code for this only consist of three lines. They are all written in plain language.

```typescript
await mid.aiAction('type "Headphones" in search box, hit Enter');
await mid.aiQuery(
'{itemTitle: string, price: Number}[], find item in list and corresponding price',
);
await mid.aiAssert("There is a category filter on the left");
```
:::

Expand Down
11 changes: 9 additions & 2 deletions apps/site/docs/zh/docs/getting-started/quick-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ test.beforeEach(async ({ page }) => {
await page.waitForLoadState("networkidle");
});

test("search headphone on ebay", async ({ ai, aiQuery }) => {
test("search headphone on ebay", async ({ ai, aiQuery, aiAssert }) => {
// 👀 输入关键字,执行搜索
// 注:尽管这是一个英文页面,你也可以用中文指令控制它
await ai('在搜索框输入 "Headphones" ,敲回车');
Expand All @@ -75,6 +75,9 @@ test("search headphone on ebay", async ({ ai, aiQuery }) => {

console.log("headphones in stock", items);
expect(items?.length).toBeGreaterThan(0);

// 👀 用 AI 断言
await aiAssert("界面左侧有类目筛选功能");
});

```
Expand Down Expand Up @@ -144,20 +147,24 @@ Promise.resolve(
);
console.log("耳机商品信息", items);

// 👀 用 AI 断言
await mid.aiAssert("界面左侧有类目筛选功能");

await browser.close();
})()
);
```

:::tip

你可能已经注意到了,上述文件中的关键代码只有两行,且都是用自然语言编写的
你可能已经注意到了,上述文件中的关键代码只有三行,且都是用自然语言编写的

```typescript
await mid.aiAction('在搜索框输入 "Headphones" ,敲回车');
await mid.aiQuery(
'{itemTitle: string, price: Number}[], 找到列表里的商品标题和价格',
);
await mid.aiAssert("界面左侧有类目筛选功能");
```
:::

Expand Down

0 comments on commit 4d8fe7d

Please sign in to comment.