digital-ai-testing-mcp 2.0.9 → 2.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/README.md +27 -31
- package/dist/api/client.d.ts +3 -3
- package/dist/api/client.js +4 -4
- package/dist/api/client.js.map +1 -1
- package/dist/api/projects.js +1 -1
- package/dist/api/projects.js.map +1 -1
- package/dist/api/reporting.d.ts +6 -1
- package/dist/api/reporting.d.ts.map +1 -1
- package/dist/api/reporting.js +45 -12
- package/dist/api/reporting.js.map +1 -1
- package/dist/api/repository.d.ts +8 -0
- package/dist/api/repository.d.ts.map +1 -1
- package/dist/api/repository.js +20 -9
- package/dist/api/repository.js.map +1 -1
- package/dist/api/test-requests.d.ts +25 -0
- package/dist/api/test-requests.d.ts.map +1 -0
- package/dist/api/test-requests.js +40 -0
- package/dist/api/test-requests.js.map +1 -0
- package/dist/api/usage-reports.d.ts +7 -4
- package/dist/api/usage-reports.d.ts.map +1 -1
- package/dist/api/usage-reports.js +7 -4
- package/dist/api/usage-reports.js.map +1 -1
- package/dist/api/virtual-devices.d.ts +37 -0
- package/dist/api/virtual-devices.d.ts.map +1 -0
- package/dist/api/virtual-devices.js +69 -0
- package/dist/api/virtual-devices.js.map +1 -0
- package/dist/api/webdriver.d.ts +47 -1
- package/dist/api/webdriver.d.ts.map +1 -1
- package/dist/api/webdriver.js +157 -13
- package/dist/api/webdriver.js.map +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/tools/boilerplate-tools.d.ts +9 -0
- package/dist/tools/boilerplate-tools.d.ts.map +1 -1
- package/dist/tools/boilerplate-tools.js +347 -61
- package/dist/tools/boilerplate-tools.js.map +1 -1
- package/dist/tools/device-health-tool.d.ts +3 -0
- package/dist/tools/device-health-tool.d.ts.map +1 -0
- package/dist/tools/device-health-tool.js +175 -0
- package/dist/tools/device-health-tool.js.map +1 -0
- package/dist/tools/device-tools.d.ts +2 -0
- package/dist/tools/device-tools.d.ts.map +1 -1
- package/dist/tools/device-tools.js +67 -6
- package/dist/tools/device-tools.js.map +1 -1
- package/dist/tools/health-tools.d.ts.map +1 -1
- package/dist/tools/health-tools.js +3 -0
- package/dist/tools/health-tools.js.map +1 -1
- package/dist/tools/inspection-tools.d.ts.map +1 -1
- package/dist/tools/inspection-tools.js +41 -2
- package/dist/tools/inspection-tools.js.map +1 -1
- package/dist/tools/meta-tools.d.ts +1 -1
- package/dist/tools/meta-tools.d.ts.map +1 -1
- package/dist/tools/meta-tools.js +4 -4
- package/dist/tools/meta-tools.js.map +1 -1
- package/dist/tools/remediation-tools.js +1 -1
- package/dist/tools/remediation-tools.js.map +1 -1
- package/dist/tools/reporting-tools.d.ts.map +1 -1
- package/dist/tools/reporting-tools.js +79 -21
- package/dist/tools/reporting-tools.js.map +1 -1
- package/dist/tools/repository-tools.js +3 -3
- package/dist/tools/repository-tools.js.map +1 -1
- package/dist/tools/resources.js +3 -3
- package/dist/tools/resources.js.map +1 -1
- package/dist/tools/usage-report-tools.js +1 -1
- package/dist/tools/usage-report-tools.js.map +1 -1
- package/dist/types/digital-ai.d.ts +2 -0
- package/dist/types/digital-ai.d.ts.map +1 -1
- package/dist/utils/access-level.d.ts +1 -1
- package/dist/utils/access-level.d.ts.map +1 -1
- package/dist/utils/api-error.js +1 -1
- package/dist/utils/api-error.js.map +1 -1
- package/dist/utils/device-health.d.ts +52 -0
- package/dist/utils/device-health.d.ts.map +1 -0
- package/dist/utils/device-health.js +76 -0
- package/dist/utils/device-health.js.map +1 -0
- package/dist/utils/device-query.d.ts +6 -0
- package/dist/utils/device-query.d.ts.map +1 -0
- package/dist/utils/device-query.js +10 -0
- package/dist/utils/device-query.js.map +1 -0
- package/dist/utils/device-resolver.d.ts.map +1 -1
- package/dist/utils/device-resolver.js +2 -1
- package/dist/utils/device-resolver.js.map +1 -1
- package/dist/utils/download-command.d.ts +1 -1
- package/dist/utils/download-command.d.ts.map +1 -1
- package/dist/utils/log-view.d.ts +30 -0
- package/dist/utils/log-view.d.ts.map +1 -0
- package/dist/utils/log-view.js +84 -0
- package/dist/utils/log-view.js.map +1 -0
- package/dist/utils/path-guard.js +1 -1
- package/dist/utils/path-guard.js.map +1 -1
- package/dist/utils/performance-comparison.d.ts +1 -1
- package/dist/utils/performance-comparison.d.ts.map +1 -1
- package/dist/utils/performance-comparison.js +3 -2
- package/dist/utils/performance-comparison.js.map +1 -1
- package/dist/utils/performance-stats.js +2 -2
- package/dist/utils/performance-stats.js.map +1 -1
- package/dist/utils/remediation.d.ts +14 -6
- package/dist/utils/remediation.d.ts.map +1 -1
- package/dist/utils/remediation.js +31 -15
- package/dist/utils/remediation.js.map +1 -1
- package/dist/utils/test-orchestrator.d.ts +1 -1
- package/dist/utils/test-orchestrator.d.ts.map +1 -1
- package/dist/utils/test-orchestrator.js +2 -1
- package/dist/utils/test-orchestrator.js.map +1 -1
- package/dist/utils/tool-annotations.d.ts +5 -0
- package/dist/utils/tool-annotations.d.ts.map +1 -1
- package/dist/utils/tool-annotations.js +6 -1
- package/dist/utils/tool-annotations.js.map +1 -1
- package/dist/utils/tool-registry.d.ts +2 -1
- package/dist/utils/tool-registry.d.ts.map +1 -1
- package/dist/utils/tool-registry.js +2 -1
- package/dist/utils/tool-registry.js.map +1 -1
- package/dist/utils/toolsets.d.ts +3 -3
- package/dist/utils/toolsets.d.ts.map +1 -1
- package/dist/utils/toolsets.js +6 -1
- package/dist/utils/toolsets.js.map +1 -1
- package/dist/utils/upload-command.d.ts +1 -1
- package/dist/utils/upload-command.d.ts.map +1 -1
- package/dist/utils/usage-report-summary.d.ts +4 -4
- package/dist/utils/usage-report-summary.d.ts.map +1 -1
- package/dist/utils/usage-report-summary.js +4 -4
- package/dist/utils/usage-report-summary.js.map +1 -1
- package/dist/utils/version.js +1 -1
- package/dist/utils/version.js.map +1 -1
- package/package.json +6 -1
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/wdio-oss.conf.js +2 -2
- package/resources/boilerplate/Android-Native/Robot Framework/AndroidNative-oss.robot +51 -0
- package/resources/boilerplate/Android-Native/Robot Framework/DigitalAiReport.py +36 -0
- package/resources/boilerplate/Android-Native/Robot Framework/pip-oss.txt +2 -0
- package/resources/boilerplate/Web/Robot Framework/DigitalAiWebReport.py +36 -0
- package/resources/boilerplate/iOS-Native/Robot Framework/DigitalAiReport.py +36 -0
- package/resources/boilerplate/iOS-Native/Robot Framework/iOSNative-oss.robot +49 -0
- package/resources/boilerplate/iOS-Native/Robot Framework/pip-oss.txt +2 -0
|
@@ -26,12 +26,14 @@ const LANGUAGE_SUBDIR = {
|
|
|
26
26
|
'java-testng': 'java TestNG',
|
|
27
27
|
'nodejs': 'NodeJS (WebDriver)',
|
|
28
28
|
'python': 'Python',
|
|
29
|
+
'robot': 'Robot Framework',
|
|
29
30
|
},
|
|
30
31
|
ios: {
|
|
31
32
|
'java-junit5': 'java-JUnit5',
|
|
32
33
|
'java-testng': 'java-TestNG',
|
|
33
34
|
'nodejs': 'NodeJS (WebDriver)',
|
|
34
35
|
'python': 'Python',
|
|
36
|
+
'robot': 'Robot Framework',
|
|
35
37
|
},
|
|
36
38
|
};
|
|
37
39
|
function getFilesForVariant(platform, language, isAppiumOss, projectType) {
|
|
@@ -68,7 +70,9 @@ function getFilesForVariant(platform, language, isAppiumOss, projectType) {
|
|
|
68
70
|
return [
|
|
69
71
|
{ filename: 'package.json', diskName: isAppiumOss ? 'package-oss.json' : 'package.json', lang: 'json' },
|
|
70
72
|
{ filename: 'wdio.conf.js', diskName: isAppiumOss ? 'wdio-oss.conf.js' : 'wdio.conf.js', lang: 'javascript' },
|
|
71
|
-
|
|
73
|
+
// Full path: wdio.conf.js loads ./test/specs/<Test>.js. A bare filename saved at the project root ran ZERO tests
|
|
74
|
+
// ("0 spec files", no error) — hit while running the generated project live, 2026-10-16.
|
|
75
|
+
{ filename: `test/specs/${testBase}.js`, diskName: `${testBase}.js`, lang: 'javascript' },
|
|
72
76
|
{ filename: 'setup-steps.sh', diskName: shellDisk, lang: 'sh', isInstructions: true },
|
|
73
77
|
];
|
|
74
78
|
}
|
|
@@ -80,6 +84,13 @@ function getFilesForVariant(platform, language, isAppiumOss, projectType) {
|
|
|
80
84
|
{ filename: 'requirements.txt', diskName: `pip${pipSuffix}${pipExt}`, lang: 'text' },
|
|
81
85
|
];
|
|
82
86
|
}
|
|
87
|
+
case 'robot':
|
|
88
|
+
// Appium Server only — the handler refuses Grid projects before this point.
|
|
89
|
+
return [
|
|
90
|
+
{ filename: `tests/${testBase}.robot`, diskName: `${testBase}-oss.robot`, lang: 'robotframework' },
|
|
91
|
+
{ filename: 'tests/DigitalAiReport.py', diskName: 'DigitalAiReport.py', lang: 'python' },
|
|
92
|
+
{ filename: 'requirements.txt', diskName: 'pip-oss.txt', lang: 'text' },
|
|
93
|
+
];
|
|
83
94
|
}
|
|
84
95
|
}
|
|
85
96
|
// Gradle templates declare `repositories { mavenCentral() }` so the default standalone project resolves its
|
|
@@ -129,7 +140,7 @@ export function detectFabricationIssues(content) {
|
|
|
129
140
|
const webPlaceholder = content.match(/#YOUR_SELECTOR|\.your-class|\[data-testid="placeholder"\]|\[data-testid='placeholder'\]|YOUR_ELEMENT_ID|YOUR_CSS_SELECTOR/gi);
|
|
130
141
|
if (webPlaceholder)
|
|
131
142
|
add('high', 'placeholder CSS selectors', `Unreplaced placeholder CSS selector(s): ${[...new Set(webPlaceholder)].slice(0, 4).join(', ')}`);
|
|
132
|
-
//
|
|
143
|
+
// 6. Soft signal: no inspection session ran in this process — can't be a hard fail
|
|
133
144
|
// (selectors may be source-derived or captured in a since-closed session), but worth surfacing.
|
|
134
145
|
if (listActiveSessions().length === 0) {
|
|
135
146
|
add('info', 'no live inspection session', 'No inspection session is active in this MCP process. If the selectors here were not captured from an inspection or taken from authoritative app source, they are guesses — re-verify before delivering.');
|
|
@@ -231,6 +242,101 @@ function appendAutomotiveCheck(language, indent) {
|
|
|
231
242
|
`${indent}// await browser.execute('digitalai:automotive.tap', x, y); // coordinates within the projection resolution`,
|
|
232
243
|
].join('\n');
|
|
233
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* Wrap the test steps so the platform report carries the real outcome (verified live 2026-10-16):
|
|
247
|
+
* - a session with no WebDriver errors is reported Passed even when the test failed on its own assertion — so the
|
|
248
|
+
* catch block sets Failed with the error message (seetest:client.setReportStatus works on Grid and Appium Server);
|
|
249
|
+
* - on Appium Server the steps sit in a named steps group. The Grid cannot run stopStepsGroup (its execute parser
|
|
250
|
+
* rejects 0-argument seetest commands), so Grid templates get the status only.
|
|
251
|
+
* Arguments are passed separately, never inside the script string (the inline form fails silently).
|
|
252
|
+
*/
|
|
253
|
+
function wrapWithReporting(language, indent, core, isAppiumOss) {
|
|
254
|
+
// Robot templates report through their own Test Teardown (Report Test Outcome) and steps-group keywords.
|
|
255
|
+
if (language === 'robot')
|
|
256
|
+
return core;
|
|
257
|
+
const inner = core.split('\n').map((l) => (l.trim() ? ` ${l}` : l)).join('\n');
|
|
258
|
+
const group = 'Test steps';
|
|
259
|
+
if (language === 'java-junit5' || language === 'java-testng') {
|
|
260
|
+
return [
|
|
261
|
+
`${indent}// Report the real outcome: without this a failed assertion still shows as Passed in the platform report.`,
|
|
262
|
+
`${indent}try {`,
|
|
263
|
+
...(isAppiumOss ? [`${indent} driver.executeScript("seetest:client.startStepsGroup", "${group}");`] : []),
|
|
264
|
+
inner,
|
|
265
|
+
...(isAppiumOss ? [`${indent} driver.executeScript("seetest:client.stopStepsGroup");`] : []),
|
|
266
|
+
`${indent} driver.executeScript("seetest:client.setReportStatus", "Passed", "All steps completed");`,
|
|
267
|
+
`${indent}} catch (RuntimeException | AssertionError e) {`,
|
|
268
|
+
`${indent} try { driver.executeScript("seetest:client.setReportStatus", "Failed", String.valueOf(e.getMessage())); } catch (RuntimeException ignored) {}`,
|
|
269
|
+
`${indent} throw e;`,
|
|
270
|
+
`${indent}}`,
|
|
271
|
+
].join('\n');
|
|
272
|
+
}
|
|
273
|
+
if (language === 'python') {
|
|
274
|
+
return [
|
|
275
|
+
`${indent}# Report the real outcome: without this a failed assertion still shows as Passed in the platform report.`,
|
|
276
|
+
`${indent}try:`,
|
|
277
|
+
...(isAppiumOss ? [`${indent} self.driver.execute_script("seetest:client.startStepsGroup", "${group}")`] : []),
|
|
278
|
+
inner,
|
|
279
|
+
...(isAppiumOss ? [`${indent} self.driver.execute_script("seetest:client.stopStepsGroup")`] : []),
|
|
280
|
+
`${indent} self.driver.execute_script("seetest:client.setReportStatus", "Passed", "All steps completed")`,
|
|
281
|
+
`${indent}except Exception as e:`,
|
|
282
|
+
`${indent} try:`,
|
|
283
|
+
`${indent} self.driver.execute_script("seetest:client.setReportStatus", "Failed", str(e)[:500])`,
|
|
284
|
+
`${indent} except Exception:`,
|
|
285
|
+
`${indent} pass`,
|
|
286
|
+
`${indent} raise`,
|
|
287
|
+
].join('\n');
|
|
288
|
+
}
|
|
289
|
+
return [
|
|
290
|
+
`${indent}// Report the real outcome: without this a failed assertion still shows as Passed in the platform report.`,
|
|
291
|
+
`${indent}try {`,
|
|
292
|
+
...(isAppiumOss ? [`${indent} await browser.execute('seetest:client.startStepsGroup', '${group}');`] : []),
|
|
293
|
+
inner,
|
|
294
|
+
...(isAppiumOss ? [`${indent} await browser.execute('seetest:client.stopStepsGroup');`] : []),
|
|
295
|
+
`${indent} await browser.execute('seetest:client.setReportStatus', 'Passed', 'All steps completed');`,
|
|
296
|
+
`${indent}} catch (e) {`,
|
|
297
|
+
`${indent} await browser.execute('seetest:client.setReportStatus', 'Failed', String(e && e.message).slice(0, 500)).catch(() => {});`,
|
|
298
|
+
`${indent} throw e;`,
|
|
299
|
+
`${indent}}`,
|
|
300
|
+
].join('\n');
|
|
301
|
+
}
|
|
302
|
+
/** Report-key names and values end up inside generated source — keep them to a safe character set. */
|
|
303
|
+
export const REPORT_KEY_NAME_RE = /^[A-Za-z][A-Za-z0-9_.-]{0,49}$/;
|
|
304
|
+
/** Single spaces only: two or more separate cells in Robot Framework and would split the &{CAPABILITIES} row. */
|
|
305
|
+
export const REPORT_KEY_VALUE_RE = /^(?=.{1,100}$)[A-Za-z0-9_.:/@+-]+(?: [A-Za-z0-9_.:/@+-]+)*$/;
|
|
306
|
+
/**
|
|
307
|
+
* digitalai:* capabilities the templates or other parameters already set — a report key with one of these names would
|
|
308
|
+
* be a second capability that silently overrides the first (the later entry wins).
|
|
309
|
+
*/
|
|
310
|
+
export const RESERVED_REPORT_KEYS = new Set([
|
|
311
|
+
'accessKey', 'testName', 'deviceQuery', 'appiumVersion', 'newSessionWaitTimeout', 'automotiveProjection',
|
|
312
|
+
'instrumentCluster', 'instrumentApp', 'reportTestId', 'reportUrl', 'releaseDevice', 'report.disable',
|
|
313
|
+
].map((k) => k.toLowerCase()));
|
|
314
|
+
/**
|
|
315
|
+
* Add capabilities next to the existing ones, for every language and both server modes (the same anchors the Axe
|
|
316
|
+
* option uses: the driver construction line for Java/Python, the deviceQuery entry in the wdio config for Node).
|
|
317
|
+
* Values are strings or numbers; names must already be valid capability names.
|
|
318
|
+
*/
|
|
319
|
+
function injectCapabilities(content, language, isAppiumOss, caps) {
|
|
320
|
+
const entries = Object.entries(caps);
|
|
321
|
+
if (entries.length === 0)
|
|
322
|
+
return content;
|
|
323
|
+
const lit = (v, q) => (typeof v === 'number' ? String(v) : `${q}${v}${q}`);
|
|
324
|
+
if (language === 'robot') {
|
|
325
|
+
// &{CAPABILITIES} dictionary rows; numbers as ${n} so Robot passes an int, not a string.
|
|
326
|
+
return content.replace(/(\n(\.\.\. +)digitalai:deviceQuery=[^\n]*)/, (m, _line, cont) => m + entries.map(([k, v]) => `\n${cont}${k}=${typeof v === 'number' ? `\${${v}}` : v}`).join(''));
|
|
327
|
+
}
|
|
328
|
+
if (language === 'java-junit5' || language === 'java-testng') {
|
|
329
|
+
const obj = isAppiumOss ? 'options' : 'dc';
|
|
330
|
+
return content.replace(/\n( +)(driver = new (?:Android|iOS)Driver)/, (_m, sp, line) => '\n' + entries.map(([k, v]) => `${sp}${obj}.setCapability("${k}", ${lit(v, '"')});\n`).join('') + `${sp}${line}`);
|
|
331
|
+
}
|
|
332
|
+
if (language === 'python') {
|
|
333
|
+
const viaOptions = content.includes('options=options');
|
|
334
|
+
return content.replace(/\n( +)(self\.driver = webdriver\.Remote\()/, (_m, sp, line) => '\n' + entries.map(([k, v]) => viaOptions
|
|
335
|
+
? `${sp}options.set_capability('${k}', ${lit(v, "'")})\n`
|
|
336
|
+
: `${sp}desired_caps['${k}'] = ${lit(v, "'")}\n`).join('') + `${sp}${line}`);
|
|
337
|
+
}
|
|
338
|
+
return content.replace(/('digitalai:deviceQuery': [^\n]+)/, (m) => m + entries.map(([k, v]) => `\n '${k}': ${lit(v, "'")},`).join(''));
|
|
339
|
+
}
|
|
234
340
|
// The cleared-body placeholder is a deliberate ANTI-fabrication guard (v38).
|
|
235
341
|
// Three properties matter: (1) a loud banner so the scaffold is never mistaken
|
|
236
342
|
// for a finished test; (2) an EXECUTABLE fail/raise as the first statement so a
|
|
@@ -250,10 +356,12 @@ function failGuard(language, indent) {
|
|
|
250
356
|
return `${indent}raise NotImplementedError("${msg}")`;
|
|
251
357
|
case 'nodejs':
|
|
252
358
|
return `${indent}throw new Error('${msg}');`;
|
|
359
|
+
case 'robot':
|
|
360
|
+
return `${indent}Fail ${msg}`;
|
|
253
361
|
}
|
|
254
362
|
}
|
|
255
363
|
function buildPlaceholder(language, platform, indent) {
|
|
256
|
-
const c = language === 'python' ? '#' : '//';
|
|
364
|
+
const c = language === 'python' || language === 'robot' ? '#' : '//';
|
|
257
365
|
const idTerm = platform === 'android' ? 'resource-id' : 'accessibility id';
|
|
258
366
|
const banner = [
|
|
259
367
|
`${indent}${c} ============================================================================`,
|
|
@@ -269,7 +377,17 @@ function buildPlaceholder(language, platform, indent) {
|
|
|
269
377
|
];
|
|
270
378
|
// Example shapes use <…> tokens so they read as obviously-unfilled, never as real selectors.
|
|
271
379
|
let examples;
|
|
272
|
-
if (
|
|
380
|
+
if (language === 'robot') {
|
|
381
|
+
const id = platform === 'android' ? 'id=<resource-id from get_element_tree>' : "xpath=//*[@name='<accessibility id from get_element_tree>']";
|
|
382
|
+
const field = platform === 'android' ? 'id=<resource-id>' : "xpath=//*[@name='<accessibility id>']";
|
|
383
|
+
examples = [
|
|
384
|
+
`${indent}${c} Example shape only — every <…> must be replaced with a value from inspection:`,
|
|
385
|
+
`${indent}${c} Click Element ${id}`,
|
|
386
|
+
`${indent}${c} Input Text ${field} <value the user gave you>`,
|
|
387
|
+
`${indent}${c} Page Should Contain Text <visible text>`,
|
|
388
|
+
];
|
|
389
|
+
}
|
|
390
|
+
else if (platform === 'android') {
|
|
273
391
|
if (language === 'java-junit5' || language === 'java-testng') {
|
|
274
392
|
examples = [
|
|
275
393
|
`${indent}${c} Example shape only — every <…> must be replaced with a value from inspection:`,
|
|
@@ -339,37 +457,25 @@ function substitute(content, language, platform, vars) {
|
|
|
339
457
|
if (DEMO_STEP_PATTERN.test(result)) {
|
|
340
458
|
const indentMatch = result.match(/([^\S\n]*)(?:\/\/|#) \[BEGIN_DEMO_STEPS\]/);
|
|
341
459
|
const indent = indentMatch?.[1] ?? ' ';
|
|
460
|
+
// Layers, innermost first: steps (or the placeholder) → Axe scan / automotive check → performance transaction →
|
|
461
|
+
// report status / steps group.
|
|
462
|
+
const decorate = (core) => {
|
|
463
|
+
let content = core;
|
|
464
|
+
if (vars.axeScan)
|
|
465
|
+
content += '\n' + appendAxeScan(language, indent, vars.axeApiKey ?? '');
|
|
466
|
+
if (vars.automotiveProjection)
|
|
467
|
+
content += '\n' + appendAutomotiveCheck(language, indent);
|
|
468
|
+
if (vars.performanceTransactions)
|
|
469
|
+
content = wrapWithPerformanceTransaction(language, indent, content);
|
|
470
|
+
if (vars.reportStatus)
|
|
471
|
+
content = wrapWithReporting(language, indent, content, !!vars.isAppiumOss);
|
|
472
|
+
return content;
|
|
473
|
+
};
|
|
342
474
|
if (vars.clearTestBody) {
|
|
343
|
-
|
|
344
|
-
if (vars.axeScan) {
|
|
345
|
-
placeholder += '\n' + appendAxeScan(language, indent, vars.axeApiKey ?? '');
|
|
346
|
-
}
|
|
347
|
-
if (vars.automotiveProjection) {
|
|
348
|
-
placeholder += '\n' + appendAutomotiveCheck(language, indent);
|
|
349
|
-
}
|
|
350
|
-
if (vars.performanceTransactions) {
|
|
351
|
-
placeholder = wrapWithPerformanceTransaction(language, indent, placeholder);
|
|
352
|
-
}
|
|
353
|
-
result = result.replace(DEMO_STEP_PATTERN, placeholder);
|
|
354
|
-
}
|
|
355
|
-
else if (vars.performanceTransactions || vars.axeScan || vars.automotiveProjection) {
|
|
356
|
-
result = result.replace(DEMO_INNER_PATTERN, (inner) => {
|
|
357
|
-
let content = inner;
|
|
358
|
-
if (vars.axeScan) {
|
|
359
|
-
content += '\n' + appendAxeScan(language, indent, vars.axeApiKey ?? '');
|
|
360
|
-
}
|
|
361
|
-
if (vars.automotiveProjection) {
|
|
362
|
-
content += '\n' + appendAutomotiveCheck(language, indent);
|
|
363
|
-
}
|
|
364
|
-
return vars.performanceTransactions
|
|
365
|
-
? wrapWithPerformanceTransaction(language, indent, content)
|
|
366
|
-
: content;
|
|
367
|
-
});
|
|
368
|
-
result = result.replace(/[^\S\n]*(?:\/\/|#) \[BEGIN_DEMO_STEPS\]\n/, '');
|
|
369
|
-
result = result.replace(/\n[^\S\n]*(?:\/\/|#) \[END_DEMO_STEPS\]/, '');
|
|
475
|
+
result = result.replace(DEMO_STEP_PATTERN, () => decorate(buildPlaceholder(language, platform, indent)));
|
|
370
476
|
}
|
|
371
477
|
else {
|
|
372
|
-
|
|
478
|
+
result = result.replace(DEMO_INNER_PATTERN, (inner) => decorate(inner));
|
|
373
479
|
result = result.replace(/[^\S\n]*(?:\/\/|#) \[BEGIN_DEMO_STEPS\]\n/, '');
|
|
374
480
|
result = result.replace(/\n[^\S\n]*(?:\/\/|#) \[END_DEMO_STEPS\]/, '');
|
|
375
481
|
}
|
|
@@ -400,13 +506,13 @@ function substitute(content, language, platform, vars) {
|
|
|
400
506
|
if (language === 'java-junit5' || language === 'java-testng') {
|
|
401
507
|
const obj = vars.isAppiumOss ? 'options' : 'dc';
|
|
402
508
|
result = result.replace(/\n( +)(driver = new (?:Android|iOS)Driver)/, (_m, sp, line) => `\n${sp}${obj}.setCapability("appium:automationName", "${automationName}");\n` +
|
|
403
|
-
`${sp}${obj}.setCapability("appiumVersion", "2.16.2");\n` +
|
|
509
|
+
`${sp}${obj}.setCapability("${vars.isAppiumOss ? 'digitalai:appiumVersion' : 'appiumVersion'}", "2.16.2");\n` +
|
|
404
510
|
`${sp}${line}`);
|
|
405
511
|
}
|
|
406
512
|
else if (language === 'python') {
|
|
407
513
|
if (result.includes('options=options')) {
|
|
408
514
|
result = result.replace(/\n( +)(self\.driver = webdriver\.Remote\()/, (_m, sp, line) => `\n${sp}options.set_capability('appium:automationName', '${automationName}')\n` +
|
|
409
|
-
`${sp}options.set_capability('appiumVersion', '2.16.2')\n` +
|
|
515
|
+
`${sp}options.set_capability('digitalai:appiumVersion', '2.16.2')\n` +
|
|
410
516
|
`${sp}${line}`);
|
|
411
517
|
}
|
|
412
518
|
else {
|
|
@@ -416,7 +522,7 @@ function substitute(content, language, platform, vars) {
|
|
|
416
522
|
}
|
|
417
523
|
}
|
|
418
524
|
else if (language === 'nodejs') {
|
|
419
|
-
result = result.replace(/('digitalai:deviceQuery': [^\n]+)/, (match) => `${match}\n 'appium:automationName': '${automationName}',\n 'appiumVersion': '2.16.2',`);
|
|
525
|
+
result = result.replace(/('digitalai:deviceQuery': [^\n]+)/, (match) => `${match}\n 'appium:automationName': '${automationName}',\n '${vars.isAppiumOss ? 'digitalai:appiumVersion' : 'appiumVersion'}': '2.16.2',`);
|
|
420
526
|
}
|
|
421
527
|
}
|
|
422
528
|
if (vars.automotiveProjection) {
|
|
@@ -431,6 +537,8 @@ function substitute(content, language, platform, vars) {
|
|
|
431
537
|
result = result.replace(/('digitalai:deviceQuery': [^\n]+)/, (match) => `${match}\n 'digitalai:automotiveProjection': '${res}',`);
|
|
432
538
|
}
|
|
433
539
|
}
|
|
540
|
+
if (vars.extraCaps)
|
|
541
|
+
result = injectCapabilities(result, language, !!vars.isAppiumOss, vars.extraCaps);
|
|
434
542
|
return result;
|
|
435
543
|
}
|
|
436
544
|
function setupNote(language, isAppiumOss, projectType) {
|
|
@@ -503,6 +611,17 @@ function setupNote(language, isAppiumOss, projectType) {
|
|
|
503
611
|
' • Use appium.webdriver.webelement.WebElement (not selenium\'s) for is_displayed()\n\n' +
|
|
504
612
|
'If you can migrate this project to Appium Server, all of these workarounds go away.\n' +
|
|
505
613
|
'Error "Cant run Appium Grid with Appium client 8+" = W3C format rejected by grid (not a version issue).';
|
|
614
|
+
case 'robot':
|
|
615
|
+
return ('Save the files in this layout:\n' +
|
|
616
|
+
' requirements.txt ← project root\n' +
|
|
617
|
+
' tests/<Suite>.robot\n' +
|
|
618
|
+
' tests/DigitalAiReport.py ← next to the suite (it is imported by relative path)\n\n' +
|
|
619
|
+
'Then run:\n' +
|
|
620
|
+
' pip install -r requirements.txt (robotframework 7.5 + robotframework-appiumlibrary 3.2.1)\n' +
|
|
621
|
+
' robot --outputdir results tests/\n\n' +
|
|
622
|
+
'The access key is read from DIGITAL_AI_ACCESS_KEY when set; the value after "=" in ${ACCESS_KEY} is the fallback — ' +
|
|
623
|
+
'remove it before committing. The Test Teardown sets the platform report to Passed / Failed / Skipped from Robot\'s ' +
|
|
624
|
+
'own result, and the steps run inside a named steps group. Run suites in parallel with pabot (pip install robotframework-pabot).');
|
|
506
625
|
}
|
|
507
626
|
}
|
|
508
627
|
function appNote(platform, packageName, bundleIdentifier, mainActivity, resolvedFromAppId) {
|
|
@@ -524,7 +643,9 @@ function appNote(platform, packageName, bundleIdentifier, mainActivity, resolved
|
|
|
524
643
|
return 'Replace com.experitest.ExperiBank with your app\'s bundle ID. Replace the test steps with interactions specific to your app.';
|
|
525
644
|
}
|
|
526
645
|
export function registerBoilerplateTools(server) {
|
|
527
|
-
server.tool('get_test_boilerplate', '
|
|
646
|
+
server.tool('get_test_boilerplate', 'DEMO: called WITHOUT appId / packageName / bundleIdentifier it returns a runnable test for the ExperiBank demo app ' +
|
|
647
|
+
'(com.experitest.ExperiBank — "SeeTestDemoApp" in the repository) with verified steps — no inspection needed for it. ' +
|
|
648
|
+
'STOP — when you target a real app (appId, packageName, or bundleIdentifier) this tool returns NO code unless ' +
|
|
528
649
|
'a live inspection session exists OR you set confirmSelectorsVerified:true. Without a selector source it blocks ' +
|
|
529
650
|
'with a redirect to start_inspection_session — there is nothing to "fill in later". Do not attempt to work around ' +
|
|
530
651
|
'the block by writing the test from scratch; capture real selectors first.\n\n' +
|
|
@@ -597,12 +718,16 @@ export function registerBoilerplateTools(server) {
|
|
|
597
718
|
'Reference the outer driver field instead: wait.until(d -> !driver.currentActivity().contains("LoginActivity")). ' +
|
|
598
719
|
'DIAGNOSTIC: If a test suite that previously passed begins failing with NoSuchElementException on elements that other ' +
|
|
599
720
|
'tests in the same run find without issue (session connects and app launches normally), this is a device health signal — ' +
|
|
600
|
-
'NOT a code or timing issue. Check device health first with get_device_health_summary or list_devices before modifying test code
|
|
721
|
+
'NOT a code or timing issue. Check device health first with get_device_health_summary or list_devices before modifying test code.\n\n' +
|
|
722
|
+
'TELEPHONY (two-phone calls, SMS, MMS, call audio): there is no template here. Review the reference project ' +
|
|
723
|
+
'https://github.com/dai-continuous-testing/UseCase-SIM-Card-Tests first — it is the working, maintained flow on this ' +
|
|
724
|
+
'platform (placing and answering calls across dialers, SMS/MMS, audio injection and recording, call-quality scoring) — ' +
|
|
725
|
+
'and adapt it; use audio_control and find_available_device(requireAudioLine: true) to explore in an inspection session.', {
|
|
601
726
|
platform: caseInsensitiveEnum(['android', 'ios'])
|
|
602
727
|
.describe("Target mobile platform: 'android' or 'ios'."),
|
|
603
728
|
language: z
|
|
604
|
-
.enum(['java-junit5', 'java-testng', 'nodejs', 'python'])
|
|
605
|
-
.describe("Test framework and language: 'java-junit5', 'java-testng', 'nodejs' (WebDriverIO), or '
|
|
729
|
+
.enum(['java-junit5', 'java-testng', 'nodejs', 'python', 'robot'])
|
|
730
|
+
.describe("Test framework and language: 'java-junit5', 'java-testng', 'nodejs' (WebDriverIO), 'python' (Appium), or 'robot' (Robot Framework + AppiumLibrary — Appium Server projects only; not combinable with includePerformanceTransactions, includeAxeScan or automotiveProjection)."),
|
|
606
731
|
appId: z
|
|
607
732
|
.number()
|
|
608
733
|
.optional()
|
|
@@ -675,6 +800,37 @@ export function registerBoilerplateTools(server) {
|
|
|
675
800
|
'The Axe API key is read from AXE_DEVTOOLS_API_KEY in the MCP environment; if not set, a placeholder is used. ' +
|
|
676
801
|
'Scan results appear in the Axe DevTools Mobile dashboard. ' +
|
|
677
802
|
'Can be combined with includePerformanceTransactions — the scan runs inside the performance transaction boundary.'),
|
|
803
|
+
reportStatus: z
|
|
804
|
+
.boolean()
|
|
805
|
+
.optional()
|
|
806
|
+
.default(true)
|
|
807
|
+
.describe('Default true. Wraps the test steps so the platform report shows the REAL outcome: a failure sets the report to ' +
|
|
808
|
+
'Failed with the error message (without this, a session with no WebDriver errors is reported Passed even when ' +
|
|
809
|
+
'an assertion failed), and on Appium Server the steps are grouped in a named steps group. ' +
|
|
810
|
+
'Set false only when the user wants the bare steps.'),
|
|
811
|
+
appiumVersion: z
|
|
812
|
+
.string()
|
|
813
|
+
.regex(/^\d+\.\d+(\.\d+)?$/, 'Use a version number such as "2.18.0".')
|
|
814
|
+
.optional()
|
|
815
|
+
.describe('Appium Server projects only: pin the Appium version the session runs on (digitalai:appiumVersion). Omit to use ' +
|
|
816
|
+
'the platform default. An unavailable version fails the session at start with the list of versions the platform ' +
|
|
817
|
+
'offers. Not combinable with includeAxeScan, which pins 2.16.2 itself.'),
|
|
818
|
+
newSessionWaitTimeout: z
|
|
819
|
+
.number()
|
|
820
|
+
.int()
|
|
821
|
+
.min(10)
|
|
822
|
+
.max(3600)
|
|
823
|
+
.optional()
|
|
824
|
+
.describe('Seconds the platform may wait for a free matching device before failing the session (digitalai:newSessionWaitTimeout). ' +
|
|
825
|
+
'Without it, a device query that matches nothing or a busy pool keeps the test waiting for 5+ minutes with no ' +
|
|
826
|
+
'reason; with it the session fails with "No available device matching the query: …". E.g. 300 for CI. ' +
|
|
827
|
+
'Works on Appium Server and Appium Grid.'),
|
|
828
|
+
reportKeys: z
|
|
829
|
+
.record(z.string().regex(REPORT_KEY_NAME_RE, 'Key names: letters, digits, _ . - (start with a letter).'), z.string().regex(REPORT_KEY_VALUE_RE, 'Values: up to 100 of letters, digits, single spaces and _ . : / @ + -'))
|
|
830
|
+
.optional()
|
|
831
|
+
.describe('Custom report keys, e.g. {"runId": "nightly-42", "build": "1.4.0"}. Each is sent as a digitalai:<key> capability and ' +
|
|
832
|
+
'stored on the platform report — find the runs later with list_test_reports filter [{property: "runId", operator: "=", ' +
|
|
833
|
+
'value: "nightly-42"}] (and keys: ["runId"] to see the value). Works on Appium Server and Appium Grid.'),
|
|
678
834
|
automotiveProjection: z
|
|
679
835
|
.enum(AUTOMOTIVE_RESOLUTIONS)
|
|
680
836
|
.optional()
|
|
@@ -711,7 +867,7 @@ export function registerBoilerplateTools(server) {
|
|
|
711
867
|
.describe('Orchestrated projects only: run.maxRetryAttempts in the agent config. Default 2 — or 0 when the test body is ' +
|
|
712
868
|
'a placeholder (fails by design) or includePerformanceTransactions is set (retries would skew samples).'),
|
|
713
869
|
outputFormat: outputFormatParam,
|
|
714
|
-
}, async ({ platform, language, appId, deviceCategory, testName, packageName, mainActivity, bundleIdentifier, projectType, region, includePerformanceTransactions, includeAxeScan, automotiveProjection, confirmSelectorsVerified, orchestration, orchestrationMaxRetries, outputFormat }) => {
|
|
870
|
+
}, async ({ platform, language, appId, deviceCategory, testName, packageName, mainActivity, bundleIdentifier, projectType, region, includePerformanceTransactions, includeAxeScan, reportStatus, appiumVersion, newSessionWaitTimeout, reportKeys, automotiveProjection, confirmSelectorsVerified, orchestration, orchestrationMaxRetries, outputFormat }) => {
|
|
715
871
|
// ── Inspection gate (v42) ────────────────────────────────────────────────
|
|
716
872
|
// Advisory guards (warning text, a requiresVerifiedSelectors flag, an in-code
|
|
717
873
|
// fail() guard) all lost to task-completion momentum: the agent stripped the
|
|
@@ -766,7 +922,7 @@ export function registerBoilerplateTools(server) {
|
|
|
766
922
|
catch {
|
|
767
923
|
// leave as raw value if URL parsing fails
|
|
768
924
|
}
|
|
769
|
-
// Auto-detect server mode via my-account-info — works for all user roles
|
|
925
|
+
// Auto-detect server mode via my-account-info (project.isAppiumOss) — works for all user roles.
|
|
770
926
|
// undefined = lookup failed. Templates fall back to Grid (the conservative choice), but the orchestration
|
|
771
927
|
// decision must not then claim the project IS Grid — it reports that the mode could not be determined.
|
|
772
928
|
let detectedAppiumOss;
|
|
@@ -788,6 +944,42 @@ export function registerBoilerplateTools(server) {
|
|
|
788
944
|
? { resolution: automotiveProjection, applied: true, note: `digitalai:automotiveProjection=${automotiveProjection} set; the test captures the ${platform === 'ios' ? 'CarPlay' : 'Android Auto'} head unit after its steps. Use automotive_control in an inspection session to explore the head unit and pick tap coordinates.` }
|
|
789
945
|
: { resolution: automotiveProjection, applied: false, note: detectedAppiumOss === undefined ? 'the project mode could not be determined, and projection is only supported here for Appium Server projects.' : 'this project runs on Appium Grid, which does not support projection commands (verified: the Grid execute layer runs digitalai:automotive.* as JavaScript and every command fails).' };
|
|
790
946
|
}
|
|
947
|
+
// Extra capabilities. appiumVersion is honoured by Appium Server only (verified live: an unavailable version fails
|
|
948
|
+
// the session with the platform's version list); report keys work on both modes and become report columns.
|
|
949
|
+
// Robot Framework: Appium Server only (AppiumLibrary 3 sends W3C capabilities, which the Grid rejects), and the
|
|
950
|
+
// performance / Axe / automotive injections have no Robot form yet.
|
|
951
|
+
if (language === 'robot') {
|
|
952
|
+
if (!isAppiumOss) {
|
|
953
|
+
return { content: [{ type: 'text', text: `Error: Robot Framework boilerplate supports Appium Server projects only — ${detectedAppiumOss === undefined ? 'this project\'s mode could not be determined' : 'this project runs on Appium Grid'}. AppiumLibrary 3 sends W3C capabilities, which the Grid rejects. Use python, java-junit5, java-testng or nodejs, or switch to an Appium Server project.` }], isError: true };
|
|
954
|
+
}
|
|
955
|
+
const unsupported = [includePerformanceTransactions && 'includePerformanceTransactions', includeAxeScan && 'includeAxeScan', automotiveProjection && 'automotiveProjection'].filter(Boolean);
|
|
956
|
+
if (unsupported.length) {
|
|
957
|
+
return { content: [{ type: 'text', text: `Error: ${unsupported.join(', ')} ${unsupported.length > 1 ? 'are' : 'is'} not available for Robot Framework yet — use python, java-junit5, java-testng or nodejs for that.` }], isError: true };
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
if (appiumVersion && includeAxeScan) {
|
|
961
|
+
return { content: [{ type: 'text', text: 'Error: appiumVersion cannot be combined with includeAxeScan — the Axe driver needs Appium 2.16.2, which includeAxeScan pins itself.' }], isError: true };
|
|
962
|
+
}
|
|
963
|
+
const reserved = Object.keys(reportKeys ?? {}).filter((k) => RESERVED_REPORT_KEYS.has(k.toLowerCase()));
|
|
964
|
+
if (reserved.length) {
|
|
965
|
+
return { content: [{ type: 'text', text: `Error: reportKeys ${reserved.join(', ')} ${reserved.length > 1 ? 'are' : 'is a'} reserved capability name${reserved.length > 1 ? 's' : ''} (it would override the generated digitalai:${reserved[0]}). Use a different key name, e.g. runId, build, suite.` }], isError: true };
|
|
966
|
+
}
|
|
967
|
+
const extraCaps = {};
|
|
968
|
+
const capNotes = [];
|
|
969
|
+
if (appiumVersion) {
|
|
970
|
+
if (isAppiumOss)
|
|
971
|
+
extraCaps['digitalai:appiumVersion'] = appiumVersion;
|
|
972
|
+
else
|
|
973
|
+
capNotes.push(`appiumVersion ignored: this project runs on Appium Grid, which does not choose an Appium Server version.`);
|
|
974
|
+
}
|
|
975
|
+
if (newSessionWaitTimeout !== undefined)
|
|
976
|
+
extraCaps['digitalai:newSessionWaitTimeout'] = newSessionWaitTimeout;
|
|
977
|
+
for (const [k, v] of Object.entries(reportKeys ?? {}))
|
|
978
|
+
extraCaps[`digitalai:${k}`] = v;
|
|
979
|
+
if (reportKeys && Object.keys(reportKeys).length > 0) {
|
|
980
|
+
const [k, v] = Object.entries(reportKeys)[0];
|
|
981
|
+
capNotes.push(`Report keys set (${Object.keys(reportKeys).join(', ')}). Find these runs with list_test_reports filter [{"property":"${k}","operator":"=","value":"${v}"}], keys ["${k}"].`);
|
|
982
|
+
}
|
|
791
983
|
// Resolve app capabilities from appId if provided.
|
|
792
984
|
let resolvedPackageName = packageName;
|
|
793
985
|
let resolvedMainActivity = mainActivity;
|
|
@@ -836,6 +1028,8 @@ export function registerBoilerplateTools(server) {
|
|
|
836
1028
|
axeApiKey: process.env.AXE_DEVTOOLS_API_KEY,
|
|
837
1029
|
isAppiumOss,
|
|
838
1030
|
automotiveProjection: automotive?.applied ? automotive.resolution : undefined,
|
|
1031
|
+
reportStatus: reportStatus !== false,
|
|
1032
|
+
extraCaps,
|
|
839
1033
|
};
|
|
840
1034
|
const files = getFilesForVariant(platform, language, isAppiumOss, projectType);
|
|
841
1035
|
// Grid scripts carry non-obvious workarounds (pinned clients, JWP capability
|
|
@@ -952,6 +1146,7 @@ export function registerBoilerplateTools(server) {
|
|
|
952
1146
|
files: resolved.map(f => ({ filename: f.filename, content: f.content })),
|
|
953
1147
|
orchestration: orchestrationInfo,
|
|
954
1148
|
...(automotive ? { automotive } : {}),
|
|
1149
|
+
...(capNotes.length ? { capabilityNotes: capNotes } : {}),
|
|
955
1150
|
setupNote: setupNote(language, isAppiumOss, projectType),
|
|
956
1151
|
appNote: appNote(platform, vars.packageName, vars.bundleIdentifier, vars.mainActivity, resolvedFromAppId),
|
|
957
1152
|
parallelNote: language === 'python'
|
|
@@ -974,6 +1169,7 @@ export function registerBoilerplateTools(server) {
|
|
|
974
1169
|
'java-testng': 'Java TestNG',
|
|
975
1170
|
'nodejs': 'NodeJS (WebDriverIO)',
|
|
976
1171
|
'python': 'Python (Appium)',
|
|
1172
|
+
'robot': 'Robot Framework (AppiumLibrary)',
|
|
977
1173
|
};
|
|
978
1174
|
const serverModeLabel = isAppiumOss ? 'Appium Server (OSS)' : 'Appium Grid';
|
|
979
1175
|
const regionLabel = region ? `Region: ${region}` : 'Region: unscoped (all regions)';
|
|
@@ -1001,6 +1197,8 @@ export function registerBoilerplateTools(server) {
|
|
|
1001
1197
|
? `> 🚗 **Automotive projection: ON** — ${automotive.note}`
|
|
1002
1198
|
: `> ⚠️ **Automotive projection requested but not applied:** ${automotive.note} Generated the classic boilerplate instead.`, '');
|
|
1003
1199
|
}
|
|
1200
|
+
for (const note of capNotes)
|
|
1201
|
+
lines.push(`> **Capabilities:** ${note}`, '');
|
|
1004
1202
|
if (clearTestBody) {
|
|
1005
1203
|
lines.push('> ⛔ **NOT A FINISHED TEST.** The test body is a placeholder with a deliberate fail-guard and ' +
|
|
1006
1204
|
'non-real `<…>` example selectors. Replace it with steps using element IDs from a live inspection ' +
|
|
@@ -1174,8 +1372,8 @@ export function registerBoilerplateTools(server) {
|
|
|
1174
1372
|
'When shadowDomSupport is enabled, a shadowQuery() helper is included for interacting with elements ' +
|
|
1175
1373
|
'inside Shadow DOM trees (React, Angular, Web Components).', {
|
|
1176
1374
|
language: z
|
|
1177
|
-
.enum(['java-junit5', 'java-testng', 'nodejs', 'python'])
|
|
1178
|
-
.describe('Target language and test framework.'),
|
|
1375
|
+
.enum(['java-junit5', 'java-testng', 'nodejs', 'python', 'robot'])
|
|
1376
|
+
.describe('Target language and test framework. "robot" = Robot Framework + SeleniumLibrary (no shadowQuery helper; Opera unsupported).'),
|
|
1179
1377
|
testName: z
|
|
1180
1378
|
.string()
|
|
1181
1379
|
.optional()
|
|
@@ -1244,7 +1442,7 @@ export function registerBoilerplateTools(server) {
|
|
|
1244
1442
|
const baseUrl = getActiveUrl() || '[Enter Instance here]';
|
|
1245
1443
|
const gridUrl = `${baseUrl}/wd/hub`;
|
|
1246
1444
|
// Decide whether to include shadow DOM helper.
|
|
1247
|
-
// For 'auto',
|
|
1445
|
+
// For 'auto', approximate: include it when any live browser session is open.
|
|
1248
1446
|
let includeShadowHelper = false;
|
|
1249
1447
|
if (shadowDomSupport === 'always') {
|
|
1250
1448
|
includeShadowHelper = true;
|
|
@@ -1252,7 +1450,7 @@ export function registerBoilerplateTools(server) {
|
|
|
1252
1450
|
else if (shadowDomSupport === 'auto') {
|
|
1253
1451
|
const browserSession = listActiveSessions().find((s) => s.platform === 'web');
|
|
1254
1452
|
// We can't detect shadow DOM without the session's DOM result, so 'auto' includes
|
|
1255
|
-
// the helper if
|
|
1453
|
+
// the helper if a browser session is open in this process (they likely encountered SPAs).
|
|
1256
1454
|
includeShadowHelper = !!browserSession;
|
|
1257
1455
|
}
|
|
1258
1456
|
// ── Inline templates ────────────────────────────────────────────────────
|
|
@@ -1265,12 +1463,14 @@ export function registerBoilerplateTools(server) {
|
|
|
1265
1463
|
return `${indent}org.testng.Assert.fail("${msg}");`;
|
|
1266
1464
|
case 'python':
|
|
1267
1465
|
return `${indent}raise NotImplementedError("${msg}")`;
|
|
1466
|
+
case 'robot':
|
|
1467
|
+
return `${indent}Fail ${msg}`;
|
|
1268
1468
|
default:
|
|
1269
1469
|
return `${indent}throw new Error('${msg}');`;
|
|
1270
1470
|
}
|
|
1271
1471
|
}
|
|
1272
1472
|
function webPlaceholderBody(lang, indent, url) {
|
|
1273
|
-
const c = lang === 'python' ? '#' : '//';
|
|
1473
|
+
const c = lang === 'python' || lang === 'robot' ? '#' : '//';
|
|
1274
1474
|
const banner = [
|
|
1275
1475
|
`${indent}${c} ============================================================================`,
|
|
1276
1476
|
`${indent}${c} ⛔ PLACEHOLDER TEST BODY — NOT A RUNNABLE TEST. This is scaffolding only.`,
|
|
@@ -1282,7 +1482,16 @@ export function registerBoilerplateTools(server) {
|
|
|
1282
1482
|
].join('\n');
|
|
1283
1483
|
const nav = url ? `"${url}"` : '"[Enter target URL here]"';
|
|
1284
1484
|
let examples;
|
|
1285
|
-
if (lang === '
|
|
1485
|
+
if (lang === 'robot') {
|
|
1486
|
+
examples = [
|
|
1487
|
+
`${indent}${c} Example shape — replace <…> with selectors from get_page_dom / find_web_elements:`,
|
|
1488
|
+
`${indent}${c} Go To ${url || '[Enter target URL here]'}`,
|
|
1489
|
+
`${indent}${c} Click Element css=<CSS selector from find_web_elements>`,
|
|
1490
|
+
`${indent}${c} Input Text css=input[name='<name attr>'] <value>`,
|
|
1491
|
+
`${indent}${c} Page Should Contain <visible text>`,
|
|
1492
|
+
].join('\n');
|
|
1493
|
+
}
|
|
1494
|
+
else if (lang === 'java-junit5' || lang === 'java-testng') {
|
|
1286
1495
|
examples = [
|
|
1287
1496
|
`${indent}${c} Example shape — replace <…> with selectors from get_page_dom / find_web_elements:`,
|
|
1288
1497
|
`${indent}${c} driver.get(${nav});`,
|
|
@@ -1404,7 +1613,7 @@ export function registerBoilerplateTools(server) {
|
|
|
1404
1613
|
const browserCap = browserCapJava(targetBrowser);
|
|
1405
1614
|
const browserImp = browserImportsJava(targetBrowser);
|
|
1406
1615
|
const shadowHelper = includeShadowHelper ? '\n\n' + shadowHelperJava() : '';
|
|
1407
|
-
const placeholder = webPlaceholderBody(language, ' ', targetUrl);
|
|
1616
|
+
const placeholder = wrapWithReporting(language, ' ', webPlaceholderBody(language, ' ', targetUrl), true);
|
|
1408
1617
|
code = [
|
|
1409
1618
|
`package com.example.tests;`,
|
|
1410
1619
|
``,
|
|
@@ -1430,7 +1639,7 @@ export function registerBoilerplateTools(server) {
|
|
|
1430
1639
|
` ${isJunit5 ? '' : 'public static '}void setUp() throws MalformedURLException {`,
|
|
1431
1640
|
`${browserCap}`,
|
|
1432
1641
|
` caps.setCapability("digitalai:accessKey", ACCESS_KEY);`,
|
|
1433
|
-
` caps.setCapability("digitalai:
|
|
1642
|
+
` caps.setCapability("digitalai:testName", "${testName}");`,
|
|
1434
1643
|
``,
|
|
1435
1644
|
` driver = new RemoteWebDriver(new URL(GRID_URL), caps);`,
|
|
1436
1645
|
` driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));`,
|
|
@@ -1448,7 +1657,7 @@ export function registerBoilerplateTools(server) {
|
|
|
1448
1657
|
` }`,
|
|
1449
1658
|
`}`,
|
|
1450
1659
|
].join('\n');
|
|
1451
|
-
// Build script (Maven
|
|
1660
|
+
// Build script (Maven pom.xml only — no Gradle file is emitted for web tests)
|
|
1452
1661
|
const pom = [
|
|
1453
1662
|
`<project>`,
|
|
1454
1663
|
` <modelVersion>4.0.0</modelVersion>`,
|
|
@@ -1513,21 +1722,23 @@ export function registerBoilerplateTools(server) {
|
|
|
1513
1722
|
}
|
|
1514
1723
|
if (language === 'python') {
|
|
1515
1724
|
filename = `test_${testName.toLowerCase()}.py`;
|
|
1725
|
+
// Joined with the 8-space body indent — the elements themselves carry none (they used to, which double-indented
|
|
1726
|
+
// the browser-neutral variant into an IndentationError; found running it live 2026-10-16).
|
|
1516
1727
|
const browserCap = targetBrowser
|
|
1517
1728
|
? `caps["browserName"] = "${targetBrowser}"`
|
|
1518
1729
|
: [
|
|
1519
1730
|
`# BROWSER-NEUTRAL: reads browser name from BROWSER env var at runtime.`,
|
|
1520
|
-
`
|
|
1521
|
-
`
|
|
1731
|
+
`browser_name = os.environ.get("BROWSER", "chrome")`,
|
|
1732
|
+
`caps["browserName"] = browser_name`,
|
|
1522
1733
|
].join('\n ');
|
|
1523
1734
|
const shadowHelper = includeShadowHelper ? '\n\n' + shadowHelperPython() : '';
|
|
1524
|
-
const placeholder = webPlaceholderBody(language, ' ', targetUrl);
|
|
1735
|
+
const placeholder = wrapWithReporting(language, ' ', webPlaceholderBody(language, ' ', targetUrl), true);
|
|
1525
1736
|
code = [
|
|
1526
1737
|
`import os`,
|
|
1527
1738
|
`import unittest`,
|
|
1528
1739
|
`from selenium import webdriver`,
|
|
1529
1740
|
`from selenium.webdriver.common.by import By`,
|
|
1530
|
-
`from selenium.webdriver.
|
|
1741
|
+
`from selenium.webdriver.common.options import ArgOptions`,
|
|
1531
1742
|
``,
|
|
1532
1743
|
``,
|
|
1533
1744
|
`class ${testClass}(unittest.TestCase):`,
|
|
@@ -1539,12 +1750,13 @@ export function registerBoilerplateTools(server) {
|
|
|
1539
1750
|
` caps = {}`,
|
|
1540
1751
|
` ${browserCap}`,
|
|
1541
1752
|
` caps["digitalai:accessKey"] = self.ACCESS_KEY`,
|
|
1542
|
-
` caps["digitalai:
|
|
1753
|
+
` caps["digitalai:testName"] = "${testName}"`,
|
|
1543
1754
|
``,
|
|
1544
|
-
`
|
|
1545
|
-
`
|
|
1546
|
-
`
|
|
1547
|
-
`
|
|
1755
|
+
` # Selenium 4.10+ removed desired_capabilities — capabilities go through an Options object.`,
|
|
1756
|
+
` options = ArgOptions()`,
|
|
1757
|
+
` for name, value in caps.items():`,
|
|
1758
|
+
` options.set_capability(name, value)`,
|
|
1759
|
+
` self.driver = webdriver.Remote(command_executor=self.GRID_URL, options=options)`,
|
|
1548
1760
|
` self.driver.implicitly_wait(10)`,
|
|
1549
1761
|
` self.driver.maximize_window()`,
|
|
1550
1762
|
``,
|
|
@@ -1591,10 +1803,84 @@ export function registerBoilerplateTools(server) {
|
|
|
1591
1803
|
].join('\n');
|
|
1592
1804
|
return respond(args.outputFormat, structured, humanText);
|
|
1593
1805
|
}
|
|
1806
|
+
if (language === 'robot') {
|
|
1807
|
+
// SeleniumLibrary names browsers differently from the grid: it builds EdgeOptions for "edge" (browserName
|
|
1808
|
+
// "MicrosoftEdge" on the wire). Opera has no SeleniumLibrary driver.
|
|
1809
|
+
const slBrowser = targetBrowser === 'MicrosoftEdge' ? 'edge' : targetBrowser;
|
|
1810
|
+
if (slBrowser === 'opera') {
|
|
1811
|
+
return { content: [{ type: 'text', text: 'Error: SeleniumLibrary cannot drive Opera — choose chrome, firefox, MicrosoftEdge or safari for Robot Framework.' }], isError: true };
|
|
1812
|
+
}
|
|
1813
|
+
const suiteFile = `tests/${testName.replace(/[^\w-]/g, '_')}.robot`;
|
|
1814
|
+
const body = webPlaceholderBody(language, ' ', targetUrl);
|
|
1815
|
+
const suite = [
|
|
1816
|
+
`*** Settings ***`,
|
|
1817
|
+
`Documentation ${testName} — web test on the Digital.ai Selenium Grid, generated by the Digital.ai Testing MCP.`,
|
|
1818
|
+
`... Run: pip install -r requirements.txt then robot ${suiteFile}`,
|
|
1819
|
+
`Library SeleniumLibrary timeout=10`,
|
|
1820
|
+
`Library DigitalAiWebReport.py`,
|
|
1821
|
+
`Test Setup Open Cloud Browser`,
|
|
1822
|
+
`Test Teardown Close Cloud Browser`,
|
|
1823
|
+
``,
|
|
1824
|
+
`*** Variables ***`,
|
|
1825
|
+
`\${GRID_URL} ${gridUrl}`,
|
|
1826
|
+
`# The DIGITAL_AI_ACCESS_KEY environment variable wins; the value after "=" is the fallback. Remove it before committing.`,
|
|
1827
|
+
`\${ACCESS_KEY} %{DIGITAL_AI_ACCESS_KEY=${accessKey}}`,
|
|
1828
|
+
slBrowser
|
|
1829
|
+
? `\${BROWSER} ${slBrowser}`
|
|
1830
|
+
: `# BROWSER-NEUTRAL: set BROWSER=chrome / firefox / edge / safari (SeleniumLibrary names) at run time.\n\${BROWSER} %{BROWSER=chrome}`,
|
|
1831
|
+
`\${TEST_NAME} ${testName}`,
|
|
1832
|
+
``,
|
|
1833
|
+
`*** Test Cases ***`,
|
|
1834
|
+
`${testName}`,
|
|
1835
|
+
` Start Steps Group Test steps`,
|
|
1836
|
+
body,
|
|
1837
|
+
` Stop Steps Group`,
|
|
1838
|
+
``,
|
|
1839
|
+
`*** Keywords ***`,
|
|
1840
|
+
`Open Cloud Browser`,
|
|
1841
|
+
` Open Browser about:blank \${BROWSER} remote_url=\${GRID_URL}`,
|
|
1842
|
+
` ... options=set_capability("digitalai:accessKey", "\${ACCESS_KEY}");set_capability("digitalai:testName", "\${TEST_NAME}")`,
|
|
1843
|
+
``,
|
|
1844
|
+
`Close Cloud Browser`,
|
|
1845
|
+
` # Report the real outcome: without this a failed step or assertion can still show as Passed in the platform report.`,
|
|
1846
|
+
` Run Keyword And Ignore Error Report Test Outcome \${TEST STATUS} \${TEST MESSAGE}`,
|
|
1847
|
+
` Close Browser`,
|
|
1848
|
+
].join('\n');
|
|
1849
|
+
const library = readFileSync(join(BOILERPLATE_DIR, 'Web', 'Robot Framework', 'DigitalAiWebReport.py'), 'utf-8').replace(/\r\n/g, '\n');
|
|
1850
|
+
const requirements = 'robotframework==7.5\nrobotframework-seleniumlibrary==6.9.0';
|
|
1851
|
+
const structured = {
|
|
1852
|
+
language,
|
|
1853
|
+
testName,
|
|
1854
|
+
targetBrowser: targetBrowser ?? 'browser-neutral (env var BROWSER)',
|
|
1855
|
+
shadowDomSupportIncluded: false,
|
|
1856
|
+
files: [
|
|
1857
|
+
{ filename: suiteFile, language: 'robotframework', content: suite },
|
|
1858
|
+
{ filename: 'tests/DigitalAiWebReport.py', language: 'python', content: library },
|
|
1859
|
+
{ filename: 'requirements.txt', language: 'text', content: requirements },
|
|
1860
|
+
],
|
|
1861
|
+
guidance: [
|
|
1862
|
+
'Replace the placeholder test body with selectors from get_page_dom / find_web_elements.',
|
|
1863
|
+
'pip install -r requirements.txt, then robot --outputdir results tests/',
|
|
1864
|
+
'The Test Teardown sets the platform report to Passed / Failed / Skipped from Robot\'s own result.',
|
|
1865
|
+
`Grid URL: ${gridUrl}`,
|
|
1866
|
+
],
|
|
1867
|
+
};
|
|
1868
|
+
const humanText = [
|
|
1869
|
+
`Generated: ${suiteFile}, tests/DigitalAiWebReport.py, requirements.txt`,
|
|
1870
|
+
`Browser: ${targetBrowser ?? 'neutral (BROWSER env var)'}`,
|
|
1871
|
+
'',
|
|
1872
|
+
'```robotframework', suite, '```',
|
|
1873
|
+
'',
|
|
1874
|
+
'```python', library, '```',
|
|
1875
|
+
'',
|
|
1876
|
+
'```text', requirements, '```',
|
|
1877
|
+
].join('\n');
|
|
1878
|
+
return respond(args.outputFormat, structured, humanText);
|
|
1879
|
+
}
|
|
1594
1880
|
// Node.js / WebdriverIO
|
|
1595
1881
|
filename = `test.${testName.toLowerCase()}.js`;
|
|
1596
1882
|
const shadowHelper = includeShadowHelper ? '\n\n' + shadowHelperNodejs() : '';
|
|
1597
|
-
const placeholder = webPlaceholderBody(language, ' ', targetUrl);
|
|
1883
|
+
const placeholder = wrapWithReporting(language, ' ', webPlaceholderBody(language, ' ', targetUrl), true);
|
|
1598
1884
|
const browserCapNode = targetBrowser
|
|
1599
1885
|
? `browserName: '${targetBrowser}'`
|
|
1600
1886
|
: [
|
|
@@ -1611,7 +1897,7 @@ export function registerBoilerplateTools(server) {
|
|
|
1611
1897
|
` capabilities: [{`,
|
|
1612
1898
|
` ${browserCapNode},`,
|
|
1613
1899
|
` 'digitalai:accessKey': '${accessKey}',`,
|
|
1614
|
-
` 'digitalai:
|
|
1900
|
+
` 'digitalai:testName': '${testName}',`,
|
|
1615
1901
|
` }],`,
|
|
1616
1902
|
` framework: 'mocha',`,
|
|
1617
1903
|
` reporters: ['spec'],`,
|