Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
lucgagan committed Nov 11, 2023
1 parent 2a1892c commit 325c001
Show file tree
Hide file tree
Showing 20 changed files with 571 additions and 5,775 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist
node_modules
test-results
.env
22 changes: 0 additions & 22 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,6 @@ furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
MIT License

Copyright (c) 2023 zerostep

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand Down
31 changes: 22 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,25 @@ $ export export OPENAI_API_KEY='sk-..."
3. Import and use the `auto` function:
```ts
import { test } from "@playwright/test";
import { test, expect } from "@playwright/test";
import { auto } from "auto-playwright";
test("auto Playwright example", async ({ page }) => {
await page.goto("https://ray.run/ask");
await page.goto("/");
const headerText = await auto("Get the header text", { page, test });
// `auto` can be used to query data
// In this case, the result is plain-text contents of the header
const headerText = await auto("get the header text", { page, test });
// `auto` can be used to perform actions
// In this case, auto will find and fill in the search text input
await auto(`Type "${headerText}" in the search box`, { page, test });
await auto("Press enter", { page, test });
// `auto` can assert the state of the website
// In this case, the result is a boolean outcome
const searchInputHasHeaderText = await auto(`Is the contents of the search box equal to "${headerText}"?` { page, test });
expect(searchInputHasHeaderText).toBe(true);
});
```
Expand All @@ -42,7 +51,7 @@ auto("<your prompt>", { page, test });
## Supported Browsers
This package only supports executing `auto` steps in Chromium browsers.
Every browser that Playwright supports.
## Additional Options
Expand All @@ -52,8 +61,6 @@ There are additional options you can pass as a third argument:
const options = {
// If true, debugging information is returned from the auto() call.
debug: boolean,
// Forces the ai step to be interpreted as the specified type.
type: "action" | "assert" | "query",
// The OpenAI model (https://platform.openai.com/docs/models/overview)
model: "gpt-4-1106-preview",
};
Expand Down Expand Up @@ -100,6 +107,12 @@ const thereAreThreeLinks = await auto("Are there 3 links on the page?", {
console.log(`"There are 3 links" is a ${thereAreThreeLinks} statement`);
```
## Acknowledgements
## Supported Playwright Actions
* `page.goto`
* `locator.getAttribute`
* `locator.innerHTML`
* `locator.innerText`
* `locator.fill`
Large parts of this project mirror https://github.com/zerostep-ai/zerostep.
Adding new actions is easy: just update the `functions` in [`src/completeTask.ts`](src/completeTask.ts).
Loading

0 comments on commit 325c001

Please sign in to comment.