@probolabs/playwright 0.4.12 → 0.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +136 -136
- package/dist/index.d.ts +37 -4
- package/dist/index.js +165 -135
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/actions.d.ts +0 -24
- package/dist/actions.d.ts.map +0 -1
- package/dist/actions.js +0 -241
- package/dist/api-client.d.ts +0 -32
- package/dist/api-client.d.ts.map +0 -1
- package/dist/api-client.js +0 -125
- package/dist/highlight.d.ts +0 -28
- package/dist/highlight.d.ts.map +0 -1
- package/dist/highlight.js +0 -79
- package/dist/index.d.ts.map +0 -1
- package/dist/probo-playwright.esm.js +0 -63
- package/dist/probo-playwright.umd.js +0 -644
- package/dist/src/actions.d.ts +0 -18
- package/dist/src/api-client.d.ts +0 -13
- package/dist/src/highlight.d.ts +0 -28
- package/dist/src/index.d.ts +0 -20
- package/dist/src/utils.d.ts +0 -20
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/utils.d.ts +0 -21
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -39
package/README.md
CHANGED
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
# Probolib: drive your playwright scripts with AI superpowers
|
|
2
|
-
|
|
3
|
-
Probolib is a powerful AI-driven automation library that enhances Playwright testing and automation by making your scripts more robust and maintainable. Instead of relying on brittle CSS selectors or complex XPath expressions, Probolib uses natural language to interact with web elements.
|
|
4
|
-
|
|
5
|
-
## Why Probolib?
|
|
6
|
-
|
|
7
|
-
- **Natural Language Automation**: Write human-readable instructions instead of complex selectors
|
|
8
|
-
- **More Resilient Tests**: AI-powered element detection that adapts to UI changes
|
|
9
|
-
- **Simpler Maintenance**: Reduce the need to update selectors when the UI changes
|
|
10
|
-
- **Faster Development**: Write automation scripts in plain English
|
|
11
|
-
|
|
12
|
-
## Example
|
|
13
|
-
|
|
14
|
-
Instead of writing:
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
page.click('some > super > complex > css > and non robust selector')
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
You can simply write:
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
probo.runStep(page, 'click on the save button')
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Quickstart
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
npm install @probolabs/playwright
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Accessing our backend
|
|
33
|
-
|
|
34
|
-
the heavy lifting of the AI reasoning is done at the moment on our backend server. in order to access it you would need to tell the library how to access it.
|
|
35
|
-
|
|
36
|
-
## easyiest - set ENV var
|
|
37
|
-
|
|
38
|
-
probolib expects the existance of 2 env vars:
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
export PROBO_API_ENDPOINT=api.probolabs.ai
|
|
42
|
-
export PROBO_API_KEY=<api key we will give you>
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Or use dotenv
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
// npm install dotenv
|
|
50
|
-
// in your script add this line
|
|
51
|
-
import 'dotenv/config' // ES6
|
|
52
|
-
|
|
53
|
-
// .env file located in the root of your project (the same level as your package.json)
|
|
54
|
-
PROBO_API_ENDPOINT=https://api.probolabs.ai
|
|
55
|
-
PROBO_API_KEY=<api key we will give you>
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## A complete example for Playwright integration. step by step
|
|
60
|
-
|
|
61
|
-
**step 1:** init a playwright project
|
|
62
|
-
|
|
63
|
-
```
|
|
64
|
-
# from your work directory
|
|
65
|
-
mkdir probo-example
|
|
66
|
-
cd probo-example
|
|
67
|
-
npm init playwright@latest
|
|
68
|
-
# follow the instructions and wait till the installation is finished
|
|
69
|
-
# verify that playwright is installed properly
|
|
70
|
-
npx playwright test --project chromium
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
**step 2**: integrate probolabs
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
npm install @probolabs/playwright dotenv
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
**step 3:** configure the env with our endpoint and api key
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
touch .env
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
edit the .env file
|
|
86
|
-
|
|
87
|
-
```
|
|
88
|
-
#.env
|
|
89
|
-
PROBO_API_ENDPOINT=https://api.probolabs.ai
|
|
90
|
-
PROBO_API_KEY=<api key we will give you>
|
|
91
|
-
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
**step 4:** create a file under the tests folder named `probo-example-todo-mvc.spec.mjs`
|
|
95
|
-
|
|
96
|
-
```
|
|
97
|
-
// tests/probo-example-todo-mvc.spec.mjs
|
|
98
|
-
import 'dotenv/config';
|
|
99
|
-
import { test} from '@playwright/test';
|
|
100
|
-
import { Probo } from '@probolabs/playwright';
|
|
101
|
-
|
|
102
|
-
//
|
|
103
|
-
// Important: Before running this script set PROBO_API_KEY and PROBO_API_ENDPOINT
|
|
104
|
-
//
|
|
105
|
-
|
|
106
|
-
test.describe('Todo MVC', () => {
|
|
107
|
-
test('basic example', async ({ page }) => {
|
|
108
|
-
try {
|
|
109
|
-
// Initialize Probo
|
|
110
|
-
const probo = new Probo({
|
|
111
|
-
scenarioName: 'probo-example-todo-mvc' // important for caching the AI reasoning
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
//Goto page
|
|
115
|
-
await page.goto('https://demo.playwright.dev/todomvc');
|
|
116
|
-
|
|
117
|
-
// Run test steps
|
|
118
|
-
console.log('Running test steps...');
|
|
119
|
-
await probo.runStep(page, 'enter a new todo item: "Buy groceries"');
|
|
120
|
-
await probo.runStep(page, 'press the Enter key');
|
|
121
|
-
|
|
122
|
-
console.log('✨ Test completed successfully!');
|
|
123
|
-
} catch (error) {
|
|
124
|
-
console.error('❌ Test failed:', error);
|
|
125
|
-
throw error; // Re-throw to mark the test as failed
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
**run the example**
|
|
133
|
-
|
|
134
|
-
```
|
|
135
|
-
npx playwright test tests/probo-example-todo-mvc.spec.mjs --headed --project chromium
|
|
136
|
-
```
|
|
1
|
+
# Probolib: drive your playwright scripts with AI superpowers
|
|
2
|
+
|
|
3
|
+
Probolib is a powerful AI-driven automation library that enhances Playwright testing and automation by making your scripts more robust and maintainable. Instead of relying on brittle CSS selectors or complex XPath expressions, Probolib uses natural language to interact with web elements.
|
|
4
|
+
|
|
5
|
+
## Why Probolib?
|
|
6
|
+
|
|
7
|
+
- **Natural Language Automation**: Write human-readable instructions instead of complex selectors
|
|
8
|
+
- **More Resilient Tests**: AI-powered element detection that adapts to UI changes
|
|
9
|
+
- **Simpler Maintenance**: Reduce the need to update selectors when the UI changes
|
|
10
|
+
- **Faster Development**: Write automation scripts in plain English
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
Instead of writing:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
page.click('some > super > complex > css > and non robust selector')
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
You can simply write:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
probo.runStep(page, 'click on the save button')
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quickstart
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
npm install @probolabs/playwright
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Accessing our backend
|
|
33
|
+
|
|
34
|
+
the heavy lifting of the AI reasoning is done at the moment on our backend server. in order to access it you would need to tell the library how to access it.
|
|
35
|
+
|
|
36
|
+
## easyiest - set ENV var
|
|
37
|
+
|
|
38
|
+
probolib expects the existance of 2 env vars:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
export PROBO_API_ENDPOINT=api.probolabs.ai
|
|
42
|
+
export PROBO_API_KEY=<api key we will give you>
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or use dotenv
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
// npm install dotenv
|
|
50
|
+
// in your script add this line
|
|
51
|
+
import 'dotenv/config' // ES6
|
|
52
|
+
|
|
53
|
+
// .env file located in the root of your project (the same level as your package.json)
|
|
54
|
+
PROBO_API_ENDPOINT=https://api.probolabs.ai
|
|
55
|
+
PROBO_API_KEY=<api key we will give you>
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## A complete example for Playwright integration. step by step
|
|
60
|
+
|
|
61
|
+
**step 1:** init a playwright project
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
# from your work directory
|
|
65
|
+
mkdir probo-example
|
|
66
|
+
cd probo-example
|
|
67
|
+
npm init playwright@latest
|
|
68
|
+
# follow the instructions and wait till the installation is finished
|
|
69
|
+
# verify that playwright is installed properly
|
|
70
|
+
npx playwright test --project chromium
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**step 2**: integrate probolabs
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
npm install @probolabs/playwright dotenv
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**step 3:** configure the env with our endpoint and api key
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
touch .env
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
edit the .env file
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
#.env
|
|
89
|
+
PROBO_API_ENDPOINT=https://api.probolabs.ai
|
|
90
|
+
PROBO_API_KEY=<api key we will give you>
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**step 4:** create a file under the tests folder named `probo-example-todo-mvc.spec.mjs`
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
// tests/probo-example-todo-mvc.spec.mjs
|
|
98
|
+
import 'dotenv/config';
|
|
99
|
+
import { test} from '@playwright/test';
|
|
100
|
+
import { Probo } from '@probolabs/playwright';
|
|
101
|
+
|
|
102
|
+
//
|
|
103
|
+
// Important: Before running this script set PROBO_API_KEY and PROBO_API_ENDPOINT
|
|
104
|
+
//
|
|
105
|
+
|
|
106
|
+
test.describe('Todo MVC', () => {
|
|
107
|
+
test('basic example', async ({ page }) => {
|
|
108
|
+
try {
|
|
109
|
+
// Initialize Probo
|
|
110
|
+
const probo = new Probo({
|
|
111
|
+
scenarioName: 'probo-example-todo-mvc' // important for caching the AI reasoning
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
//Goto page
|
|
115
|
+
await page.goto('https://demo.playwright.dev/todomvc');
|
|
116
|
+
|
|
117
|
+
// Run test steps
|
|
118
|
+
console.log('Running test steps...');
|
|
119
|
+
await probo.runStep(page, 'enter a new todo item: "Buy groceries"');
|
|
120
|
+
await probo.runStep(page, 'press the Enter key');
|
|
121
|
+
|
|
122
|
+
console.log('✨ Test completed successfully!');
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.error('❌ Test failed:', error);
|
|
125
|
+
throw error; // Re-throw to mark the test as failed
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**run the example**
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
npx playwright test tests/probo-example-todo-mvc.spec.mjs --headed --project chromium
|
|
136
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,9 @@ declare global {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Logging levels for Probo
|
|
26
|
+
*/
|
|
24
27
|
declare enum ProboLogLevel {
|
|
25
28
|
DEBUG = "DEBUG",
|
|
26
29
|
INFO = "INFO",
|
|
@@ -28,6 +31,32 @@ declare enum ProboLogLevel {
|
|
|
28
31
|
WARN = "WARN",
|
|
29
32
|
ERROR = "ERROR"
|
|
30
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Configure logging transports and level.
|
|
36
|
+
* @param options.logToConsole - Enable or disable console logging (default: true)
|
|
37
|
+
* @param options.logToFile - Enable or disable file logging (default: true)
|
|
38
|
+
* @param options.level - Logging level (default: INFO)
|
|
39
|
+
* @param options.filePath - Path for file transport (default: '/tmp/probo.log')
|
|
40
|
+
*/
|
|
41
|
+
declare function configureLogger(options?: {
|
|
42
|
+
logToConsole?: boolean;
|
|
43
|
+
logToFile?: boolean;
|
|
44
|
+
level?: ProboLogLevel;
|
|
45
|
+
filePath?: string;
|
|
46
|
+
}): void;
|
|
47
|
+
/**
|
|
48
|
+
* Simple logger wrapper that prefixes messages.
|
|
49
|
+
*/
|
|
50
|
+
declare class ProboLogger {
|
|
51
|
+
private prefix;
|
|
52
|
+
constructor(prefix: string);
|
|
53
|
+
private _logInternal;
|
|
54
|
+
debug(...args: any[]): void;
|
|
55
|
+
info(...args: any[]): void;
|
|
56
|
+
log(...args: any[]): void;
|
|
57
|
+
warn(...args: any[]): void;
|
|
58
|
+
error(...args: any[]): void;
|
|
59
|
+
}
|
|
31
60
|
|
|
32
61
|
/**
|
|
33
62
|
* Available AI models for LLM operations
|
|
@@ -45,18 +74,22 @@ declare enum AIModel {
|
|
|
45
74
|
DEEPSEEK_V3 = "DEEPSEEK_V3",
|
|
46
75
|
DEFAULT_AI_MODEL = "DEFAULT_AI_MODEL"
|
|
47
76
|
}
|
|
48
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Configuration options for Probo client
|
|
79
|
+
*/
|
|
49
80
|
interface ProboConfig {
|
|
50
81
|
scenarioName: string;
|
|
51
82
|
token?: string;
|
|
52
83
|
apiUrl?: string;
|
|
53
84
|
enableConsoleLogs?: boolean;
|
|
85
|
+
logToConsole?: boolean;
|
|
86
|
+
logToFile?: boolean;
|
|
54
87
|
debugLevel?: ProboLogLevel;
|
|
55
88
|
aiModel?: AIModel;
|
|
56
89
|
}
|
|
57
90
|
interface RunStepOptions {
|
|
58
91
|
useCache: boolean;
|
|
59
|
-
stepIdFromServer
|
|
92
|
+
stepIdFromServer?: number | null;
|
|
60
93
|
aiModel?: AIModel;
|
|
61
94
|
}
|
|
62
95
|
declare class Probo {
|
|
@@ -65,7 +98,7 @@ declare class Probo {
|
|
|
65
98
|
private readonly enableConsoleLogs;
|
|
66
99
|
private readonly scenarioName;
|
|
67
100
|
private readonly aiModel;
|
|
68
|
-
constructor({ scenarioName, token, apiUrl, enableConsoleLogs, debugLevel, aiModel }: ProboConfig);
|
|
101
|
+
constructor({ scenarioName, token, apiUrl, enableConsoleLogs, logToConsole, logToFile, debugLevel, aiModel }: ProboConfig);
|
|
69
102
|
runStep(page: Page, stepPrompt: string, options?: RunStepOptions): Promise<boolean>;
|
|
70
103
|
private _handleCachedStep;
|
|
71
104
|
private _handleStepCreation;
|
|
@@ -77,4 +110,4 @@ declare class Probo {
|
|
|
77
110
|
private _handlePerformAction;
|
|
78
111
|
}
|
|
79
112
|
|
|
80
|
-
export { AIModel, Probo, ProboLogLevel, type RunStepOptions };
|
|
113
|
+
export { AIModel, Probo, ProboLogLevel, ProboLogger, type RunStepOptions, configureLogger };
|