testdriverai 6.2.2 → 7.1.0
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/.github/workflows/acceptance-linux.yml +75 -0
- package/.github/workflows/acceptance-sdk-tests.yml +133 -0
- package/.vscode/settings.json +5 -1
- package/AGENTS.md +550 -0
- package/CODEOWNERS +0 -1
- package/README.md +126 -0
- package/{testdriver → _testdriver}/acceptance/drag-and-drop.yaml +2 -2
- package/{testdriver → _testdriver}/acceptance/snippets/login.yaml +1 -1
- package/_testdriver/examples/desktop/lifecycle/prerun.yaml +0 -0
- package/{testdriver → _testdriver}/examples/web/lifecycle/prerun.yaml +6 -1
- package/{testdriver → _testdriver}/lifecycle/postrun.yaml +3 -2
- package/_testdriver/lifecycle/prerun.yaml +15 -0
- package/{testdriver → _testdriver}/lifecycle/provision.yaml +7 -2
- package/agent/index.js +300 -85
- package/agent/interface.js +15 -0
- package/agent/lib/cache.js +142 -0
- package/agent/lib/commander.js +1 -39
- package/agent/lib/commands.js +910 -296
- package/agent/lib/redraw.js +129 -41
- package/agent/lib/sandbox.js +29 -6
- package/agent/lib/sdk.js +22 -0
- package/agent/lib/system.js +0 -3
- package/agent/lib/validation.js +1 -7
- package/debug-locate-response.js +82 -0
- package/debugger/index.html +15 -4
- package/docs/ARCHITECTURE.md +424 -0
- package/docs/AWESOME_LOGS_QUICK_REF.md +100 -0
- package/docs/MIGRATION.md +425 -0
- package/docs/PRESETS.md +210 -0
- package/docs/QUICK_START_TEST_RECORDING.md +215 -0
- package/docs/SDK_AWESOME_LOGS.md +468 -0
- package/docs/TEST_RECORDING.md +388 -0
- package/docs/docs.json +286 -152
- package/docs/guide/best-practices-polling.mdx +154 -0
- package/docs/sdk-browser-rendering.md +167 -0
- package/docs/v6/getting-started/self-hosting.mdx +407 -0
- package/docs/{guide → v6/guide}/dashcam.mdx +1 -1
- package/docs/{guide → v6/guide}/environment-variables.mdx +4 -5
- package/docs/{guide → v6/guide}/lifecycle.mdx +1 -1
- package/docs/v6/overview/comparison.mdx +101 -0
- package/docs/v7/README.md +135 -0
- package/docs/v7/api/ai.mdx +205 -0
- package/docs/v7/api/assert.mdx +285 -0
- package/docs/v7/api/assertions.mdx +403 -0
- package/docs/v7/api/click.mdx +287 -0
- package/docs/v7/api/client.mdx +322 -0
- package/docs/v7/api/dashcam.mdx +497 -0
- package/docs/v7/api/doubleClick.mdx +102 -0
- package/docs/v7/api/elements.mdx +479 -0
- package/docs/v7/api/exec.mdx +346 -0
- package/docs/v7/api/find.mdx +316 -0
- package/docs/v7/api/focusApplication.mdx +294 -0
- package/docs/v7/api/hover.mdx +279 -0
- package/docs/v7/api/mouseDown.mdx +161 -0
- package/docs/v7/api/mouseUp.mdx +164 -0
- package/docs/v7/api/pressKeys.mdx +349 -0
- package/docs/v7/api/rightClick.mdx +123 -0
- package/docs/v7/api/sandbox.mdx +404 -0
- package/docs/v7/api/scroll.mdx +300 -0
- package/docs/v7/api/type.mdx +314 -0
- package/docs/v7/commands/assert.mdx +45 -0
- package/docs/v7/commands/exec.mdx +282 -0
- package/docs/v7/commands/focus-application.mdx +44 -0
- package/docs/v7/commands/hover-image.mdx +69 -0
- package/docs/v7/commands/hover-text.mdx +47 -0
- package/docs/v7/commands/if.mdx +53 -0
- package/docs/v7/commands/match-image.mdx +67 -0
- package/docs/v7/commands/press-keys.mdx +87 -0
- package/docs/v7/commands/remember.mdx +49 -0
- package/docs/v7/commands/run.mdx +44 -0
- package/docs/v7/commands/scroll-until-image.mdx +66 -0
- package/docs/v7/commands/scroll-until-text.mdx +60 -0
- package/docs/v7/commands/scroll.mdx +69 -0
- package/docs/v7/commands/type.mdx +45 -0
- package/docs/v7/commands/wait-for-image.mdx +54 -0
- package/docs/v7/commands/wait-for-text.mdx +48 -0
- package/docs/v7/commands/wait.mdx +45 -0
- package/docs/v7/getting-started/configuration.mdx +380 -0
- package/docs/v7/getting-started/quickstart.mdx +332 -0
- package/docs/v7/guides/best-practices.mdx +486 -0
- package/docs/v7/guides/caching-ai.mdx +215 -0
- package/docs/v7/guides/caching-selectors.mdx +292 -0
- package/docs/v7/guides/caching.mdx +366 -0
- package/docs/v7/guides/ci-cd/azure.mdx +587 -0
- package/docs/v7/guides/ci-cd/circleci.mdx +523 -0
- package/docs/v7/guides/ci-cd/github-actions.mdx +457 -0
- package/docs/v7/guides/ci-cd/gitlab.mdx +498 -0
- package/docs/v7/guides/ci-cd/jenkins.mdx +664 -0
- package/docs/v7/guides/ci-cd/travis.mdx +438 -0
- package/docs/v7/guides/debugging.mdx +349 -0
- package/docs/v7/guides/faq.mdx +393 -0
- package/docs/v7/guides/migration.mdx +562 -0
- package/docs/v7/guides/performance.mdx +517 -0
- package/docs/{getting-started → v7/guides}/self-hosting.mdx +11 -12
- package/docs/v7/guides/troubleshooting.mdx +526 -0
- package/docs/v7/guides/vitest-plugin.mdx +477 -0
- package/docs/v7/guides/vitest.mdx +535 -0
- package/docs/v7/platforms/linux.mdx +308 -0
- package/docs/v7/platforms/macos.mdx +433 -0
- package/docs/v7/platforms/windows.mdx +430 -0
- package/docs/v7/playwright.mdx +342 -0
- package/docs/v7/presets/chrome-extension.mdx +223 -0
- package/docs/v7/presets/chrome.mdx +287 -0
- package/docs/v7/presets/electron.mdx +435 -0
- package/docs/v7/presets/vscode.mdx +398 -0
- package/docs/v7/presets/webapp.mdx +396 -0
- package/docs/v7/progressive-apis/CORE.md +459 -0
- package/docs/v7/progressive-apis/HOOKS.md +360 -0
- package/docs/v7/progressive-apis/PROGRESSIVE_DISCLOSURE.md +230 -0
- package/docs/v7/progressive-apis/PROVISION.md +266 -0
- package/eslint.config.js +19 -1
- package/interfaces/cli/lib/base.js +10 -4
- package/interfaces/logger.js +2 -1
- package/interfaces/shared-test-state.mjs +69 -0
- package/interfaces/vitest-plugin.mjs +830 -0
- package/package.json +29 -5
- package/schema.json +8 -29
- package/scripts/view-test-results.mjs +96 -0
- package/sdk-log-formatter.js +714 -0
- package/sdk.d.ts +1028 -0
- package/sdk.js +2567 -0
- package/{.github/workflows/self-hosted.yml → self-hosted.yml} +13 -4
- package/setup/aws/cloudformation.yaml +9 -2
- package/src/core/Dashcam.js +469 -0
- package/src/core/index.d.ts +150 -0
- package/src/core/index.js +12 -0
- package/src/presets/index.mjs +331 -0
- package/src/vitest/extended.mjs +108 -0
- package/src/vitest/hooks.d.ts +119 -0
- package/src/vitest/hooks.mjs +298 -0
- package/src/vitest/index.mjs +64 -0
- package/src/vitest/lifecycle.mjs +277 -0
- package/src/vitest/utils.mjs +150 -0
- package/test/dashcam.test.js +137 -0
- package/test/mcp-example-test.yaml +27 -0
- package/testdriver/acceptance-sdk/QUICK_REFERENCE.md +61 -0
- package/testdriver/acceptance-sdk/README.md +128 -0
- package/testdriver/acceptance-sdk/TEST_REPORTING.md +245 -0
- package/testdriver/acceptance-sdk/assert.test.mjs +26 -0
- package/testdriver/acceptance-sdk/auto-cache-key-demo.test.mjs +56 -0
- package/testdriver/acceptance-sdk/chrome-extension.test.mjs +89 -0
- package/testdriver/acceptance-sdk/drag-and-drop.test.mjs +58 -0
- package/testdriver/acceptance-sdk/element-not-found.test.mjs +25 -0
- package/testdriver/acceptance-sdk/exec-js.test.mjs +43 -0
- package/testdriver/acceptance-sdk/exec-output.test.mjs +59 -0
- package/testdriver/acceptance-sdk/exec-pwsh.test.mjs +57 -0
- package/testdriver/acceptance-sdk/focus-window.test.mjs +36 -0
- package/testdriver/acceptance-sdk/formatted-logging.test.mjs +26 -0
- package/testdriver/acceptance-sdk/hooks-example.test.mjs +38 -0
- package/testdriver/acceptance-sdk/hover-image.test.mjs +34 -0
- package/testdriver/acceptance-sdk/hover-text-with-description.test.mjs +38 -0
- package/testdriver/acceptance-sdk/hover-text.test.mjs +27 -0
- package/testdriver/acceptance-sdk/match-image.test.mjs +36 -0
- package/testdriver/acceptance-sdk/presets-example.test.mjs +87 -0
- package/testdriver/acceptance-sdk/press-keys.test.mjs +50 -0
- package/testdriver/acceptance-sdk/prompt.test.mjs +33 -0
- package/testdriver/acceptance-sdk/scroll-keyboard.test.mjs +38 -0
- package/testdriver/acceptance-sdk/scroll-until-image.test.mjs +39 -0
- package/testdriver/acceptance-sdk/scroll-until-text.test.mjs +28 -0
- package/testdriver/acceptance-sdk/scroll.test.mjs +41 -0
- package/testdriver/acceptance-sdk/setup/globalTeardown.mjs +11 -0
- package/testdriver/acceptance-sdk/setup/testHelpers.mjs +420 -0
- package/testdriver/acceptance-sdk/setup/vitestSetup.mjs +40 -0
- package/testdriver/acceptance-sdk/sully-ai.test.mjs +234 -0
- package/testdriver/acceptance-sdk/test-console-logs.test.mjs +42 -0
- package/testdriver/acceptance-sdk/type-checking-demo.js +49 -0
- package/testdriver/acceptance-sdk/type.test.mjs +45 -0
- package/verify-element-api.js +89 -0
- package/verify-types.js +0 -0
- package/vitest.config.example.js +19 -0
- package/vitest.config.mjs +66 -0
- package/vitest.config.mjs.bak +44 -0
- package/.github/workflows/acceptance-v6.yml +0 -169
- package/.vscode/mcp.json +0 -9
- package/docs/overview/comparison.mdx +0 -82
- package/testdriver/lifecycle/prerun.yaml +0 -17
- /package/{testdriver/examples/desktop/lifecycle/prerun.yaml → .env.example} +0 -0
- /package/{testdriver → _testdriver}/acceptance/assert.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/dashcam.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/embed.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/exec-js.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/exec-output.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/exec-shell.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/focus-window.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/hover-image.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/hover-text-with-description.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/hover-text.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/if-else.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/match-image.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/press-keys.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/prompt.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/remember.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/screenshots/cart.png +0 -0
- /package/{testdriver → _testdriver}/acceptance/scroll-keyboard.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/scroll-until-image.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/scroll-until-text.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/scroll.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/snippets/match-cart.yaml +0 -0
- /package/{testdriver → _testdriver}/acceptance/type.yaml +0 -0
- /package/{testdriver → _testdriver}/behavior/failure.yaml +0 -0
- /package/{testdriver → _testdriver}/behavior/hover-text.yaml +0 -0
- /package/{testdriver → _testdriver}/behavior/lifecycle/postrun.yaml +0 -0
- /package/{testdriver → _testdriver}/behavior/lifecycle/prerun.yaml +0 -0
- /package/{testdriver → _testdriver}/behavior/lifecycle/provision.yaml +0 -0
- /package/{testdriver → _testdriver}/behavior/secrets.yaml +0 -0
- /package/{testdriver → _testdriver}/edge-cases/dashcam-chrome.yaml +0 -0
- /package/{testdriver → _testdriver}/edge-cases/exec-pwsh-multiline.yaml +0 -0
- /package/{testdriver → _testdriver}/edge-cases/js-exception.yaml +0 -0
- /package/{testdriver → _testdriver}/edge-cases/js-promise.yaml +0 -0
- /package/{testdriver → _testdriver}/edge-cases/lifecycle/postrun.yaml +0 -0
- /package/{testdriver → _testdriver}/edge-cases/prompt-in-middle.yaml +0 -0
- /package/{testdriver → _testdriver}/edge-cases/prompt-nested.yaml +0 -0
- /package/{testdriver → _testdriver}/edge-cases/success-test.yaml +0 -0
- /package/{testdriver → _testdriver}/examples/android/example.yaml +0 -0
- /package/{testdriver → _testdriver}/examples/android/lifecycle/postrun.yaml +0 -0
- /package/{testdriver → _testdriver}/examples/android/lifecycle/provision.yaml +0 -0
- /package/{testdriver → _testdriver}/examples/android/readme.md +0 -0
- /package/{testdriver → _testdriver}/examples/chrome-extension/lifecycle/provision.yaml +0 -0
- /package/{testdriver → _testdriver}/examples/desktop/lifecycle/provision.yaml +0 -0
- /package/{testdriver → _testdriver}/examples/vscode-extension/lifecycle/provision.yaml +0 -0
- /package/{testdriver → _testdriver}/examples/web/lifecycle/postrun.yaml +0 -0
- /package/docs/{account → v6/account}/dashboard.mdx +0 -0
- /package/docs/{account → v6/account}/enterprise.mdx +0 -0
- /package/docs/{account → v6/account}/pricing.mdx +0 -0
- /package/docs/{account → v6/account}/projects.mdx +0 -0
- /package/docs/{account → v6/account}/team.mdx +0 -0
- /package/docs/{action → v6/action}/ami.mdx +0 -0
- /package/docs/{action → v6/action}/performance.mdx +0 -0
- /package/docs/{action → v6/action}/secrets.mdx +0 -0
- /package/docs/{apps → v6/apps}/chrome-extensions.mdx +0 -0
- /package/docs/{apps → v6/apps}/desktop-apps.mdx +0 -0
- /package/docs/{apps → v6/apps}/mobile-apps.mdx +0 -0
- /package/docs/{apps → v6/apps}/static-websites.mdx +0 -0
- /package/docs/{apps → v6/apps}/tauri-apps.mdx +0 -0
- /package/docs/{bugs → v6/bugs}/jira.mdx +0 -0
- /package/docs/{cli → v6/cli}/overview.mdx +0 -0
- /package/docs/{commands → v6/commands}/assert.mdx +0 -0
- /package/docs/{commands → v6/commands}/exec.mdx +0 -0
- /package/docs/{commands → v6/commands}/focus-application.mdx +0 -0
- /package/docs/{commands → v6/commands}/hover-image.mdx +0 -0
- /package/docs/{commands → v6/commands}/hover-text.mdx +0 -0
- /package/docs/{commands → v6/commands}/if.mdx +0 -0
- /package/docs/{commands → v6/commands}/match-image.mdx +0 -0
- /package/docs/{commands → v6/commands}/press-keys.mdx +0 -0
- /package/docs/{commands → v6/commands}/remember.mdx +0 -0
- /package/docs/{commands → v6/commands}/run.mdx +0 -0
- /package/docs/{commands → v6/commands}/scroll-until-image.mdx +0 -0
- /package/docs/{commands → v6/commands}/scroll-until-text.mdx +0 -0
- /package/docs/{commands → v6/commands}/scroll.mdx +0 -0
- /package/docs/{commands → v6/commands}/type.mdx +0 -0
- /package/docs/{commands → v6/commands}/wait-for-image.mdx +0 -0
- /package/docs/{commands → v6/commands}/wait-for-text.mdx +0 -0
- /package/docs/{commands → v6/commands}/wait.mdx +0 -0
- /package/docs/{exporting → v6/exporting}/junit.mdx +0 -0
- /package/docs/{exporting → v6/exporting}/playwright.mdx +0 -0
- /package/docs/{features → v6/features}/auto-healing.mdx +0 -0
- /package/docs/{features → v6/features}/generation.mdx +0 -0
- /package/docs/{features → v6/features}/parallel-testing.mdx +0 -0
- /package/docs/{features → v6/features}/reusable-snippets.mdx +0 -0
- /package/docs/{features → v6/features}/selectorless.mdx +0 -0
- /package/docs/{features → v6/features}/visual-assertions.mdx +0 -0
- /package/docs/{getting-started → v6/getting-started}/ci.mdx +0 -0
- /package/docs/{getting-started → v6/getting-started}/cli.mdx +0 -0
- /package/docs/{getting-started → v6/getting-started}/editing.mdx +0 -0
- /package/docs/{getting-started → v6/getting-started}/playwright.mdx +0 -0
- /package/docs/{getting-started → v6/getting-started}/running.mdx +0 -0
- /package/docs/{getting-started → v6/getting-started}/vscode.mdx +0 -0
- /package/docs/{guide → v6/guide}/assertions.mdx +0 -0
- /package/docs/{guide → v6/guide}/authentication.mdx +0 -0
- /package/docs/{guide → v6/guide}/code.mdx +0 -0
- /package/docs/{guide → v6/guide}/locating.mdx +0 -0
- /package/docs/{guide → v6/guide}/protips.mdx +0 -0
- /package/docs/{guide → v6/guide}/variables.mdx +0 -0
- /package/docs/{guide → v6/guide}/waiting.mdx +0 -0
- /package/docs/{importing → v6/importing}/csv.mdx +0 -0
- /package/docs/{importing → v6/importing}/gherkin.mdx +0 -0
- /package/docs/{importing → v6/importing}/jira.mdx +0 -0
- /package/docs/{importing → v6/importing}/testrail.mdx +0 -0
- /package/docs/{integrations → v6/integrations}/electron.mdx +0 -0
- /package/docs/{integrations → v6/integrations}/netlify.mdx +0 -0
- /package/docs/{integrations → v6/integrations}/vercel.mdx +0 -0
- /package/docs/{interactive → v6/interactive}/explore.mdx +0 -0
- /package/docs/{interactive → v6/interactive}/run.mdx +0 -0
- /package/docs/{interactive → v6/interactive}/save.mdx +0 -0
- /package/docs/{overview → v6/overview}/faq.mdx +0 -0
- /package/docs/{overview → v6/overview}/performance.mdx +0 -0
- /package/docs/{overview → v6/overview}/quickstart.mdx +0 -0
- /package/docs/{overview → v6/overview}/what-is-testdriver.mdx +0 -0
- /package/docs/{scenarios → v6/scenarios}/ai-chatbot.mdx +0 -0
- /package/docs/{scenarios → v6/scenarios}/cookie-banner.mdx +0 -0
- /package/docs/{scenarios → v6/scenarios}/file-upload.mdx +0 -0
- /package/docs/{scenarios → v6/scenarios}/form-filling.mdx +0 -0
- /package/docs/{scenarios → v6/scenarios}/log-in.mdx +0 -0
- /package/docs/{scenarios → v6/scenarios}/pdf-generation.mdx +0 -0
- /package/docs/{scenarios → v6/scenarios}/spell-check.mdx +0 -0
- /package/docs/{security → v6/security}/action.mdx +0 -0
- /package/docs/{security → v6/security}/agent.mdx +0 -0
- /package/docs/{security → v6/security}/platform.mdx +0 -0
- /package/docs/{tutorials → v6/tutorials}/advanced-test.mdx +0 -0
- /package/docs/{tutorials → v6/tutorials}/basic-test.mdx +0 -0
package/sdk.d.ts
ADDED
|
@@ -0,0 +1,1028 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TestDriver SDK - TypeScript Definitions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Type Definitions
|
|
6
|
+
export type ClickAction =
|
|
7
|
+
| "click"
|
|
8
|
+
| "right-click"
|
|
9
|
+
| "double-click"
|
|
10
|
+
| "hover"
|
|
11
|
+
| "mouseDown"
|
|
12
|
+
| "mouseUp";
|
|
13
|
+
export type ScrollDirection = "up" | "down" | "left" | "right";
|
|
14
|
+
export type ScrollMethod = "keyboard" | "mouse";
|
|
15
|
+
export type TextMatchMethod = "ai" | "turbo";
|
|
16
|
+
export type ExecLanguage = "js" | "pwsh";
|
|
17
|
+
export type KeyboardKey =
|
|
18
|
+
| "\t"
|
|
19
|
+
| "\n"
|
|
20
|
+
| "\r"
|
|
21
|
+
| " "
|
|
22
|
+
| "!"
|
|
23
|
+
| '"'
|
|
24
|
+
| "#"
|
|
25
|
+
| "$"
|
|
26
|
+
| "%"
|
|
27
|
+
| "&"
|
|
28
|
+
| "'"
|
|
29
|
+
| "("
|
|
30
|
+
| ")"
|
|
31
|
+
| "*"
|
|
32
|
+
| "+"
|
|
33
|
+
| ","
|
|
34
|
+
| "-"
|
|
35
|
+
| "."
|
|
36
|
+
| "/"
|
|
37
|
+
| "0"
|
|
38
|
+
| "1"
|
|
39
|
+
| "2"
|
|
40
|
+
| "3"
|
|
41
|
+
| "4"
|
|
42
|
+
| "5"
|
|
43
|
+
| "6"
|
|
44
|
+
| "7"
|
|
45
|
+
| "8"
|
|
46
|
+
| "9"
|
|
47
|
+
| ":"
|
|
48
|
+
| ";"
|
|
49
|
+
| "<"
|
|
50
|
+
| "="
|
|
51
|
+
| ">"
|
|
52
|
+
| "?"
|
|
53
|
+
| "@"
|
|
54
|
+
| "["
|
|
55
|
+
| "\\"
|
|
56
|
+
| "]"
|
|
57
|
+
| "^"
|
|
58
|
+
| "_"
|
|
59
|
+
| "`"
|
|
60
|
+
| "a"
|
|
61
|
+
| "b"
|
|
62
|
+
| "c"
|
|
63
|
+
| "d"
|
|
64
|
+
| "e"
|
|
65
|
+
| "f"
|
|
66
|
+
| "g"
|
|
67
|
+
| "h"
|
|
68
|
+
| "i"
|
|
69
|
+
| "j"
|
|
70
|
+
| "k"
|
|
71
|
+
| "l"
|
|
72
|
+
| "m"
|
|
73
|
+
| "n"
|
|
74
|
+
| "o"
|
|
75
|
+
| "p"
|
|
76
|
+
| "q"
|
|
77
|
+
| "r"
|
|
78
|
+
| "s"
|
|
79
|
+
| "t"
|
|
80
|
+
| "u"
|
|
81
|
+
| "v"
|
|
82
|
+
| "w"
|
|
83
|
+
| "x"
|
|
84
|
+
| "y"
|
|
85
|
+
| "z"
|
|
86
|
+
| "{"
|
|
87
|
+
| "|"
|
|
88
|
+
| "}"
|
|
89
|
+
| "~"
|
|
90
|
+
| "accept"
|
|
91
|
+
| "add"
|
|
92
|
+
| "alt"
|
|
93
|
+
| "altleft"
|
|
94
|
+
| "altright"
|
|
95
|
+
| "apps"
|
|
96
|
+
| "backspace"
|
|
97
|
+
| "browserback"
|
|
98
|
+
| "browserfavorites"
|
|
99
|
+
| "browserforward"
|
|
100
|
+
| "browserhome"
|
|
101
|
+
| "browserrefresh"
|
|
102
|
+
| "browsersearch"
|
|
103
|
+
| "browserstop"
|
|
104
|
+
| "capslock"
|
|
105
|
+
| "clear"
|
|
106
|
+
| "convert"
|
|
107
|
+
| "ctrl"
|
|
108
|
+
| "ctrlleft"
|
|
109
|
+
| "ctrlright"
|
|
110
|
+
| "decimal"
|
|
111
|
+
| "del"
|
|
112
|
+
| "delete"
|
|
113
|
+
| "divide"
|
|
114
|
+
| "down"
|
|
115
|
+
| "end"
|
|
116
|
+
| "enter"
|
|
117
|
+
| "esc"
|
|
118
|
+
| "escape"
|
|
119
|
+
| "execute"
|
|
120
|
+
| "f1"
|
|
121
|
+
| "f2"
|
|
122
|
+
| "f3"
|
|
123
|
+
| "f4"
|
|
124
|
+
| "f5"
|
|
125
|
+
| "f6"
|
|
126
|
+
| "f7"
|
|
127
|
+
| "f8"
|
|
128
|
+
| "f9"
|
|
129
|
+
| "f10"
|
|
130
|
+
| "f11"
|
|
131
|
+
| "f12"
|
|
132
|
+
| "f13"
|
|
133
|
+
| "f14"
|
|
134
|
+
| "f15"
|
|
135
|
+
| "f16"
|
|
136
|
+
| "f17"
|
|
137
|
+
| "f18"
|
|
138
|
+
| "f19"
|
|
139
|
+
| "f20"
|
|
140
|
+
| "f21"
|
|
141
|
+
| "f22"
|
|
142
|
+
| "f23"
|
|
143
|
+
| "f24"
|
|
144
|
+
| "final"
|
|
145
|
+
| "fn"
|
|
146
|
+
| "hanguel"
|
|
147
|
+
| "hangul"
|
|
148
|
+
| "hanja"
|
|
149
|
+
| "help"
|
|
150
|
+
| "home"
|
|
151
|
+
| "insert"
|
|
152
|
+
| "junja"
|
|
153
|
+
| "kana"
|
|
154
|
+
| "kanji"
|
|
155
|
+
| "launchapp1"
|
|
156
|
+
| "launchapp2"
|
|
157
|
+
| "launchmail"
|
|
158
|
+
| "launchmediaselect"
|
|
159
|
+
| "left"
|
|
160
|
+
| "modechange"
|
|
161
|
+
| "multiply"
|
|
162
|
+
| "nexttrack"
|
|
163
|
+
| "nonconvert"
|
|
164
|
+
| "num0"
|
|
165
|
+
| "num1"
|
|
166
|
+
| "num2"
|
|
167
|
+
| "num3"
|
|
168
|
+
| "num4"
|
|
169
|
+
| "num5"
|
|
170
|
+
| "num6"
|
|
171
|
+
| "num7"
|
|
172
|
+
| "num8"
|
|
173
|
+
| "num9"
|
|
174
|
+
| "numlock"
|
|
175
|
+
| "pagedown"
|
|
176
|
+
| "pageup"
|
|
177
|
+
| "pause"
|
|
178
|
+
| "pgdn"
|
|
179
|
+
| "pgup"
|
|
180
|
+
| "playpause"
|
|
181
|
+
| "prevtrack"
|
|
182
|
+
| "print"
|
|
183
|
+
| "printscreen"
|
|
184
|
+
| "prntscrn"
|
|
185
|
+
| "prtsc"
|
|
186
|
+
| "prtscr"
|
|
187
|
+
| "return"
|
|
188
|
+
| "right"
|
|
189
|
+
| "scrolllock"
|
|
190
|
+
| "select"
|
|
191
|
+
| "separator"
|
|
192
|
+
| "shift"
|
|
193
|
+
| "shiftleft"
|
|
194
|
+
| "shiftright"
|
|
195
|
+
| "sleep"
|
|
196
|
+
| "space"
|
|
197
|
+
| "stop"
|
|
198
|
+
| "subtract"
|
|
199
|
+
| "tab"
|
|
200
|
+
| "up"
|
|
201
|
+
| "volumedown"
|
|
202
|
+
| "volumemute"
|
|
203
|
+
| "volumeup"
|
|
204
|
+
| "win"
|
|
205
|
+
| "winleft"
|
|
206
|
+
| "winright"
|
|
207
|
+
| "yen"
|
|
208
|
+
| "command"
|
|
209
|
+
| "option"
|
|
210
|
+
| "optionleft"
|
|
211
|
+
| "optionright";
|
|
212
|
+
|
|
213
|
+
export interface TestDriverOptions {
|
|
214
|
+
/** API endpoint URL (default: 'https://v6.testdriver.ai') */
|
|
215
|
+
apiRoot?: string;
|
|
216
|
+
/** Sandbox resolution (default: '1366x768') */
|
|
217
|
+
resolution?: string;
|
|
218
|
+
/** Enable analytics tracking (default: true) */
|
|
219
|
+
analytics?: boolean;
|
|
220
|
+
/** Enable console logging output (default: true) */
|
|
221
|
+
logging?: boolean;
|
|
222
|
+
/** Enable/disable cache (default: true). Set to false to force regeneration on all find operations */
|
|
223
|
+
cache?: boolean;
|
|
224
|
+
/** Cache threshold configuration for different methods */
|
|
225
|
+
cacheThreshold?: {
|
|
226
|
+
/** Threshold for find operations (default: 0.05 = 5% difference, 95% similarity) */
|
|
227
|
+
find?: number;
|
|
228
|
+
/** Threshold for findAll operations (default: 0.05 = 5% difference, 95% similarity) */
|
|
229
|
+
findAll?: number;
|
|
230
|
+
};
|
|
231
|
+
/** Additional environment variables */
|
|
232
|
+
environment?: Record<string, any>;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export interface ConnectOptions {
|
|
236
|
+
/** Existing sandbox ID to reconnect to */
|
|
237
|
+
sandboxId?: string;
|
|
238
|
+
/** Force creation of a new sandbox */
|
|
239
|
+
newSandbox?: boolean;
|
|
240
|
+
/** Direct IP address to connect to */
|
|
241
|
+
ip?: string;
|
|
242
|
+
/** Custom AMI for sandbox */
|
|
243
|
+
sandboxAmi?: string;
|
|
244
|
+
/** Instance type for sandbox */
|
|
245
|
+
sandboxInstance?: string;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface SandboxInstance {
|
|
249
|
+
instanceId: string;
|
|
250
|
+
ip: string;
|
|
251
|
+
vncPort: number;
|
|
252
|
+
[key: string]: any;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface ElementCoordinates {
|
|
256
|
+
x: number;
|
|
257
|
+
y: number;
|
|
258
|
+
centerX: number;
|
|
259
|
+
centerY: number;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface ElementBoundingBox {
|
|
263
|
+
top: number;
|
|
264
|
+
left: number;
|
|
265
|
+
bottom: number;
|
|
266
|
+
right: number;
|
|
267
|
+
[key: string]: any;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface ElementResponse {
|
|
271
|
+
coordinates: ElementCoordinates;
|
|
272
|
+
confidence?: number;
|
|
273
|
+
screenshot?: string;
|
|
274
|
+
width?: number;
|
|
275
|
+
height?: number;
|
|
276
|
+
boundingBox?: ElementBoundingBox;
|
|
277
|
+
text?: string;
|
|
278
|
+
label?: string;
|
|
279
|
+
[key: string]: any;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export interface HoverResult {
|
|
283
|
+
x: number;
|
|
284
|
+
y: number;
|
|
285
|
+
centerX: number;
|
|
286
|
+
centerY: number;
|
|
287
|
+
[key: string]: any;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// ====================================
|
|
291
|
+
// Command Options Interfaces
|
|
292
|
+
// ====================================
|
|
293
|
+
|
|
294
|
+
/** Options for scroll command */
|
|
295
|
+
export interface ScrollOptions {
|
|
296
|
+
/** Direction to scroll */
|
|
297
|
+
direction?: ScrollDirection;
|
|
298
|
+
/** Amount to scroll in pixels */
|
|
299
|
+
amount?: number;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** Options for click command */
|
|
303
|
+
export interface ClickOptions {
|
|
304
|
+
/** X coordinate */
|
|
305
|
+
x: number;
|
|
306
|
+
/** Y coordinate */
|
|
307
|
+
y: number;
|
|
308
|
+
/** Type of click action */
|
|
309
|
+
action?: ClickAction;
|
|
310
|
+
/** Prompt for tracking */
|
|
311
|
+
prompt?: string;
|
|
312
|
+
/** Whether cache was hit */
|
|
313
|
+
cacheHit?: boolean;
|
|
314
|
+
/** Selector used */
|
|
315
|
+
selector?: string;
|
|
316
|
+
/** Whether selector was used */
|
|
317
|
+
selectorUsed?: boolean;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** Options for hover command */
|
|
321
|
+
export interface HoverOptions {
|
|
322
|
+
/** X coordinate */
|
|
323
|
+
x: number;
|
|
324
|
+
/** Y coordinate */
|
|
325
|
+
y: number;
|
|
326
|
+
/** Prompt for tracking */
|
|
327
|
+
prompt?: string;
|
|
328
|
+
/** Whether cache was hit */
|
|
329
|
+
cacheHit?: boolean;
|
|
330
|
+
/** Selector used */
|
|
331
|
+
selector?: string;
|
|
332
|
+
/** Whether selector was used */
|
|
333
|
+
selectorUsed?: boolean;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** Options for hoverText command */
|
|
337
|
+
export interface HoverTextOptions {
|
|
338
|
+
/** Text to find and hover over */
|
|
339
|
+
text: string;
|
|
340
|
+
/** Optional description of the element */
|
|
341
|
+
description?: string | null;
|
|
342
|
+
/** Action to perform */
|
|
343
|
+
action?: ClickAction;
|
|
344
|
+
/** Timeout in milliseconds */
|
|
345
|
+
timeout?: number;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/** Options for hoverImage command */
|
|
349
|
+
export interface HoverImageOptions {
|
|
350
|
+
/** Description of the image to find */
|
|
351
|
+
description: string;
|
|
352
|
+
/** Action to perform */
|
|
353
|
+
action?: ClickAction;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/** Options for matchImage command */
|
|
357
|
+
export interface MatchImageOptions {
|
|
358
|
+
/** Path to the image template */
|
|
359
|
+
path: string;
|
|
360
|
+
/** Action to perform */
|
|
361
|
+
action?: ClickAction;
|
|
362
|
+
/** Invert the match */
|
|
363
|
+
invert?: boolean;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/** Options for type command */
|
|
367
|
+
export interface TypeOptions {
|
|
368
|
+
/** Text to type */
|
|
369
|
+
text: string | number;
|
|
370
|
+
/** Delay between keystrokes in milliseconds */
|
|
371
|
+
delay?: number;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/** Options for pressKeys command */
|
|
375
|
+
export interface PressKeysOptions {
|
|
376
|
+
/** Array of keys to press */
|
|
377
|
+
keys: KeyboardKey[];
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/** Options for wait command */
|
|
381
|
+
export interface WaitOptions {
|
|
382
|
+
/** Time to wait in milliseconds */
|
|
383
|
+
timeout?: number;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/** Options for waitForText command */
|
|
387
|
+
export interface WaitForTextOptions {
|
|
388
|
+
/** Text to wait for */
|
|
389
|
+
text: string;
|
|
390
|
+
/** Timeout in milliseconds */
|
|
391
|
+
timeout?: number;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/** Options for waitForImage command */
|
|
395
|
+
export interface WaitForImageOptions {
|
|
396
|
+
/** Description of the image */
|
|
397
|
+
description: string;
|
|
398
|
+
/** Timeout in milliseconds */
|
|
399
|
+
timeout?: number;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/** Options for scrollUntilText command */
|
|
403
|
+
export interface ScrollUntilTextOptions {
|
|
404
|
+
/** Text to find */
|
|
405
|
+
text: string;
|
|
406
|
+
/** Scroll direction */
|
|
407
|
+
direction?: ScrollDirection;
|
|
408
|
+
/** Maximum distance to scroll in pixels */
|
|
409
|
+
maxDistance?: number;
|
|
410
|
+
/** Invert the match */
|
|
411
|
+
invert?: boolean;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** Options for scrollUntilImage command */
|
|
415
|
+
export interface ScrollUntilImageOptions {
|
|
416
|
+
/** Description of the image */
|
|
417
|
+
description?: string;
|
|
418
|
+
/** Scroll direction */
|
|
419
|
+
direction?: ScrollDirection;
|
|
420
|
+
/** Maximum distance to scroll in pixels */
|
|
421
|
+
maxDistance?: number;
|
|
422
|
+
/** Scroll method */
|
|
423
|
+
method?: ScrollMethod;
|
|
424
|
+
/** Path to image template */
|
|
425
|
+
path?: string;
|
|
426
|
+
/** Invert the match */
|
|
427
|
+
invert?: boolean;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/** Options for focusApplication command */
|
|
431
|
+
export interface FocusApplicationOptions {
|
|
432
|
+
/** Application name */
|
|
433
|
+
name: string;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/** Options for remember command */
|
|
437
|
+
export interface RememberOptions {
|
|
438
|
+
/** What to remember */
|
|
439
|
+
description: string;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/** Options for assert command */
|
|
443
|
+
export interface AssertOptions {
|
|
444
|
+
/** Assertion to check */
|
|
445
|
+
assertion: string;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/** Options for exec command */
|
|
449
|
+
export interface ExecOptions {
|
|
450
|
+
/** Language ('js', 'pwsh', or 'sh') */
|
|
451
|
+
language?: ExecLanguage;
|
|
452
|
+
/** Code to execute */
|
|
453
|
+
code: string;
|
|
454
|
+
/** Timeout in milliseconds */
|
|
455
|
+
timeout?: number;
|
|
456
|
+
/** Suppress output */
|
|
457
|
+
silent?: boolean;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* A Promise that resolves to an Element but also has chainable element methods.
|
|
462
|
+
* This enables syntax like: await testdriver.find("button").click()
|
|
463
|
+
*/
|
|
464
|
+
export interface ChainableElementPromise extends Promise<Element> {
|
|
465
|
+
/**
|
|
466
|
+
* Click on the element (chainable)
|
|
467
|
+
* @param action - Type of click action (default: 'click')
|
|
468
|
+
*/
|
|
469
|
+
click(action?: ClickAction): Promise<void>;
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Hover over the element (chainable)
|
|
473
|
+
*/
|
|
474
|
+
hover(): Promise<void>;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Double-click on the element (chainable)
|
|
478
|
+
*/
|
|
479
|
+
doubleClick(): Promise<void>;
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Right-click on the element (chainable)
|
|
483
|
+
*/
|
|
484
|
+
rightClick(): Promise<void>;
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Press mouse button down on this element (chainable)
|
|
488
|
+
*/
|
|
489
|
+
mouseDown(): Promise<void>;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Release mouse button on this element (chainable)
|
|
493
|
+
*/
|
|
494
|
+
mouseUp(): Promise<void>;
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Check if element was found (chainable)
|
|
498
|
+
*/
|
|
499
|
+
found(): Promise<boolean>;
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Get the coordinates of the element (chainable)
|
|
503
|
+
*/
|
|
504
|
+
getCoordinates(): Promise<ElementCoordinates | null>;
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Get the full API response data (chainable)
|
|
508
|
+
*/
|
|
509
|
+
getResponse(): Promise<ElementResponse | null>;
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Get the x coordinate (chainable)
|
|
513
|
+
*/
|
|
514
|
+
readonly x: Promise<number | null>;
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Get the y coordinate (chainable)
|
|
518
|
+
*/
|
|
519
|
+
readonly y: Promise<number | null>;
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Get the center x coordinate (chainable)
|
|
523
|
+
*/
|
|
524
|
+
readonly centerX: Promise<number | null>;
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Get the center y coordinate (chainable)
|
|
528
|
+
*/
|
|
529
|
+
readonly centerY: Promise<number | null>;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Element class representing a located or to-be-located element on screen
|
|
534
|
+
*/
|
|
535
|
+
export class Element {
|
|
536
|
+
constructor(description: string);
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Check if element was found
|
|
540
|
+
*/
|
|
541
|
+
found(): boolean;
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Find the element on screen
|
|
545
|
+
* @param newDescription - Optional new description to search for
|
|
546
|
+
* @param cacheThreshold - Cache threshold for this specific find (overrides global setting)
|
|
547
|
+
*/
|
|
548
|
+
find(newDescription?: string, cacheThreshold?: number): Promise<Element>;
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Click on the element
|
|
552
|
+
* @param action - Type of click action (default: 'click')
|
|
553
|
+
*/
|
|
554
|
+
click(action?: ClickAction): Promise<void>;
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Hover over the element
|
|
558
|
+
*/
|
|
559
|
+
hover(): Promise<void>;
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Double-click on the element
|
|
563
|
+
*/
|
|
564
|
+
doubleClick(): Promise<void>;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Right-click on the element
|
|
568
|
+
*/
|
|
569
|
+
rightClick(): Promise<void>;
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Press mouse button down on this element
|
|
573
|
+
*/
|
|
574
|
+
mouseDown(): Promise<void>;
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Release mouse button on this element
|
|
578
|
+
*/
|
|
579
|
+
mouseUp(): Promise<void>;
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Get the coordinates of the element
|
|
583
|
+
*/
|
|
584
|
+
getCoordinates(): ElementCoordinates | null;
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Get the x coordinate (top-left)
|
|
588
|
+
*/
|
|
589
|
+
readonly x: number | null;
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Get the y coordinate (top-left)
|
|
593
|
+
*/
|
|
594
|
+
readonly y: number | null;
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Get the center x coordinate
|
|
598
|
+
*/
|
|
599
|
+
readonly centerX: number | null;
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Get the center y coordinate
|
|
603
|
+
*/
|
|
604
|
+
readonly centerY: number | null;
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Get the full API response data
|
|
608
|
+
*/
|
|
609
|
+
getResponse(): ElementResponse | null;
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Get element screenshot if available (base64 encoded)
|
|
613
|
+
*/
|
|
614
|
+
readonly screenshot: string | null;
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Get element confidence score if available
|
|
618
|
+
*/
|
|
619
|
+
readonly confidence: number | null;
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Get element width if available
|
|
623
|
+
*/
|
|
624
|
+
readonly width: number | null;
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* Get element height if available
|
|
628
|
+
*/
|
|
629
|
+
readonly height: number | null;
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Get element bounding box if available
|
|
633
|
+
*/
|
|
634
|
+
readonly boundingBox: ElementBoundingBox | null;
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Get element text content if available
|
|
638
|
+
*/
|
|
639
|
+
readonly text: string | null;
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Get element label if available
|
|
643
|
+
*/
|
|
644
|
+
readonly label: string | null;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
export default class TestDriverSDK {
|
|
648
|
+
constructor(apiKey: string, options?: TestDriverOptions);
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Authenticate with TestDriver API
|
|
652
|
+
*/
|
|
653
|
+
auth(): Promise<string>;
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Connect to a sandbox environment
|
|
657
|
+
*/
|
|
658
|
+
connect(options?: ConnectOptions): Promise<SandboxInstance>;
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Disconnect from the sandbox
|
|
662
|
+
*/
|
|
663
|
+
disconnect(): Promise<void>;
|
|
664
|
+
|
|
665
|
+
// Element Finding API
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Find an element by description
|
|
669
|
+
* Automatically locates the element and returns it
|
|
670
|
+
*
|
|
671
|
+
* @param description - Description of the element to find
|
|
672
|
+
* @param cacheThreshold - Cache threshold for this specific find (overrides global setting)
|
|
673
|
+
* @returns Chainable promise that resolves to Element instance
|
|
674
|
+
*
|
|
675
|
+
* @example
|
|
676
|
+
* // Find and click immediately (chainable)
|
|
677
|
+
* await client.find('the sign in button').click();
|
|
678
|
+
*
|
|
679
|
+
* @example
|
|
680
|
+
* // Find and click (traditional)
|
|
681
|
+
* const element = await client.find('the sign in button');
|
|
682
|
+
* await element.click();
|
|
683
|
+
*
|
|
684
|
+
* @example
|
|
685
|
+
* // Find with custom cache threshold
|
|
686
|
+
* const element = await client.find('login button', 0.01);
|
|
687
|
+
*
|
|
688
|
+
* @example
|
|
689
|
+
* // Poll until element is found
|
|
690
|
+
* let element;
|
|
691
|
+
* while (!element?.found()) {
|
|
692
|
+
* element = await client.find('login button');
|
|
693
|
+
* if (!element.found()) {
|
|
694
|
+
* await new Promise(resolve => setTimeout(resolve, 1000));
|
|
695
|
+
* }
|
|
696
|
+
* }
|
|
697
|
+
* await element.click();
|
|
698
|
+
*/
|
|
699
|
+
find(description: string, cacheThreshold?: number): ChainableElementPromise;
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Find all elements matching a description
|
|
703
|
+
* @param description - Description of the elements to find
|
|
704
|
+
* @param cacheThreshold - Cache threshold for this specific findAll (overrides global setting)
|
|
705
|
+
* @returns Array of Element instances
|
|
706
|
+
*
|
|
707
|
+
* @example
|
|
708
|
+
* // Find all buttons
|
|
709
|
+
* const buttons = await client.findAll('button');
|
|
710
|
+
*
|
|
711
|
+
* @example
|
|
712
|
+
* // Find with custom cache threshold
|
|
713
|
+
* const items = await client.findAll('list item', 0.01);
|
|
714
|
+
*/
|
|
715
|
+
findAll(description: string, cacheThreshold?: number): Promise<Element[]>;
|
|
716
|
+
|
|
717
|
+
// Text Interaction Methods
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Hover over text on screen
|
|
721
|
+
* @deprecated Use find() and element.click() instead
|
|
722
|
+
* @param options - Options object with text, description, action, and timeout
|
|
723
|
+
*/
|
|
724
|
+
hoverText(options: HoverTextOptions): Promise<HoverResult>;
|
|
725
|
+
/**
|
|
726
|
+
* Hover over text on screen (positional arguments - legacy)
|
|
727
|
+
* @deprecated Use find() and element.click() instead
|
|
728
|
+
* @param text - Text to find and hover over
|
|
729
|
+
* @param description - Optional description of the element
|
|
730
|
+
* @param action - Action to perform (default: 'click')
|
|
731
|
+
* @param timeout - Timeout in milliseconds (default: 5000)
|
|
732
|
+
*/
|
|
733
|
+
hoverText(
|
|
734
|
+
text: string,
|
|
735
|
+
description?: string | null,
|
|
736
|
+
action?: ClickAction,
|
|
737
|
+
timeout?: number,
|
|
738
|
+
): Promise<HoverResult>;
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Type text
|
|
742
|
+
* @param text - Text to type
|
|
743
|
+
* @param options - Options object with delay and secret
|
|
744
|
+
*
|
|
745
|
+
* @example
|
|
746
|
+
* // Type regular text
|
|
747
|
+
* await client.type('hello world');
|
|
748
|
+
*
|
|
749
|
+
* @example
|
|
750
|
+
* // Type a password securely (not logged or stored)
|
|
751
|
+
* await client.type(process.env.TD_PASSWORD, { secret: true });
|
|
752
|
+
*
|
|
753
|
+
* @example
|
|
754
|
+
* // Type with custom delay
|
|
755
|
+
* await client.type('slow typing', { delay: 100 });
|
|
756
|
+
*/
|
|
757
|
+
type(text: string | number, options?: { delay?: number; secret?: boolean }): Promise<void>;
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Wait for text to appear on screen
|
|
761
|
+
* @deprecated Use find() in a polling loop instead
|
|
762
|
+
* @param options - Options object with text and timeout
|
|
763
|
+
*/
|
|
764
|
+
waitForText(options: WaitForTextOptions): Promise<void>;
|
|
765
|
+
/**
|
|
766
|
+
* Wait for text to appear on screen (positional arguments - legacy)
|
|
767
|
+
* @deprecated Use find() in a polling loop instead
|
|
768
|
+
* @param text - Text to wait for
|
|
769
|
+
* @param timeout - Timeout in milliseconds (default: 5000)
|
|
770
|
+
*/
|
|
771
|
+
waitForText(text: string, timeout?: number): Promise<void>;
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Scroll until text is found
|
|
775
|
+
* @param options - Options object with text, direction, maxDistance, and invert
|
|
776
|
+
*/
|
|
777
|
+
scrollUntilText(options: ScrollUntilTextOptions): Promise<void>;
|
|
778
|
+
/**
|
|
779
|
+
* Scroll until text is found (positional arguments - legacy)
|
|
780
|
+
* @param text - Text to find
|
|
781
|
+
* @param direction - Scroll direction (default: 'down')
|
|
782
|
+
* @param maxDistance - Maximum distance to scroll in pixels (default: 10000)
|
|
783
|
+
* @param invert - Invert the match (default: false)
|
|
784
|
+
*/
|
|
785
|
+
scrollUntilText(
|
|
786
|
+
text: string,
|
|
787
|
+
direction?: ScrollDirection,
|
|
788
|
+
maxDistance?: number,
|
|
789
|
+
invert?: boolean,
|
|
790
|
+
): Promise<void>;
|
|
791
|
+
|
|
792
|
+
// Image Interaction Methods
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* Hover over an image on screen
|
|
796
|
+
* @deprecated Use find() and element.click() instead
|
|
797
|
+
* @param options - Options object with description and action
|
|
798
|
+
*/
|
|
799
|
+
hoverImage(options: HoverImageOptions): Promise<HoverResult>;
|
|
800
|
+
/**
|
|
801
|
+
* Hover over an image on screen (positional arguments - legacy)
|
|
802
|
+
* @deprecated Use find() and element.click() instead
|
|
803
|
+
* @param description - Description of the image to find
|
|
804
|
+
* @param action - Action to perform (default: 'click')
|
|
805
|
+
*/
|
|
806
|
+
hoverImage(description: string, action?: ClickAction): Promise<HoverResult>;
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* Match and interact with an image template
|
|
810
|
+
* @param options - Options object with path, action, and invert
|
|
811
|
+
*/
|
|
812
|
+
matchImage(options: MatchImageOptions): Promise<boolean>;
|
|
813
|
+
/**
|
|
814
|
+
* Match and interact with an image template (positional arguments - legacy)
|
|
815
|
+
* @param imagePath - Path to the image template
|
|
816
|
+
* @param action - Action to perform (default: 'click')
|
|
817
|
+
* @param invert - Invert the match (default: false)
|
|
818
|
+
*/
|
|
819
|
+
matchImage(
|
|
820
|
+
imagePath: string,
|
|
821
|
+
action?: ClickAction,
|
|
822
|
+
invert?: boolean,
|
|
823
|
+
): Promise<boolean>;
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* Wait for image to appear on screen
|
|
827
|
+
* @deprecated Use find() in a polling loop instead
|
|
828
|
+
* @param options - Options object with description and timeout
|
|
829
|
+
*/
|
|
830
|
+
waitForImage(options: WaitForImageOptions): Promise<void>;
|
|
831
|
+
/**
|
|
832
|
+
* Wait for image to appear on screen (positional arguments - legacy)
|
|
833
|
+
* @deprecated Use find() in a polling loop instead
|
|
834
|
+
* @param description - Description of the image
|
|
835
|
+
* @param timeout - Timeout in milliseconds (default: 10000)
|
|
836
|
+
*/
|
|
837
|
+
waitForImage(description: string, timeout?: number): Promise<void>;
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Scroll until image is found
|
|
841
|
+
* @param options - Options object with description, direction, maxDistance, method, path, and invert
|
|
842
|
+
*/
|
|
843
|
+
scrollUntilImage(options: ScrollUntilImageOptions): Promise<void>;
|
|
844
|
+
/**
|
|
845
|
+
* Scroll until image is found (positional arguments - legacy)
|
|
846
|
+
* @param description - Description of the image (or use path parameter)
|
|
847
|
+
* @param direction - Scroll direction (default: 'down')
|
|
848
|
+
* @param maxDistance - Maximum distance to scroll in pixels (default: 10000)
|
|
849
|
+
* @param method - Scroll method (default: 'keyboard')
|
|
850
|
+
* @param path - Path to image template (default: null)
|
|
851
|
+
* @param invert - Invert the match (default: false)
|
|
852
|
+
*/
|
|
853
|
+
scrollUntilImage(
|
|
854
|
+
description: string,
|
|
855
|
+
direction?: ScrollDirection,
|
|
856
|
+
maxDistance?: number,
|
|
857
|
+
method?: ScrollMethod,
|
|
858
|
+
path?: string | null,
|
|
859
|
+
invert?: boolean,
|
|
860
|
+
): Promise<void>;
|
|
861
|
+
|
|
862
|
+
// Mouse & Keyboard Methods
|
|
863
|
+
|
|
864
|
+
/**
|
|
865
|
+
* Click at coordinates
|
|
866
|
+
* @param options - Options object with x, y, and action
|
|
867
|
+
*/
|
|
868
|
+
click(options: ClickOptions): Promise<void>;
|
|
869
|
+
/**
|
|
870
|
+
* Click at coordinates (positional arguments - legacy)
|
|
871
|
+
* @param x - X coordinate
|
|
872
|
+
* @param y - Y coordinate
|
|
873
|
+
* @param action - Type of click action (default: 'click')
|
|
874
|
+
*/
|
|
875
|
+
click(x: number, y: number, action?: ClickAction): Promise<void>;
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* Hover at coordinates
|
|
879
|
+
* @param options - Options object with x and y
|
|
880
|
+
*/
|
|
881
|
+
hover(options: HoverOptions): Promise<void>;
|
|
882
|
+
/**
|
|
883
|
+
* Hover at coordinates (positional arguments - legacy)
|
|
884
|
+
* @param x - X coordinate
|
|
885
|
+
* @param y - Y coordinate
|
|
886
|
+
*/
|
|
887
|
+
hover(x: number, y: number): Promise<void>;
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* Press keyboard keys
|
|
891
|
+
* @param keys - Array of keys to press
|
|
892
|
+
* @param options - Additional options (reserved for future use)
|
|
893
|
+
*/
|
|
894
|
+
pressKeys(keys: KeyboardKey[], options?: object): Promise<void>;
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* Scroll the page
|
|
898
|
+
* @param direction - Direction to scroll (default: 'down')
|
|
899
|
+
* @param options - Options object with amount
|
|
900
|
+
*/
|
|
901
|
+
scroll(direction?: ScrollDirection, options?: { amount?: number }): Promise<void>;
|
|
902
|
+
|
|
903
|
+
// Application Control
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Focus an application by name
|
|
907
|
+
* @param name - Application name
|
|
908
|
+
* @param options - Additional options (reserved for future use)
|
|
909
|
+
*/
|
|
910
|
+
focusApplication(name: string, options?: object): Promise<string>;
|
|
911
|
+
|
|
912
|
+
// AI-Powered Methods
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* Make an AI-powered assertion
|
|
916
|
+
* @param assertion - Assertion to check
|
|
917
|
+
* @param options - Additional options (reserved for future use)
|
|
918
|
+
*/
|
|
919
|
+
assert(assertion: string, options?: object): Promise<boolean>;
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* Extract and remember information from the screen using AI
|
|
923
|
+
* @param options - Options object with description
|
|
924
|
+
*/
|
|
925
|
+
remember(options: RememberOptions): Promise<string>;
|
|
926
|
+
/**
|
|
927
|
+
* Extract and remember information from the screen using AI (positional arguments - legacy)
|
|
928
|
+
* @param description - What to remember
|
|
929
|
+
*/
|
|
930
|
+
remember(description: string): Promise<string>;
|
|
931
|
+
|
|
932
|
+
// Code Execution
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* Execute code in the sandbox
|
|
936
|
+
* @param options - Options object with language, code, timeout, and silent
|
|
937
|
+
*/
|
|
938
|
+
exec(options: ExecOptions): Promise<string>;
|
|
939
|
+
/**
|
|
940
|
+
* Execute code in the sandbox (positional arguments - legacy)
|
|
941
|
+
* @param language - Language ('js' or 'pwsh')
|
|
942
|
+
* @param code - Code to execute
|
|
943
|
+
* @param timeout - Timeout in milliseconds
|
|
944
|
+
* @param silent - Suppress output (default: false)
|
|
945
|
+
*/
|
|
946
|
+
exec(
|
|
947
|
+
language: ExecLanguage,
|
|
948
|
+
code: string,
|
|
949
|
+
timeout: number,
|
|
950
|
+
silent?: boolean,
|
|
951
|
+
): Promise<string>;
|
|
952
|
+
|
|
953
|
+
// Utility Methods
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* Capture a screenshot of the current screen
|
|
957
|
+
* @param scale - Scale factor for the screenshot (default: 1 = original size)
|
|
958
|
+
* @param silent - Whether to suppress logging (default: false)
|
|
959
|
+
* @param mouse - Whether to include mouse cursor (default: false)
|
|
960
|
+
* @returns Base64 encoded PNG screenshot
|
|
961
|
+
*
|
|
962
|
+
* @example
|
|
963
|
+
* // Capture a screenshot
|
|
964
|
+
* const screenshot = await client.screenshot();
|
|
965
|
+
* fs.writeFileSync('screenshot.png', Buffer.from(screenshot, 'base64'));
|
|
966
|
+
*
|
|
967
|
+
* @example
|
|
968
|
+
* // Capture with mouse cursor visible
|
|
969
|
+
* const screenshot = await client.screenshot(1, false, true);
|
|
970
|
+
*/
|
|
971
|
+
screenshot(
|
|
972
|
+
scale?: number,
|
|
973
|
+
silent?: boolean,
|
|
974
|
+
mouse?: boolean,
|
|
975
|
+
): Promise<string>;
|
|
976
|
+
|
|
977
|
+
/**
|
|
978
|
+
* Wait for specified time
|
|
979
|
+
* @deprecated Consider using element polling with find() instead of arbitrary waits
|
|
980
|
+
* @param timeout - Time to wait in milliseconds (default: 3000)
|
|
981
|
+
* @param options - Additional options (reserved for future use)
|
|
982
|
+
*/
|
|
983
|
+
wait(timeout?: number, options?: object): Promise<void>;
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* Get the current sandbox instance details
|
|
987
|
+
*/
|
|
988
|
+
getInstance(): SandboxInstance | null;
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* Get the session ID
|
|
992
|
+
*/
|
|
993
|
+
getSessionId(): string | null;
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* Enable or disable logging output
|
|
997
|
+
*/
|
|
998
|
+
setLogging(enabled: boolean): void;
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* Get the event emitter for custom event handling
|
|
1002
|
+
*/
|
|
1003
|
+
getEmitter(): any; // EventEmitter2 type
|
|
1004
|
+
|
|
1005
|
+
// AI Methods (Exploratory Loop)
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* Execute a natural language task using AI
|
|
1009
|
+
* This is the SDK equivalent of the CLI's exploratory loop
|
|
1010
|
+
*
|
|
1011
|
+
* @param task - Natural language description of what to do
|
|
1012
|
+
* @param options - Execution options
|
|
1013
|
+
* @returns Final AI response if validateAndLoop is true
|
|
1014
|
+
*
|
|
1015
|
+
* @example
|
|
1016
|
+
* // Simple execution
|
|
1017
|
+
* await client.ai('Click the submit button');
|
|
1018
|
+
*
|
|
1019
|
+
* @example
|
|
1020
|
+
* // With validation loop
|
|
1021
|
+
* const result = await client.ai('Fill out the contact form', { validateAndLoop: true });
|
|
1022
|
+
* console.log(result); // AI's final assessment
|
|
1023
|
+
*/
|
|
1024
|
+
ai(
|
|
1025
|
+
task: string,
|
|
1026
|
+
options?: { validateAndLoop?: boolean },
|
|
1027
|
+
): Promise<string | void>;
|
|
1028
|
+
}
|