You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Depending on the `type` of action (specified above or inferred by the `auto` function), there are different behaviors and return types.
73
+
Depending on the `type` of action (inferred by the `auto` function), there are different behaviors and return types.
74
74
75
75
### Action
76
76
77
-
**Action**: An action (e.g. "click") is some simulated user interaction with the page, e.g. a click on a link. Actions will return `undefined`` if they were successful and will throw an error if they failed, e.g.
77
+
An action (e.g. "click") is some simulated user interaction with the page, e.g. a click on a link. Actions will return `undefined`` if they were successful and will throw an error if they failed, e.g.
78
78
79
79
```ts
80
80
try {
@@ -86,7 +86,7 @@ try {
86
86
87
87
### Query
88
88
89
-
**Query**: A query will return requested data from the page as a string, e.g.
89
+
A query will return requested data from the page as a string, e.g.
90
90
91
91
```ts
92
92
const linkText = await auto("Get the text of the first link", { page, test });
@@ -96,7 +96,7 @@ console.log("The link text is", linkText);
96
96
97
97
### Assert
98
98
99
-
**Assert**: An assertion is a question that will return `true` or `false`, e.g.
99
+
An assertion is a question that will return `true` or `false`, e.g.
100
100
101
101
```ts
102
102
const thereAreThreeLinks = await auto("Are there 3 links on the page?", {
@@ -107,12 +107,49 @@ const thereAreThreeLinks = await auto("Are there 3 links on the page?", {
107
107
console.log(`"There are 3 links" is a ${thereAreThreeLinks} statement`);
108
108
```
109
109
110
+
111
+
## Why use Auto Playwright?
112
+
113
+
Certainly! Here's a rephrased version of the provided content, presented in a markdown table:
114
+
115
+
| Aspect | Conventional Approach | Testing with Auto Playwright |
|**Coupling with Markup**| Strongly linked to the application's markup. | Eliminates the use of selectors; actions are determined by the AI assistant at runtime. |
118
+
| **Speed of Implementation** | Slower implementation due to the need for precise code translation for each action. | Rapid test creation using simple, plain text instructions for actions and assertions. |
119
+
| **Handling Complex Scenarios** | Automating complex scenarios is challenging and prone to frequent failures. | Facilitates testing of complex scenarios by focusing on the intended test outcomes. |
120
+
| **Test Writing Timing** | Can only write tests after the complete development of the functionality. | Enables a Test-Driven Development (TDD) approach, allowing test writing concurrent with or before functionality development. |
121
+
110
122
## Supported Playwright Actions
111
123
112
-
* `page.goto`
113
-
* `locator.getAttribute`
114
-
* `locator.innerHTML`
115
-
* `locator.innerText`
116
-
* `locator.fill`
124
+
- `locator.fill`
125
+
- `locator.getAttribute`
126
+
- `locator.innerHTML`
127
+
- `locator.innerText`
128
+
- `locator.inputValue`
129
+
- `page.goto`
130
+
131
+
Adding new actions is easy: just update the `functions` in [`src/completeTask.ts`](src/completeTask.ts).
132
+
133
+
## Pricing
134
+
135
+
This library is free. However, there are costs associated with using OpenAI. You can find more information about pricing here: https://openai.com/pricing/.
136
+
137
+
<details>
138
+
<summary>Example</summary>
139
+
140
+
Using https://ray.run/ as an example, the cost of running a test step is approximately $0.01 using GPT-4 Turbo (and $0.001 using GPT-3.5 Turbo).
141
+
142
+
The low cost is in part because `auto-playwright` uses HTML sanitization to reduce the payload size, e.g. What follows is the payload that would be submitted for https://ray.run/.
143
+
144
+
Naturally, the price will vary dramatically depending on the payload.
Adding new actions is easy: just update the `functions` in [`src/completeTask.ts`](src/completeTask.ts).
155
+
The `auto` function uses [sanitize-html](https://www.npmjs.com/package/sanitize-html) to sanitize the HTML of the page before sending it to OpenAI. This is done to reduce cost and improve the quality of the generated text.
0 commit comments