@qapilot/appium-module 1.0.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/LICENSE +21 -0
- package/README.md +269 -0
- package/dist/commands/actions/perform-actions.command.d.ts +16 -0
- package/dist/commands/actions/perform-actions.command.d.ts.map +1 -0
- package/dist/commands/actions/perform-actions.command.js +23 -0
- package/dist/commands/actions/perform-actions.command.js.map +1 -0
- package/dist/commands/actions/touch-perform.command.d.ts +21 -0
- package/dist/commands/actions/touch-perform.command.d.ts.map +1 -0
- package/dist/commands/actions/touch-perform.command.js +28 -0
- package/dist/commands/actions/touch-perform.command.js.map +1 -0
- package/dist/commands/base.command.d.ts +36 -0
- package/dist/commands/base.command.d.ts.map +1 -0
- package/dist/commands/base.command.js +41 -0
- package/dist/commands/base.command.js.map +1 -0
- package/dist/commands/command.registry.d.ts +12 -0
- package/dist/commands/command.registry.d.ts.map +1 -0
- package/dist/commands/command.registry.js +111 -0
- package/dist/commands/command.registry.js.map +1 -0
- package/dist/commands/context/get-context.command.d.ts +13 -0
- package/dist/commands/context/get-context.command.d.ts.map +1 -0
- package/dist/commands/context/get-context.command.js +14 -0
- package/dist/commands/context/get-context.command.js.map +1 -0
- package/dist/commands/context/get-contexts.command.d.ts +13 -0
- package/dist/commands/context/get-contexts.command.d.ts.map +1 -0
- package/dist/commands/context/get-contexts.command.js +17 -0
- package/dist/commands/context/get-contexts.command.js.map +1 -0
- package/dist/commands/context/set-context.command.d.ts +17 -0
- package/dist/commands/context/set-context.command.d.ts.map +1 -0
- package/dist/commands/context/set-context.command.js +27 -0
- package/dist/commands/context/set-context.command.js.map +1 -0
- package/dist/commands/device/activate-app.command.d.ts +16 -0
- package/dist/commands/device/activate-app.command.d.ts.map +1 -0
- package/dist/commands/device/activate-app.command.js +23 -0
- package/dist/commands/device/activate-app.command.js.map +1 -0
- package/dist/commands/device/hide-keyboard.command.d.ts +17 -0
- package/dist/commands/device/hide-keyboard.command.d.ts.map +1 -0
- package/dist/commands/device/hide-keyboard.command.js +18 -0
- package/dist/commands/device/hide-keyboard.command.js.map +1 -0
- package/dist/commands/device/is-keyboard-shown.command.d.ts +13 -0
- package/dist/commands/device/is-keyboard-shown.command.d.ts.map +1 -0
- package/dist/commands/device/is-keyboard-shown.command.js +14 -0
- package/dist/commands/device/is-keyboard-shown.command.js.map +1 -0
- package/dist/commands/device/press-keycode.command.d.ts +19 -0
- package/dist/commands/device/press-keycode.command.d.ts.map +1 -0
- package/dist/commands/device/press-keycode.command.js +28 -0
- package/dist/commands/device/press-keycode.command.js.map +1 -0
- package/dist/commands/device/set-location.command.d.ts +16 -0
- package/dist/commands/device/set-location.command.d.ts.map +1 -0
- package/dist/commands/device/set-location.command.js +24 -0
- package/dist/commands/device/set-location.command.js.map +1 -0
- package/dist/commands/device/set-orientation.command.d.ts +16 -0
- package/dist/commands/device/set-orientation.command.d.ts.map +1 -0
- package/dist/commands/device/set-orientation.command.js +23 -0
- package/dist/commands/device/set-orientation.command.js.map +1 -0
- package/dist/commands/device/terminate-app.command.d.ts +16 -0
- package/dist/commands/device/terminate-app.command.d.ts.map +1 -0
- package/dist/commands/device/terminate-app.command.js +23 -0
- package/dist/commands/device/terminate-app.command.js.map +1 -0
- package/dist/commands/element/clear-element.command.d.ts +14 -0
- package/dist/commands/element/clear-element.command.d.ts.map +1 -0
- package/dist/commands/element/clear-element.command.js +13 -0
- package/dist/commands/element/clear-element.command.js.map +1 -0
- package/dist/commands/element/click-element.command.d.ts +14 -0
- package/dist/commands/element/click-element.command.d.ts.map +1 -0
- package/dist/commands/element/click-element.command.js +13 -0
- package/dist/commands/element/click-element.command.js.map +1 -0
- package/dist/commands/element/find-element.command.d.ts +17 -0
- package/dist/commands/element/find-element.command.d.ts.map +1 -0
- package/dist/commands/element/find-element.command.js +36 -0
- package/dist/commands/element/find-element.command.js.map +1 -0
- package/dist/commands/element/find-elements.command.d.ts +17 -0
- package/dist/commands/element/find-elements.command.d.ts.map +1 -0
- package/dist/commands/element/find-elements.command.js +39 -0
- package/dist/commands/element/find-elements.command.js.map +1 -0
- package/dist/commands/element/get-element-attribute.command.d.ts +16 -0
- package/dist/commands/element/get-element-attribute.command.d.ts.map +1 -0
- package/dist/commands/element/get-element-attribute.command.js +25 -0
- package/dist/commands/element/get-element-attribute.command.js.map +1 -0
- package/dist/commands/element/get-element-displayed.command.d.ts +14 -0
- package/dist/commands/element/get-element-displayed.command.d.ts.map +1 -0
- package/dist/commands/element/get-element-displayed.command.js +14 -0
- package/dist/commands/element/get-element-displayed.command.js.map +1 -0
- package/dist/commands/element/get-element-location.command.d.ts +15 -0
- package/dist/commands/element/get-element-location.command.d.ts.map +1 -0
- package/dist/commands/element/get-element-location.command.js +18 -0
- package/dist/commands/element/get-element-location.command.js.map +1 -0
- package/dist/commands/element/get-element-rect.command.d.ts +15 -0
- package/dist/commands/element/get-element-rect.command.d.ts.map +1 -0
- package/dist/commands/element/get-element-rect.command.js +20 -0
- package/dist/commands/element/get-element-rect.command.js.map +1 -0
- package/dist/commands/element/get-element-size.command.d.ts +15 -0
- package/dist/commands/element/get-element-size.command.d.ts.map +1 -0
- package/dist/commands/element/get-element-size.command.js +18 -0
- package/dist/commands/element/get-element-size.command.js.map +1 -0
- package/dist/commands/element/get-element-text.command.d.ts +14 -0
- package/dist/commands/element/get-element-text.command.d.ts.map +1 -0
- package/dist/commands/element/get-element-text.command.js +14 -0
- package/dist/commands/element/get-element-text.command.js.map +1 -0
- package/dist/commands/element/set-value.command.d.ts +16 -0
- package/dist/commands/element/set-value.command.d.ts.map +1 -0
- package/dist/commands/element/set-value.command.js +27 -0
- package/dist/commands/element/set-value.command.js.map +1 -0
- package/dist/commands/page/get-screenshot.command.d.ts +14 -0
- package/dist/commands/page/get-screenshot.command.d.ts.map +1 -0
- package/dist/commands/page/get-screenshot.command.js +15 -0
- package/dist/commands/page/get-screenshot.command.js.map +1 -0
- package/dist/commands/page/get-source.command.d.ts +13 -0
- package/dist/commands/page/get-source.command.d.ts.map +1 -0
- package/dist/commands/page/get-source.command.js +14 -0
- package/dist/commands/page/get-source.command.js.map +1 -0
- package/dist/commands/script/execute-script-sync.command.d.ts +20 -0
- package/dist/commands/script/execute-script-sync.command.d.ts.map +1 -0
- package/dist/commands/script/execute-script-sync.command.js +31 -0
- package/dist/commands/script/execute-script-sync.command.js.map +1 -0
- package/dist/commands/script/execute-script.command.d.ts +16 -0
- package/dist/commands/script/execute-script.command.d.ts.map +1 -0
- package/dist/commands/script/execute-script.command.js +27 -0
- package/dist/commands/script/execute-script.command.js.map +1 -0
- package/dist/commands/session/create-session.command.d.ts +16 -0
- package/dist/commands/session/create-session.command.d.ts.map +1 -0
- package/dist/commands/session/create-session.command.js +39 -0
- package/dist/commands/session/create-session.command.js.map +1 -0
- package/dist/commands/session/delete-session.command.d.ts +13 -0
- package/dist/commands/session/delete-session.command.d.ts.map +1 -0
- package/dist/commands/session/delete-session.command.js +13 -0
- package/dist/commands/session/delete-session.command.js.map +1 -0
- package/dist/commands/session/get-session.command.d.ts +14 -0
- package/dist/commands/session/get-session.command.d.ts.map +1 -0
- package/dist/commands/session/get-session.command.js +18 -0
- package/dist/commands/session/get-session.command.js.map +1 -0
- package/dist/commands/window/get-window-handles.command.d.ts +13 -0
- package/dist/commands/window/get-window-handles.command.d.ts.map +1 -0
- package/dist/commands/window/get-window-handles.command.js +17 -0
- package/dist/commands/window/get-window-handles.command.js.map +1 -0
- package/dist/commands/window/get-window.command.d.ts +13 -0
- package/dist/commands/window/get-window.command.d.ts.map +1 -0
- package/dist/commands/window/get-window.command.js +14 -0
- package/dist/commands/window/get-window.command.js.map +1 -0
- package/dist/commands/window/switch-window.command.d.ts +15 -0
- package/dist/commands/window/switch-window.command.d.ts.map +1 -0
- package/dist/commands/window/switch-window.command.js +23 -0
- package/dist/commands/window/switch-window.command.js.map +1 -0
- package/dist/http/middleware/error-handler.d.ts +3 -0
- package/dist/http/middleware/error-handler.d.ts.map +1 -0
- package/dist/http/middleware/error-handler.js +29 -0
- package/dist/http/middleware/error-handler.js.map +1 -0
- package/dist/http/middleware/request-validator.d.ts +3 -0
- package/dist/http/middleware/request-validator.d.ts.map +1 -0
- package/dist/http/middleware/request-validator.js +37 -0
- package/dist/http/middleware/request-validator.js.map +1 -0
- package/dist/http/router.d.ts +3 -0
- package/dist/http/router.d.ts.map +1 -0
- package/dist/http/router.js +43 -0
- package/dist/http/router.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/invoker/command-invoker.d.ts +3 -0
- package/dist/invoker/command-invoker.d.ts.map +1 -0
- package/dist/invoker/command-invoker.js +94 -0
- package/dist/invoker/command-invoker.js.map +1 -0
- package/dist/logger/index.d.ts +4 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +19 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/providers/base.provider.d.ts +11 -0
- package/dist/providers/base.provider.d.ts.map +1 -0
- package/dist/providers/base.provider.js +51 -0
- package/dist/providers/base.provider.js.map +1 -0
- package/dist/providers/browserstack/browserstack.config.d.ts +11 -0
- package/dist/providers/browserstack/browserstack.config.d.ts.map +1 -0
- package/dist/providers/browserstack/browserstack.config.js +32 -0
- package/dist/providers/browserstack/browserstack.config.js.map +1 -0
- package/dist/providers/browserstack/browserstack.provider.d.ts +15 -0
- package/dist/providers/browserstack/browserstack.provider.d.ts.map +1 -0
- package/dist/providers/browserstack/browserstack.provider.js +80 -0
- package/dist/providers/browserstack/browserstack.provider.js.map +1 -0
- package/dist/providers/lambdatest/lambdatest.config.d.ts +11 -0
- package/dist/providers/lambdatest/lambdatest.config.d.ts.map +1 -0
- package/dist/providers/lambdatest/lambdatest.config.js +28 -0
- package/dist/providers/lambdatest/lambdatest.config.js.map +1 -0
- package/dist/providers/lambdatest/lambdatest.provider.d.ts +15 -0
- package/dist/providers/lambdatest/lambdatest.provider.d.ts.map +1 -0
- package/dist/providers/lambdatest/lambdatest.provider.js +74 -0
- package/dist/providers/lambdatest/lambdatest.provider.js.map +1 -0
- package/dist/providers/local/local.provider.d.ts +15 -0
- package/dist/providers/local/local.provider.d.ts.map +1 -0
- package/dist/providers/local/local.provider.js +40 -0
- package/dist/providers/local/local.provider.js.map +1 -0
- package/dist/providers/provider.factory.d.ts +10 -0
- package/dist/providers/provider.factory.d.ts.map +1 -0
- package/dist/providers/provider.factory.js +32 -0
- package/dist/providers/provider.factory.js.map +1 -0
- package/dist/providers/provider.interface.d.ts +30 -0
- package/dist/providers/provider.interface.d.ts.map +1 -0
- package/dist/providers/provider.interface.js +2 -0
- package/dist/providers/provider.interface.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +13 -0
- package/dist/server.js.map +1 -0
- package/dist/types/command.types.d.ts +24 -0
- package/dist/types/command.types.d.ts.map +1 -0
- package/dist/types/command.types.js +2 -0
- package/dist/types/command.types.js.map +1 -0
- package/dist/types/error.types.d.ts +25 -0
- package/dist/types/error.types.d.ts.map +1 -0
- package/dist/types/error.types.js +26 -0
- package/dist/types/error.types.js.map +1 -0
- package/dist/types/provider.types.d.ts +13 -0
- package/dist/types/provider.types.d.ts.map +1 -0
- package/dist/types/provider.types.js +2 -0
- package/dist/types/provider.types.js.map +1 -0
- package/dist/types/webdriver.types.d.ts +55 -0
- package/dist/types/webdriver.types.d.ts.map +1 -0
- package/dist/types/webdriver.types.js +4 -0
- package/dist/types/webdriver.types.js.map +1 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 QAPilot
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
# @qapilot/appium-module
|
|
2
|
+
|
|
3
|
+
Appium W3C WebDriver module for interacting with devices across **BrowserStack**, **LambdaTest**, and **local Appium** servers. Exposes a unified `invokeCommand` API that normalizes provider-specific differences (URLs, auth headers, capability formats) behind a single interface.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @qapilot/appium-module
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
If you plan to use the built-in HTTP server mode, also install `express`:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install express
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### Programmatic (library mode)
|
|
20
|
+
|
|
21
|
+
Import `invokeCommand` and call any W3C WebDriver command against any supported provider.
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { invokeCommand } from '@qapilot/appium-module';
|
|
25
|
+
|
|
26
|
+
// Create a session on BrowserStack
|
|
27
|
+
const session = await invokeCommand({
|
|
28
|
+
commandName: 'createSession',
|
|
29
|
+
provider: 'browserstack',
|
|
30
|
+
credentials: {
|
|
31
|
+
username: process.env.BS_USER,
|
|
32
|
+
accessKey: process.env.BS_KEY,
|
|
33
|
+
},
|
|
34
|
+
params: {
|
|
35
|
+
capabilities: {
|
|
36
|
+
platformName: 'Android',
|
|
37
|
+
'appium:deviceName': 'Google Pixel 6',
|
|
38
|
+
'appium:platformVersion': '12.0',
|
|
39
|
+
'appium:app': 'bs://<app-id>',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
if (!session.success) {
|
|
45
|
+
throw new Error(session.error?.message);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const { sessionId } = session.data;
|
|
49
|
+
|
|
50
|
+
// Find an element
|
|
51
|
+
const element = await invokeCommand({
|
|
52
|
+
commandName: 'findElement',
|
|
53
|
+
provider: 'browserstack',
|
|
54
|
+
credentials: { username: process.env.BS_USER, accessKey: process.env.BS_KEY },
|
|
55
|
+
params: { sessionId, using: 'accessibility id', value: 'loginButton' },
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Click it
|
|
59
|
+
await invokeCommand({
|
|
60
|
+
commandName: 'clickElement',
|
|
61
|
+
provider: 'browserstack',
|
|
62
|
+
credentials: { username: process.env.BS_USER, accessKey: process.env.BS_KEY },
|
|
63
|
+
params: { sessionId, elementId: element.data.elementId },
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Take a screenshot
|
|
67
|
+
const screenshot = await invokeCommand({
|
|
68
|
+
commandName: 'getScreenshot',
|
|
69
|
+
provider: 'browserstack',
|
|
70
|
+
credentials: { username: process.env.BS_USER, accessKey: process.env.BS_KEY },
|
|
71
|
+
params: { sessionId },
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Delete the session
|
|
75
|
+
await invokeCommand({
|
|
76
|
+
commandName: 'deleteSession',
|
|
77
|
+
provider: 'browserstack',
|
|
78
|
+
credentials: { username: process.env.BS_USER, accessKey: process.env.BS_KEY },
|
|
79
|
+
params: { sessionId },
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Local Appium
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { invokeCommand } from '@qapilot/appium-module';
|
|
87
|
+
|
|
88
|
+
const session = await invokeCommand({
|
|
89
|
+
commandName: 'createSession',
|
|
90
|
+
provider: 'local',
|
|
91
|
+
credentials: {
|
|
92
|
+
hubUrl: 'http://localhost:4723',
|
|
93
|
+
},
|
|
94
|
+
params: {
|
|
95
|
+
capabilities: {
|
|
96
|
+
platformName: 'Android',
|
|
97
|
+
'appium:automationName': 'UiAutomator2',
|
|
98
|
+
'appium:deviceName': 'emulator-5554',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### LambdaTest
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import { invokeCommand } from '@qapilot/appium-module';
|
|
108
|
+
|
|
109
|
+
const session = await invokeCommand({
|
|
110
|
+
commandName: 'createSession',
|
|
111
|
+
provider: 'lambdatest',
|
|
112
|
+
credentials: {
|
|
113
|
+
username: process.env.LT_USER,
|
|
114
|
+
accessKey: process.env.LT_KEY,
|
|
115
|
+
},
|
|
116
|
+
params: {
|
|
117
|
+
capabilities: {
|
|
118
|
+
platformName: 'Android',
|
|
119
|
+
'appium:deviceName': 'Galaxy S21',
|
|
120
|
+
'appium:app': 'lt://<app-id>',
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Supported Commands
|
|
127
|
+
|
|
128
|
+
| Category | Commands |
|
|
129
|
+
|----------|----------|
|
|
130
|
+
| Session | `createSession`, `getSession`, `deleteSession` |
|
|
131
|
+
| Element | `findElement`, `findElements`, `clickElement`, `setValue`, `clearElement`, `getElementText`, `getElementAttribute`, `getElementDisplayed`, `getElementRect`, `getElementLocation`, `getElementSize` |
|
|
132
|
+
| Page | `getScreenshot`, `getSource` |
|
|
133
|
+
| Actions | `performActions`, `touchPerform` |
|
|
134
|
+
| Context | `getContext`, `setContext`, `getContexts` |
|
|
135
|
+
| Window | `getWindow`, `getWindowHandles`, `switchWindow` |
|
|
136
|
+
| Device | `hideKeyboard`, `isKeyboardShown`, `pressKeycode`, `activateApp`, `terminateApp`, `setOrientation`, `setLocation` |
|
|
137
|
+
| Script | `executeScript`, `executeScriptSync` |
|
|
138
|
+
|
|
139
|
+
Get the full list at runtime:
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
import { getSupportedCommands } from '@qapilot/appium-module';
|
|
143
|
+
console.log(getSupportedCommands());
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Extending
|
|
147
|
+
|
|
148
|
+
### Custom Providers
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { registerProvider, BaseProvider } from '@qapilot/appium-module';
|
|
152
|
+
import type { IAppiumProvider, ProviderCredentials, AppiumServiceError } from '@qapilot/appium-module';
|
|
153
|
+
|
|
154
|
+
class SauceLabsProvider extends BaseProvider implements IAppiumProvider {
|
|
155
|
+
readonly name = 'saucelabs' as any;
|
|
156
|
+
protected readonly hubBaseUrl = 'https://ondemand.us-west-1.saucelabs.com';
|
|
157
|
+
protected readonly wdHubPath = '/wd/hub';
|
|
158
|
+
|
|
159
|
+
buildUrl(_sessionId: string | null, path: string, credentials: ProviderCredentials): string {
|
|
160
|
+
return `${this.buildBaseUrl(credentials)}${path}`;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
buildHeaders(credentials: ProviderCredentials): Record<string, string> {
|
|
164
|
+
return {
|
|
165
|
+
'Content-Type': 'application/json',
|
|
166
|
+
Authorization: this.buildBasicAuthHeader(credentials),
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
normalizeCapabilities(caps: Record<string, unknown>): Record<string, unknown> {
|
|
171
|
+
return caps;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
normalizeError(statusCode: number, body: unknown): AppiumServiceError {
|
|
175
|
+
return this.mapW3CError(statusCode, body);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
getDefaultCapabilities(): Record<string, unknown> {
|
|
179
|
+
return {};
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
registerProvider(new SauceLabsProvider());
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Custom Commands
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
import { registerCommand, BaseCommand } from '@qapilot/appium-module';
|
|
190
|
+
|
|
191
|
+
class ShakeDeviceCommand extends BaseCommand<{ sessionId: string }, void> {
|
|
192
|
+
readonly name = 'shakeDevice';
|
|
193
|
+
readonly method = 'POST' as const;
|
|
194
|
+
readonly pathTemplate = '/session/{sessionId}/appium/device/shake';
|
|
195
|
+
|
|
196
|
+
buildBody(_params: { sessionId: string }) {
|
|
197
|
+
return {};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
parseResponse(_raw: unknown): void {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
registerCommand(new ShakeDeviceCommand());
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## HTTP Server Mode
|
|
209
|
+
|
|
210
|
+
The package also ships a standalone Express HTTP server that exposes the command invoker over REST. This is useful when you want to call Appium from a language other than Node.js, or from a microservice over HTTP.
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
# Run the server directly
|
|
214
|
+
npx @qapilot/appium-module/server
|
|
215
|
+
|
|
216
|
+
# Or in your own project (after installing express):
|
|
217
|
+
node node_modules/@qapilot/appium-module/dist/server.js
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### `POST /api/v1/execute`
|
|
221
|
+
|
|
222
|
+
```json
|
|
223
|
+
{
|
|
224
|
+
"commandName": "findElement",
|
|
225
|
+
"provider": "browserstack",
|
|
226
|
+
"credentials": { "username": "...", "accessKey": "..." },
|
|
227
|
+
"params": { "sessionId": "abc123", "using": "xpath", "value": "//button" }
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### `GET /api/v1/commands` — list all registered commands
|
|
232
|
+
### `GET /api/v1/providers` — list all registered providers
|
|
233
|
+
### `GET /api/v1/health` — liveness probe
|
|
234
|
+
|
|
235
|
+
Environment variables for server mode:
|
|
236
|
+
|
|
237
|
+
| Variable | Default | Description |
|
|
238
|
+
|----------|---------|-------------|
|
|
239
|
+
| `PORT` | `8000` | HTTP port to listen on |
|
|
240
|
+
| `NODE_ENV` | `development` | Set to `production` for JSON logging |
|
|
241
|
+
| `LOG_LEVEL` | `info` | Pino log level |
|
|
242
|
+
| `LOCAL_APPIUM_URL` | `http://localhost:4723` | Default URL for the `local` provider |
|
|
243
|
+
|
|
244
|
+
## TypeScript
|
|
245
|
+
|
|
246
|
+
All types are exported from the main entry point:
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
import type {
|
|
250
|
+
ExecuteRequest,
|
|
251
|
+
ExecuteResponse,
|
|
252
|
+
ProviderName,
|
|
253
|
+
ProviderCredentials,
|
|
254
|
+
AppiumServiceError,
|
|
255
|
+
IAppiumProvider,
|
|
256
|
+
} from '@qapilot/appium-module';
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Publishing
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
npm run build # compile TypeScript to dist/
|
|
263
|
+
npm login # authenticate with npm
|
|
264
|
+
npm publish --access public
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## License
|
|
268
|
+
|
|
269
|
+
MIT
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { W3CAction } from '../../types/webdriver.types.js';
|
|
2
|
+
import { BaseCommand } from '../base.command.js';
|
|
3
|
+
interface PerformActionsParams extends Record<string, unknown> {
|
|
4
|
+
sessionId: string;
|
|
5
|
+
actions: W3CAction[];
|
|
6
|
+
}
|
|
7
|
+
export declare class PerformActionsCommand extends BaseCommand<PerformActionsParams, null> {
|
|
8
|
+
readonly name = "performActions";
|
|
9
|
+
readonly method: "POST";
|
|
10
|
+
readonly pathTemplate = "/session/{sessionId}/actions";
|
|
11
|
+
validate(params: PerformActionsParams): void;
|
|
12
|
+
buildBody(params: PerformActionsParams): unknown;
|
|
13
|
+
parseResponse(_raw: unknown): null;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=perform-actions.command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perform-actions.command.d.ts","sourceRoot":"","sources":["../../../src/commands/actions/perform-actions.command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,UAAU,oBAAqB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC5D,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,SAAS,EAAE,CAAC;CACtB;AAED,qBAAa,qBAAsB,SAAQ,WAAW,CAAC,oBAAoB,EAAE,IAAI,CAAC;IAChF,QAAQ,CAAC,IAAI,oBAAoB;IACjC,QAAQ,CAAC,MAAM,EAAG,MAAM,CAAU;IAClC,QAAQ,CAAC,YAAY,kCAAkC;IAE9C,QAAQ,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI;IAUrD,SAAS,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO;IAIhD,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;CAGnC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AppiumError, AppiumErrorCode } from '../../types/error.types.js';
|
|
2
|
+
import { BaseCommand } from '../base.command.js';
|
|
3
|
+
export class PerformActionsCommand extends BaseCommand {
|
|
4
|
+
name = 'performActions';
|
|
5
|
+
method = 'POST';
|
|
6
|
+
pathTemplate = '/session/{sessionId}/actions';
|
|
7
|
+
validate(params) {
|
|
8
|
+
if (!Array.isArray(params.actions) || params.actions.length === 0) {
|
|
9
|
+
throw new AppiumError({
|
|
10
|
+
code: AppiumErrorCode.VALIDATION_ERROR,
|
|
11
|
+
message: '"actions" must be a non-empty array of W3C action sequences',
|
|
12
|
+
httpStatus: 400,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
buildBody(params) {
|
|
17
|
+
return { actions: params.actions };
|
|
18
|
+
}
|
|
19
|
+
parseResponse(_raw) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=perform-actions.command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perform-actions.command.js","sourceRoot":"","sources":["../../../src/commands/actions/perform-actions.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE1E,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAOjD,MAAM,OAAO,qBAAsB,SAAQ,WAAuC;IACvE,IAAI,GAAG,gBAAgB,CAAC;IACxB,MAAM,GAAG,MAAe,CAAC;IACzB,YAAY,GAAG,8BAA8B,CAAC;IAE9C,QAAQ,CAAC,MAA4B;QAC5C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClE,MAAM,IAAI,WAAW,CAAC;gBACpB,IAAI,EAAE,eAAe,CAAC,gBAAgB;gBACtC,OAAO,EAAE,6DAA6D;gBACtE,UAAU,EAAE,GAAG;aAChB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,SAAS,CAAC,MAA4B;QACpC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;IACrC,CAAC;IAED,aAAa,CAAC,IAAa;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TouchAction } from '../../types/webdriver.types.js';
|
|
2
|
+
import { BaseCommand } from '../base.command.js';
|
|
3
|
+
interface TouchPerformParams extends Record<string, unknown> {
|
|
4
|
+
sessionId: string;
|
|
5
|
+
actions: TouchAction[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Legacy touch actions endpoint.
|
|
9
|
+
* Prefer PerformActionsCommand (W3C) for new implementations.
|
|
10
|
+
* Kept for compatibility with older Appium servers.
|
|
11
|
+
*/
|
|
12
|
+
export declare class TouchPerformCommand extends BaseCommand<TouchPerformParams, null> {
|
|
13
|
+
readonly name = "touchPerform";
|
|
14
|
+
readonly method: "POST";
|
|
15
|
+
readonly pathTemplate = "/session/{sessionId}/touch/perform";
|
|
16
|
+
validate(params: TouchPerformParams): void;
|
|
17
|
+
buildBody(params: TouchPerformParams): unknown;
|
|
18
|
+
parseResponse(_raw: unknown): null;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=touch-perform.command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"touch-perform.command.d.ts","sourceRoot":"","sources":["../../../src/commands/actions/touch-perform.command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,UAAU,kBAAmB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AAED;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,WAAW,CAAC,kBAAkB,EAAE,IAAI,CAAC;IAC5E,QAAQ,CAAC,IAAI,kBAAkB;IAC/B,QAAQ,CAAC,MAAM,EAAG,MAAM,CAAU;IAClC,QAAQ,CAAC,YAAY,wCAAwC;IAEpD,QAAQ,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI;IAUnD,SAAS,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO;IAI9C,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;CAGnC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AppiumError, AppiumErrorCode } from '../../types/error.types.js';
|
|
2
|
+
import { BaseCommand } from '../base.command.js';
|
|
3
|
+
/**
|
|
4
|
+
* Legacy touch actions endpoint.
|
|
5
|
+
* Prefer PerformActionsCommand (W3C) for new implementations.
|
|
6
|
+
* Kept for compatibility with older Appium servers.
|
|
7
|
+
*/
|
|
8
|
+
export class TouchPerformCommand extends BaseCommand {
|
|
9
|
+
name = 'touchPerform';
|
|
10
|
+
method = 'POST';
|
|
11
|
+
pathTemplate = '/session/{sessionId}/touch/perform';
|
|
12
|
+
validate(params) {
|
|
13
|
+
if (!Array.isArray(params.actions) || params.actions.length === 0) {
|
|
14
|
+
throw new AppiumError({
|
|
15
|
+
code: AppiumErrorCode.VALIDATION_ERROR,
|
|
16
|
+
message: '"actions" must be a non-empty array of touch action objects',
|
|
17
|
+
httpStatus: 400,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
buildBody(params) {
|
|
22
|
+
return { actions: params.actions };
|
|
23
|
+
}
|
|
24
|
+
parseResponse(_raw) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=touch-perform.command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"touch-perform.command.js","sourceRoot":"","sources":["../../../src/commands/actions/touch-perform.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE1E,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAOjD;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,WAAqC;IACnE,IAAI,GAAG,cAAc,CAAC;IACtB,MAAM,GAAG,MAAe,CAAC;IACzB,YAAY,GAAG,oCAAoC,CAAC;IAEpD,QAAQ,CAAC,MAA0B;QAC1C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClE,MAAM,IAAI,WAAW,CAAC;gBACpB,IAAI,EAAE,eAAe,CAAC,gBAAgB;gBACtC,OAAO,EAAE,6DAA6D;gBACtE,UAAU,EAAE,GAAG;aAChB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,SAAS,CAAC,MAA0B;QAClC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;IACrC,CAAC;IAED,aAAa,CAAC,IAAa;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { CommandRequestConfig } from '../types/command.types.js';
|
|
2
|
+
import type { HttpMethod } from '../types/webdriver.types.js';
|
|
3
|
+
export declare abstract class BaseCommand<TParams extends Record<string, unknown>, TResult> {
|
|
4
|
+
abstract readonly name: string;
|
|
5
|
+
abstract readonly method: HttpMethod;
|
|
6
|
+
/**
|
|
7
|
+
* W3C path template with {placeholder} tokens.
|
|
8
|
+
* e.g. '/session/{sessionId}/element/{elementId}/click'
|
|
9
|
+
* The full URL prefix (/wd/hub) is handled by the provider.
|
|
10
|
+
*/
|
|
11
|
+
abstract readonly pathTemplate: string;
|
|
12
|
+
/**
|
|
13
|
+
* Validate incoming params. Throw AppiumError with VALIDATION_ERROR on failure.
|
|
14
|
+
* Default implementation is a no-op; override to add validation.
|
|
15
|
+
*/
|
|
16
|
+
validate(_params: TParams): void;
|
|
17
|
+
/**
|
|
18
|
+
* Build the JSON body to send. Return undefined for GET/DELETE requests.
|
|
19
|
+
*/
|
|
20
|
+
abstract buildBody(params: TParams): unknown | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Parse the raw Appium/W3C response body into a typed result.
|
|
23
|
+
*/
|
|
24
|
+
abstract parseResponse(raw: unknown): TResult;
|
|
25
|
+
/**
|
|
26
|
+
* Resolve the path template to an actual path by substituting {tokens} with values from params.
|
|
27
|
+
* Override for non-standard path resolution logic.
|
|
28
|
+
*/
|
|
29
|
+
resolvePath(params: TParams): string;
|
|
30
|
+
/**
|
|
31
|
+
* Build the complete request config (method, resolved path, body) from params.
|
|
32
|
+
* Called by CommandInvoker.
|
|
33
|
+
*/
|
|
34
|
+
buildRequestConfig(params: TParams): CommandRequestConfig;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=base.command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.command.d.ts","sourceRoot":"","sources":["../../src/commands/base.command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,8BAAsB,WAAW,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;IAChF,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAErC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAEvC;;;OAGG;IAEH,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIhC;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS;IAExD;;OAEG;IACH,QAAQ,CAAC,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO;IAE7C;;;OAGG;IACH,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM;IAcpC;;;OAGG;IACH,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,oBAAoB;CAQ1D"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AppiumError, AppiumErrorCode } from '../types/error.types.js';
|
|
2
|
+
export class BaseCommand {
|
|
3
|
+
/**
|
|
4
|
+
* Validate incoming params. Throw AppiumError with VALIDATION_ERROR on failure.
|
|
5
|
+
* Default implementation is a no-op; override to add validation.
|
|
6
|
+
*/
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8
|
+
validate(_params) {
|
|
9
|
+
// no-op by default
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Resolve the path template to an actual path by substituting {tokens} with values from params.
|
|
13
|
+
* Override for non-standard path resolution logic.
|
|
14
|
+
*/
|
|
15
|
+
resolvePath(params) {
|
|
16
|
+
return this.pathTemplate.replace(/\{(\w+)\}/g, (_, key) => {
|
|
17
|
+
const value = params[key];
|
|
18
|
+
if (value === undefined || value === null) {
|
|
19
|
+
throw new AppiumError({
|
|
20
|
+
code: AppiumErrorCode.VALIDATION_ERROR,
|
|
21
|
+
message: `Missing required path parameter: "${key}" for command "${this.name}"`,
|
|
22
|
+
httpStatus: 400,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return String(value);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Build the complete request config (method, resolved path, body) from params.
|
|
30
|
+
* Called by CommandInvoker.
|
|
31
|
+
*/
|
|
32
|
+
buildRequestConfig(params) {
|
|
33
|
+
this.validate(params);
|
|
34
|
+
return {
|
|
35
|
+
method: this.method,
|
|
36
|
+
path: this.resolvePath(params),
|
|
37
|
+
body: this.buildBody(params),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=base.command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.command.js","sourceRoot":"","sources":["../../src/commands/base.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAIvE,MAAM,OAAgB,WAAW;IAW/B;;;OAGG;IACH,6DAA6D;IAC7D,QAAQ,CAAC,OAAgB;QACvB,mBAAmB;IACrB,CAAC;IAYD;;;OAGG;IACH,WAAW,CAAC,MAAe;QACzB,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,GAAW,EAAE,EAAE;YAChE,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAC1B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBAC1C,MAAM,IAAI,WAAW,CAAC;oBACpB,IAAI,EAAE,eAAe,CAAC,gBAAgB;oBACtC,OAAO,EAAE,qCAAqC,GAAG,kBAAkB,IAAI,CAAC,IAAI,GAAG;oBAC/E,UAAU,EAAE,GAAG;iBAChB,CAAC,CAAC;YACL,CAAC;YACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,kBAAkB,CAAC,MAAe;QAChC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACtB,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YAC9B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;SAC7B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseCommand } from './base.command.js';
|
|
2
|
+
type AnyCommand = BaseCommand<Record<string, unknown>, any>;
|
|
3
|
+
export declare function getCommand(name: string): AnyCommand;
|
|
4
|
+
export declare function hasCommand(name: string): boolean;
|
|
5
|
+
export declare function getSupportedCommands(): string[];
|
|
6
|
+
/**
|
|
7
|
+
* Register a custom command at runtime.
|
|
8
|
+
* Use this to extend the registry without modifying source.
|
|
9
|
+
*/
|
|
10
|
+
export declare function registerCommand(command: AnyCommand): void;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=command.registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.registry.d.ts","sourceRoot":"","sources":["../../src/commands/command.registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAoDhD,KAAK,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC;AAyD5D,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAUnD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAE/C;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAEzD"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { AppiumError, AppiumErrorCode } from '../types/error.types.js';
|
|
2
|
+
// Session
|
|
3
|
+
import { CreateSessionCommand } from './session/create-session.command.js';
|
|
4
|
+
import { GetSessionCommand } from './session/get-session.command.js';
|
|
5
|
+
import { DeleteSessionCommand } from './session/delete-session.command.js';
|
|
6
|
+
// Element
|
|
7
|
+
import { FindElementCommand } from './element/find-element.command.js';
|
|
8
|
+
import { FindElementsCommand } from './element/find-elements.command.js';
|
|
9
|
+
import { ClickElementCommand } from './element/click-element.command.js';
|
|
10
|
+
import { SetValueCommand } from './element/set-value.command.js';
|
|
11
|
+
import { ClearElementCommand } from './element/clear-element.command.js';
|
|
12
|
+
import { GetElementDisplayedCommand } from './element/get-element-displayed.command.js';
|
|
13
|
+
import { GetElementRectCommand } from './element/get-element-rect.command.js';
|
|
14
|
+
import { GetElementAttributeCommand } from './element/get-element-attribute.command.js';
|
|
15
|
+
import { GetElementLocationCommand } from './element/get-element-location.command.js';
|
|
16
|
+
import { GetElementSizeCommand } from './element/get-element-size.command.js';
|
|
17
|
+
import { GetElementTextCommand } from './element/get-element-text.command.js';
|
|
18
|
+
// Page
|
|
19
|
+
import { GetSourceCommand } from './page/get-source.command.js';
|
|
20
|
+
import { GetScreenshotCommand } from './page/get-screenshot.command.js';
|
|
21
|
+
// Actions
|
|
22
|
+
import { PerformActionsCommand } from './actions/perform-actions.command.js';
|
|
23
|
+
import { TouchPerformCommand } from './actions/touch-perform.command.js';
|
|
24
|
+
// Context
|
|
25
|
+
import { GetContextCommand } from './context/get-context.command.js';
|
|
26
|
+
import { SetContextCommand } from './context/set-context.command.js';
|
|
27
|
+
import { GetContextsCommand } from './context/get-contexts.command.js';
|
|
28
|
+
// Window
|
|
29
|
+
import { GetWindowHandlesCommand } from './window/get-window-handles.command.js';
|
|
30
|
+
import { GetWindowCommand } from './window/get-window.command.js';
|
|
31
|
+
import { SwitchWindowCommand } from './window/switch-window.command.js';
|
|
32
|
+
// Device
|
|
33
|
+
import { HideKeyboardCommand } from './device/hide-keyboard.command.js';
|
|
34
|
+
import { IsKeyboardShownCommand } from './device/is-keyboard-shown.command.js';
|
|
35
|
+
import { PressKeycodeCommand } from './device/press-keycode.command.js';
|
|
36
|
+
import { ActivateAppCommand } from './device/activate-app.command.js';
|
|
37
|
+
import { TerminateAppCommand } from './device/terminate-app.command.js';
|
|
38
|
+
import { SetOrientationCommand } from './device/set-orientation.command.js';
|
|
39
|
+
import { SetLocationCommand } from './device/set-location.command.js';
|
|
40
|
+
// Script
|
|
41
|
+
import { ExecuteScriptCommand } from './script/execute-script.command.js';
|
|
42
|
+
import { ExecuteScriptSyncCommand } from './script/execute-script-sync.command.js';
|
|
43
|
+
const commands = [
|
|
44
|
+
// Session (3)
|
|
45
|
+
new CreateSessionCommand(),
|
|
46
|
+
new GetSessionCommand(),
|
|
47
|
+
new DeleteSessionCommand(),
|
|
48
|
+
// Element (11)
|
|
49
|
+
new FindElementCommand(),
|
|
50
|
+
new FindElementsCommand(),
|
|
51
|
+
new ClickElementCommand(),
|
|
52
|
+
new SetValueCommand(),
|
|
53
|
+
new ClearElementCommand(),
|
|
54
|
+
new GetElementDisplayedCommand(),
|
|
55
|
+
new GetElementRectCommand(),
|
|
56
|
+
new GetElementAttributeCommand(),
|
|
57
|
+
new GetElementLocationCommand(),
|
|
58
|
+
new GetElementSizeCommand(),
|
|
59
|
+
new GetElementTextCommand(),
|
|
60
|
+
// Page (2)
|
|
61
|
+
new GetSourceCommand(),
|
|
62
|
+
new GetScreenshotCommand(),
|
|
63
|
+
// Actions (2)
|
|
64
|
+
new PerformActionsCommand(),
|
|
65
|
+
new TouchPerformCommand(),
|
|
66
|
+
// Context (3)
|
|
67
|
+
new GetContextCommand(),
|
|
68
|
+
new SetContextCommand(),
|
|
69
|
+
new GetContextsCommand(),
|
|
70
|
+
// Window (3)
|
|
71
|
+
new GetWindowHandlesCommand(),
|
|
72
|
+
new GetWindowCommand(),
|
|
73
|
+
new SwitchWindowCommand(),
|
|
74
|
+
// Device (7)
|
|
75
|
+
new HideKeyboardCommand(),
|
|
76
|
+
new IsKeyboardShownCommand(),
|
|
77
|
+
new PressKeycodeCommand(),
|
|
78
|
+
new ActivateAppCommand(),
|
|
79
|
+
new TerminateAppCommand(),
|
|
80
|
+
new SetOrientationCommand(),
|
|
81
|
+
new SetLocationCommand(),
|
|
82
|
+
// Script (2)
|
|
83
|
+
new ExecuteScriptCommand(),
|
|
84
|
+
new ExecuteScriptSyncCommand(),
|
|
85
|
+
];
|
|
86
|
+
const registry = new Map(commands.map((cmd) => [cmd.name, cmd]));
|
|
87
|
+
export function getCommand(name) {
|
|
88
|
+
const command = registry.get(name);
|
|
89
|
+
if (!command) {
|
|
90
|
+
throw new AppiumError({
|
|
91
|
+
code: AppiumErrorCode.UNKNOWN_COMMAND,
|
|
92
|
+
message: `Unknown command: "${name}". Supported commands: ${[...registry.keys()].join(', ')}`,
|
|
93
|
+
httpStatus: 400,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return command;
|
|
97
|
+
}
|
|
98
|
+
export function hasCommand(name) {
|
|
99
|
+
return registry.has(name);
|
|
100
|
+
}
|
|
101
|
+
export function getSupportedCommands() {
|
|
102
|
+
return [...registry.keys()];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Register a custom command at runtime.
|
|
106
|
+
* Use this to extend the registry without modifying source.
|
|
107
|
+
*/
|
|
108
|
+
export function registerCommand(command) {
|
|
109
|
+
registry.set(command.name, command);
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=command.registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.registry.js","sourceRoot":"","sources":["../../src/commands/command.registry.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseCommand } from '../base.command.js';
|
|
2
|
+
interface GetContextParams extends Record<string, unknown> {
|
|
3
|
+
sessionId: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class GetContextCommand extends BaseCommand<GetContextParams, string> {
|
|
6
|
+
readonly name = "getContext";
|
|
7
|
+
readonly method: "GET";
|
|
8
|
+
readonly pathTemplate = "/session/{sessionId}/context";
|
|
9
|
+
buildBody(_params: GetContextParams): undefined;
|
|
10
|
+
parseResponse(raw: unknown): string;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=get-context.command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-context.command.d.ts","sourceRoot":"","sources":["../../../src/commands/context/get-context.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,UAAU,gBAAiB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACxD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,iBAAkB,SAAQ,WAAW,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAC1E,QAAQ,CAAC,IAAI,gBAAgB;IAC7B,QAAQ,CAAC,MAAM,EAAG,KAAK,CAAU;IACjC,QAAQ,CAAC,YAAY,kCAAkC;IAEvD,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS;IAI/C,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;CAIpC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseCommand } from '../base.command.js';
|
|
2
|
+
export class GetContextCommand extends BaseCommand {
|
|
3
|
+
name = 'getContext';
|
|
4
|
+
method = 'GET';
|
|
5
|
+
pathTemplate = '/session/{sessionId}/context';
|
|
6
|
+
buildBody(_params) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
parseResponse(raw) {
|
|
10
|
+
const body = raw;
|
|
11
|
+
return String(body['value'] ?? 'NATIVE_APP');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=get-context.command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-context.command.js","sourceRoot":"","sources":["../../../src/commands/context/get-context.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAMjD,MAAM,OAAO,iBAAkB,SAAQ,WAAqC;IACjE,IAAI,GAAG,YAAY,CAAC;IACpB,MAAM,GAAG,KAAc,CAAC;IACxB,YAAY,GAAG,8BAA8B,CAAC;IAEvD,SAAS,CAAC,OAAyB;QACjC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,aAAa,CAAC,GAAY;QACxB,MAAM,IAAI,GAAG,GAA8B,CAAC;QAC5C,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,YAAY,CAAC,CAAC;IAC/C,CAAC;CACF"}
|