Playwright.js is an open-source automation library developed by Microsoft, primarily used for end-to-end testing and web scraping of web applications.
Here we assume you already have a repository with Playwright integration.
You can find an example project of Playwright integration here: https://github.com/web-infra-dev/midscene-example/blob/main/playwright-demo
Set your model configs into the environment variables. You may refer to choose a model for more details.
Add dependencies
Update playwright.config.ts
The type
option of the reporter
configuration can be merged
or separate
. The default value is merged
, which indicates that one merged report for all test cases; the optional value is separate
, indicating that the report is separated for each test case.
test
instanceSave the following code as ./e2e/fixture.ts
:
ai
or aiAction
- General AI interactionaiTap
- Click operationaiHover
- Hover operationaiInput
- Input operationaiKeyboardPress
- Keyboard operationaiScroll
- Scroll operationaiQuery
- AI QueryaiNumber
- Number QueryaiString
- String QueryaiBoolean
- Boolean QueryaiAssert
- AI AssertionaiWaitFor
- AI WaitaiLocate
- Locate ElementBesides the exposed shortcut methods, if you need to call other API provided by the agent, you can use agentForPage
to get the PageAgent
instance, and use PageAgent
to call the API for interaction: