-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5417632
commit da7553d
Showing
6 changed files
with
61 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { it, describe, expect, vi } from 'vitest'; | ||
import { sleep } from '@midscene/core/utils'; | ||
import { launchPage } from './utils'; | ||
import { PuppeteerAgent } from '@/puppeteer'; | ||
|
||
vi.setConfig({ | ||
testTimeout: 60 * 1000, | ||
}); | ||
|
||
describe('puppeteer integration', () => { | ||
it('search headphones on ebay', async () => { | ||
const page = await launchPage('https://www.ebay.com'); | ||
const mid = new PuppeteerAgent(page); | ||
|
||
// perform a search | ||
await mid.aiAction('type "Headphones" in search box, hit Enter'); | ||
await sleep(5000); | ||
|
||
// find the items | ||
const items = await mid.aiQuery( | ||
'{itemTitle: string, price: Number}[], find item in list and corresponding price', | ||
); | ||
console.log('headphones in stock', items); | ||
expect(items.length).toBeGreaterThanOrEqual(2); | ||
}); | ||
|
||
it('extract the Github service status', async () => { | ||
const page = await launchPage('https://www.githubstatus.com/'); | ||
const mid = new PuppeteerAgent(page); | ||
|
||
const result = await mid.aiQuery( | ||
'this is a service status page. Extract all status data with this scheme: {[serviceName]: [statusText]}', | ||
); | ||
console.log('Github service status', result); | ||
}); | ||
}); |