testdriverai 4.0.80 → 4.1.1

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 CHANGED
@@ -12,6 +12,10 @@ Next generation autonomous AI agent for end-to-end testing of web & desktop
12
12
  npm install testdriverai -g
13
13
  ```
14
14
 
15
+ | Windows | MacOS | Linux |
16
+ ---------|-------|-------|
17
+ | ✅ | ✅ | ❌ |
18
+
15
19
  TestDriver isn't like any test framework you've used before. TestDriver is an OS Agent for QA. TestDriver uses AI vision along with mouse and keyboard emulation to control the entire desktop. It's more like a QA employee than a test framework. This kind of black-box testing has some major advantages:
16
20
 
17
21
  - **Easier set up:** No need to add test IDs or craft complex selectors
@@ -0,0 +1,302 @@
1
+ <!doctype html>
2
+ <html>
3
+
4
+ <head>
5
+ <style>
6
+ * {
7
+ margin: 0;
8
+ padding: 0;
9
+ overflow: hidden;
10
+ box-sizing: border-box;
11
+ }
12
+
13
+ @keyframes animate-glow {
14
+ 0% {
15
+ opacity: 0;
16
+ filter: brightness(3) saturate(3);
17
+ transform: scale(0.8, 0.8);
18
+ }
19
+
20
+ 30% {
21
+ opacity: 1;
22
+ filter: brightness(1) saturate(1);
23
+ transform: scale(1, 1);
24
+ }
25
+
26
+ 100% {
27
+ /* opacity: 0; */
28
+ opacity: 1;
29
+ transform: scale(1, 1);
30
+ }
31
+ }
32
+
33
+ @keyframes animate-screenshot {
34
+ 0% {
35
+ opacity: 0;
36
+ transform: scale(1, 1);
37
+ }
38
+
39
+ 30% {
40
+ opacity: 1;
41
+ filter: brightness(3) saturate(3);
42
+ }
43
+
44
+ 50% {
45
+ opacity: 1;
46
+ transform: scale(.99, .99);
47
+ filter: brightness(3) saturate(3);
48
+ }
49
+
50
+ 70% {
51
+ opacity: 1;
52
+ filter: brightness(3) saturate(3);
53
+ }
54
+
55
+ 100% {
56
+ opacity: 0;
57
+ transform: scale(1, 1);
58
+ }
59
+ }
60
+
61
+ body {
62
+ width: 100vw;
63
+ height: 100vh;
64
+ position: relative;
65
+ }
66
+
67
+ .screenshot {
68
+ position: absolute;
69
+ inset: 0;
70
+ border: 8px dashed #B0CF34;
71
+ border-radius: 20px;
72
+ opacity: 0;
73
+ animation-duration: 0.3s;
74
+ animation-delay: 0;
75
+ animation-timing-function: cubic-bezier(0.26, 0.53, 0.74, 1.48);
76
+ animation-fill-mode: backwards;
77
+ animation-name: animate-screenshot;
78
+ animation-timing-function: ease;
79
+ animation-fill-mode: forwards;
80
+ }
81
+
82
+ .box {
83
+ border: 2px solid #B0CF34;
84
+ position: absolute;
85
+
86
+ animation-duration: 5s;
87
+ animation-delay: 0s;
88
+ animation-timing-function: cubic-bezier(0.26, 0.53, 0.74, 1.48);
89
+ animation-fill-mode: backwards;
90
+ animation-name: animate-glow;
91
+ animation-timing-function: ease;
92
+ animation-fill-mode: forwards;
93
+ }
94
+
95
+ .container {
96
+ inset: 0;
97
+ position: absolute;
98
+ }
99
+
100
+ #pointer {
101
+ width: 25px;
102
+ height: 25px;
103
+ opacity: 0;
104
+ position: absolute;
105
+ transform: translate(-50%, -50%);
106
+ border-radius: 50%;
107
+ background-color: #B0CF34;
108
+ }
109
+
110
+ .single-click {
111
+ animation: singleClick 0.7s ease-in-out forwards;
112
+ }
113
+
114
+ .double-click {
115
+ animation: doubleClick 0.7s ease-in-out forwards;
116
+ }
117
+
118
+ @keyframes singleClick {
119
+ 0% {
120
+ opacity: 1;
121
+ transform: translate(-50%, -50%) scale(1);
122
+ }
123
+
124
+ 100% {
125
+ opacity: 0;
126
+ transform: translate(-50%, -50%) scale(2);
127
+ }
128
+ }
129
+
130
+ @keyframes doubleClick {
131
+ 0% {
132
+ opacity: 1;
133
+ transform: translate(-50%, -50%) scale(1);
134
+ }
135
+
136
+ 45% {
137
+ opacity: 0;
138
+ transform: translate(-50%, -50%) scale(1.2);
139
+ }
140
+
141
+ 55% {
142
+ opacity: 1;
143
+ transform: translate(-50%, -50%) scale(1);
144
+ }
145
+
146
+ 100% {
147
+ opacity: 0;
148
+ transform: scale(2);
149
+ }
150
+ }
151
+
152
+ #terminal-wrapper {
153
+ position: absolute;
154
+ left: calc(100vw - 800px);
155
+ top: 0px;
156
+ height: 100vh;
157
+ width: 800px;
158
+ background: black;
159
+ opacity: 0;
160
+ z-index: -1;
161
+ overflow-y: auto;
162
+ padding: 4px;
163
+ }
164
+
165
+ #terminal {
166
+ width: 100%;
167
+ height: 100%;
168
+ overflow-y: auto;
169
+ }
170
+
171
+ #boxes {
172
+ position: absolute;
173
+ top: 0;
174
+ left: 0;
175
+ right: 0;
176
+ bottom: 0;
177
+ }
178
+ </style>
179
+ <link rel="stylesheet" href="terminal/xterm.css" />
180
+ <script src="terminal/xterm.js" type="text/javascript"></script>
181
+ <script src="terminal/xterm-fit.js" type="text/javascript"></script>
182
+ </head>
183
+
184
+ <body>
185
+ <div id="screenshot"></div>
186
+ <div id="main" class="container">
187
+ <div id="boxes">
188
+ <div id="pointer"></div>
189
+ </div>
190
+ <div id="terminal-wrapper">
191
+ <div id="terminal"></div>
192
+ </div>
193
+ </div>
194
+ <script>
195
+
196
+ const { ipcRenderer } = require("electron");
197
+ const { events } = require("../lib/events.js");
198
+
199
+ const pointer = document.querySelector("#pointer");
200
+ const container = document.querySelector("#main");
201
+ const screenshotElement = document.querySelector("#screenshot");
202
+ const terminalElement = document.querySelector("#terminal");
203
+
204
+ let boundingBoxesTimeout = null
205
+
206
+ let drawBoxes = (boxes) => {
207
+
208
+ // Remove old boxes
209
+ document.querySelectorAll(".box").forEach((box) => {
210
+ box.remove()
211
+ });
212
+
213
+ // Update or Create boxes
214
+ boxes.forEach(({ x, y, width, height, color }) => {
215
+
216
+ const boxElement = document.createElement("div");
217
+ boxElement.setAttribute("class", "box");
218
+ boxElement.style.position = "absolute";
219
+ boxElement.style.top = toCss(y);
220
+ boxElement.style.left = toCss(x);
221
+ boxElement.style.width = toCss(width);
222
+ boxElement.style.height = toCss(height);
223
+ boxElement.style.borderRadius = "1px";
224
+ document.querySelector("#boxes").appendChild(boxElement);
225
+
226
+ });
227
+ }
228
+
229
+
230
+ ipcRenderer.on(events.screenCapture.start, (event, data) => {
231
+ // Hide everything whlie the app takes the screenshot
232
+
233
+ container.style.opacity = 0;
234
+ });
235
+
236
+ ipcRenderer.on(events.screenCapture.end, (event, data) => {
237
+ screenshotElement.classList.remove('screenshot');
238
+ // Force reflow
239
+ void screenshotElement.offsetWidth;
240
+ screenshotElement.classList.add('screenshot');
241
+ setTimeout(() => {
242
+ container.style.opacity = 1
243
+ }, 300)
244
+ });
245
+
246
+ ipcRenderer.on(events.mouseClick,
247
+ (event, { x, y, click = "single" } = {}) => {
248
+ pointer.style.marginLeft = toCss(x);
249
+ pointer.style.marginTop = toCss(y);
250
+ pointer.setAttribute("class", "");
251
+ // Force reflow
252
+ void pointer.offsetWidth;
253
+ pointer.classList.add(`${click}-click`);
254
+ },
255
+ );
256
+
257
+ ipcRenderer.on(events.matches.show, (event, closeMatches = []) => {
258
+ if (boundingBoxesTimeout) clearTimeout(boundingBoxesTimeout)
259
+ drawBoxes(closeMatches)
260
+ boundingBoxesTimeout = setTimeout(() => drawBoxes([]), 10000)
261
+ });
262
+
263
+ const toCss = (size) => {
264
+ if (typeof size === "number") {
265
+ return `${size}px`;
266
+ }
267
+ return size;
268
+ };
269
+
270
+ // Terminal
271
+ const terminal = new Terminal({
272
+ convertEol: true,
273
+ cursorInactiveStyle: "none",
274
+ scrollback: 9999999,
275
+ allowProposedApi: true,
276
+ fontSize: 18
277
+ });
278
+
279
+ const fitAddon = new FitAddon.FitAddon();
280
+ terminal.loadAddon(fitAddon);
281
+ terminal.open(terminalElement);
282
+ fitAddon.fit();
283
+
284
+ ipcRenderer.on(events.terminal.stdout, (event, data) =>
285
+ terminal.write(data),
286
+ );
287
+
288
+ ipcRenderer.on(events.terminal.stderr, (event, data) =>
289
+ terminal.write(data),
290
+ );
291
+
292
+ ipcRenderer.on(events.interactive, (event, data) => {
293
+ if (data) {
294
+ terminalElement.parentElement.style.opacity = "0"
295
+ } else {
296
+ terminalElement.parentElement.style.opacity = "0.8"
297
+ }
298
+ });
299
+ </script>
300
+ </body>
301
+
302
+ </html>
@@ -0,0 +1,58 @@
1
+ const ipc = require("node-ipc").default;
2
+ const { app, screen, BrowserWindow } = require("electron");
3
+ const { eventsArray } = require("../lib/events.js");
4
+
5
+ ipc.config.id = "testdriverai_overlay";
6
+ ipc.config.retry = 1500;
7
+ ipc.config.silent = true;
8
+
9
+ app.whenReady().then(() => {
10
+ app.dock?.hide();
11
+
12
+ const windowOptions = {
13
+ ...screen.getPrimaryDisplay().bounds,
14
+ enableLargerThanScreen: true,
15
+ frame: false,
16
+ show: false,
17
+ closable: false,
18
+ resizable: false,
19
+ focusable: false,
20
+ fullscreenable: true,
21
+ transparent: true,
22
+ alwaysOnTop: true,
23
+ skipTaskbar: true,
24
+ webPreferences: {
25
+ nodeIntegration: true,
26
+ contextIsolation: false,
27
+ },
28
+ autoHideMenuBar: true,
29
+ };
30
+
31
+ if (process.platform !== 'darwin') {
32
+ windowOptions.fullscreen = true;
33
+ }
34
+
35
+ const window = new BrowserWindow(windowOptions);
36
+ window.setIgnoreMouseEvents(true);
37
+ window.setAlwaysOnTop(true, "screen-saver");
38
+ window.setVisibleOnAllWorkspaces(true, {
39
+ visibleOnFullScreen: true,
40
+ });
41
+ window.loadFile("overlay.html");
42
+ window.show();
43
+
44
+ // open developer tools
45
+ // window.webContents.openDevTools();
46
+
47
+ ipc.serve(() => {
48
+ for (const event of eventsArray) {
49
+ ipc.server.on(event, (data) => {
50
+ window?.webContents.send(event, data);
51
+ });
52
+ }
53
+ });
54
+ ipc.server.on("socket.disconnected", function () {
55
+ process.exit();
56
+ });
57
+ ipc.server.start();
58
+ });
@@ -0,0 +1,2 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FitAddon=t():e.FitAddon=t()}(self,(()=>(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.FitAddon=void 0,t.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){const e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;const t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal)return;if(!this._terminal.element||!this._terminal.element.parentElement)return;const e=this._terminal._core,t=e._renderService.dimensions;if(0===t.css.cell.width||0===t.css.cell.height)return;const r=0===this._terminal.options.scrollback?0:e.viewport.scrollBarWidth,i=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(i.getPropertyValue("height")),s=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),l=o-(parseInt(n.getPropertyValue("padding-top"))+parseInt(n.getPropertyValue("padding-bottom"))),a=s-(parseInt(n.getPropertyValue("padding-right"))+parseInt(n.getPropertyValue("padding-left")))-r;return{cols:Math.max(2,Math.floor(a/t.css.cell.width)),rows:Math.max(1,Math.floor(l/t.css.cell.height))}}}})(),e})()));
2
+ //# sourceMappingURL=addon-fit.js.map
@@ -0,0 +1,209 @@
1
+ /**
2
+ * Copyright (c) 2014 The xterm.js authors. All rights reserved.
3
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
4
+ * https://github.com/chjj/term.js
5
+ * @license MIT
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ * Originally forked from (with the author's permission):
26
+ * Fabrice Bellard's javascript vt100 for jslinux:
27
+ * http://bellard.org/jslinux/
28
+ * Copyright (c) 2011 Fabrice Bellard
29
+ * The original design remains. The terminal itself
30
+ * has been extended to include xterm CSI codes, among
31
+ * other features.
32
+ */
33
+
34
+ /**
35
+ * Default styles for xterm.js
36
+ */
37
+
38
+ .xterm {
39
+ cursor: text;
40
+ position: relative;
41
+ user-select: none;
42
+ -ms-user-select: none;
43
+ -webkit-user-select: none;
44
+ }
45
+
46
+ .xterm.focus,
47
+ .xterm:focus {
48
+ outline: none;
49
+ }
50
+
51
+ .xterm .xterm-helpers {
52
+ position: absolute;
53
+ top: 0;
54
+ /**
55
+ * The z-index of the helpers must be higher than the canvases in order for
56
+ * IMEs to appear on top.
57
+ */
58
+ z-index: 5;
59
+ }
60
+
61
+ .xterm .xterm-helper-textarea {
62
+ padding: 0;
63
+ border: 0;
64
+ margin: 0;
65
+ /* Move textarea out of the screen to the far left, so that the cursor is not visible */
66
+ position: absolute;
67
+ opacity: 0;
68
+ left: -9999em;
69
+ top: 0;
70
+ width: 0;
71
+ height: 0;
72
+ z-index: -5;
73
+ /** Prevent wrapping so the IME appears against the textarea at the correct position */
74
+ white-space: nowrap;
75
+ overflow: hidden;
76
+ resize: none;
77
+ }
78
+
79
+ .xterm .composition-view {
80
+ /* T-8819 Composition position got messed up somewhere */
81
+ background: #000;
82
+ color: #FFF;
83
+ display: none;
84
+ position: absolute;
85
+ white-space: nowrap;
86
+ z-index: 1;
87
+ }
88
+
89
+ .xterm .composition-view.active {
90
+ display: block;
91
+ }
92
+
93
+ .xterm .xterm-viewport {
94
+ /* On OS X this is required in order for the scroll bar to appear fully opaque */
95
+ background-color: #000;
96
+ overflow-y: scroll;
97
+ cursor: default;
98
+ position: absolute;
99
+ right: 0;
100
+ left: 0;
101
+ top: 0;
102
+ bottom: 0;
103
+ }
104
+
105
+ .xterm .xterm-screen {
106
+ position: relative;
107
+ }
108
+
109
+ .xterm .xterm-screen canvas {
110
+ position: absolute;
111
+ left: 0;
112
+ top: 0;
113
+ }
114
+
115
+ .xterm .xterm-scroll-area {
116
+ visibility: hidden;
117
+ }
118
+
119
+ .xterm-char-measure-element {
120
+ display: inline-block;
121
+ visibility: hidden;
122
+ position: absolute;
123
+ top: 0;
124
+ left: -9999em;
125
+ line-height: normal;
126
+ }
127
+
128
+ .xterm.enable-mouse-events {
129
+ /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
130
+ cursor: default;
131
+ }
132
+
133
+ .xterm.xterm-cursor-pointer,
134
+ .xterm .xterm-cursor-pointer {
135
+ cursor: pointer;
136
+ }
137
+
138
+ .xterm.column-select.focus {
139
+ /* Column selection mode */
140
+ cursor: crosshair;
141
+ }
142
+
143
+ .xterm .xterm-accessibility,
144
+ .xterm .xterm-message {
145
+ position: absolute;
146
+ left: 0;
147
+ top: 0;
148
+ bottom: 0;
149
+ right: 0;
150
+ z-index: 10;
151
+ color: transparent;
152
+ pointer-events: none;
153
+ }
154
+
155
+ .xterm .live-region {
156
+ position: absolute;
157
+ left: -9999px;
158
+ width: 1px;
159
+ height: 1px;
160
+ overflow: hidden;
161
+ }
162
+
163
+ .xterm-dim {
164
+ /* Dim should not apply to background, so the opacity of the foreground color is applied
165
+ * explicitly in the generated class and reset to 1 here */
166
+ opacity: 1 !important;
167
+ }
168
+
169
+ .xterm-underline-1 { text-decoration: underline; }
170
+ .xterm-underline-2 { text-decoration: double underline; }
171
+ .xterm-underline-3 { text-decoration: wavy underline; }
172
+ .xterm-underline-4 { text-decoration: dotted underline; }
173
+ .xterm-underline-5 { text-decoration: dashed underline; }
174
+
175
+ .xterm-overline {
176
+ text-decoration: overline;
177
+ }
178
+
179
+ .xterm-overline.xterm-underline-1 { text-decoration: overline underline; }
180
+ .xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }
181
+ .xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }
182
+ .xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }
183
+ .xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }
184
+
185
+ .xterm-strikethrough {
186
+ text-decoration: line-through;
187
+ }
188
+
189
+ .xterm-screen .xterm-decoration-container .xterm-decoration {
190
+ z-index: 6;
191
+ position: absolute;
192
+ }
193
+
194
+ .xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer {
195
+ z-index: 7;
196
+ }
197
+
198
+ .xterm-decoration-overview-ruler {
199
+ z-index: 8;
200
+ position: absolute;
201
+ top: 0;
202
+ right: 0;
203
+ pointer-events: none;
204
+ }
205
+
206
+ .xterm-decoration-top {
207
+ z-index: 2;
208
+ position: relative;
209
+ }