@probolabs/playwright 0.4.8 → 0.4.10

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 ADDED
@@ -0,0 +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
+ ```
package/dist/index.d.ts CHANGED
@@ -45,12 +45,11 @@ declare enum AIModel {
45
45
  DEEPSEEK_V3 = "DEEPSEEK_V3",
46
46
  DEFAULT_AI_MODEL = "DEFAULT_AI_MODEL"
47
47
  }
48
- declare const DEMO_TOKEN = "b31793f81a1f58b8a153c86a5fdf4df0e5179c51";
49
48
 
50
49
  interface ProboConfig {
51
50
  scenarioName: string;
52
- token: string;
53
- apiUrl: string;
51
+ token?: string;
52
+ apiUrl?: string;
54
53
  enableConsoleLogs?: boolean;
55
54
  debugLevel?: ProboLogLevel;
56
55
  aiModel?: AIModel;
@@ -71,11 +70,11 @@ declare class Probo {
71
70
  private _handleCachedStep;
72
71
  private _handleStepCreation;
73
72
  private setupConsoleLogs;
74
- highlightElements(page: Page, elementTag: ElementTagType): Promise<any>;
73
+ highlightElements(page: Page, elementTags: [ElementTagType]): Promise<any>;
75
74
  unhighlightElements(page: Page): Promise<void>;
76
75
  highlightElement(page: Page, element_css_selector: string, iframe_selector: string, element_index: string): Promise<void>;
77
76
  screenshot(page: Page): Promise<string>;
78
77
  private _handlePerformAction;
79
78
  }
80
79
 
81
- export { AIModel, DEMO_TOKEN, Probo, ProboLogLevel, type RunStepOptions };
80
+ export { AIModel, Probo, ProboLogLevel, type RunStepOptions };