@browserstack/mcp-server 1.1.9 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +4 -1
  2. package/dist/config.d.ts +13 -0
  3. package/dist/config.js +4 -6
  4. package/dist/index.d.ts +4 -0
  5. package/dist/index.js +21 -31
  6. package/dist/lib/api.d.ts +2 -0
  7. package/dist/lib/api.js +10 -5
  8. package/dist/lib/apiClient.d.ts +31 -0
  9. package/dist/lib/apiClient.js +108 -0
  10. package/dist/lib/constants.d.ts +17 -0
  11. package/dist/lib/device-cache.d.ts +9 -0
  12. package/dist/lib/device-cache.js +3 -3
  13. package/dist/lib/error.d.ts +7 -0
  14. package/dist/lib/fuzzy.d.ts +1 -0
  15. package/dist/lib/get-auth.d.ts +2 -0
  16. package/dist/lib/get-auth.js +8 -0
  17. package/dist/lib/inmemory-store.d.ts +1 -0
  18. package/dist/lib/instrumentation.d.ts +4 -0
  19. package/dist/lib/instrumentation.js +8 -7
  20. package/dist/lib/local.d.ts +3 -0
  21. package/dist/lib/local.js +3 -3
  22. package/dist/lib/types.d.ts +4 -0
  23. package/dist/lib/types.js +1 -0
  24. package/dist/lib/utils.d.ts +4 -0
  25. package/dist/lib/version-resolver.d.ts +6 -0
  26. package/dist/logger.d.ts +3 -0
  27. package/dist/logger.js +20 -4
  28. package/dist/oninitialized.d.ts +2 -0
  29. package/dist/oninitialized.js +2 -7
  30. package/dist/server-factory.d.ts +25 -0
  31. package/dist/server-factory.js +70 -0
  32. package/dist/tools/accessibility.d.ts +3 -0
  33. package/dist/tools/accessibility.js +21 -12
  34. package/dist/tools/accessiblity-utils/accessibility-rag.d.ts +12 -0
  35. package/dist/tools/accessiblity-utils/accessibility-rag.js +22 -12
  36. package/dist/tools/accessiblity-utils/report-fetcher.d.ts +8 -0
  37. package/dist/tools/accessiblity-utils/report-fetcher.js +26 -16
  38. package/dist/tools/accessiblity-utils/report-parser.d.ts +23 -0
  39. package/dist/tools/accessiblity-utils/report-parser.js +3 -3
  40. package/dist/tools/accessiblity-utils/scanner.d.ts +25 -0
  41. package/dist/tools/accessiblity-utils/scanner.js +43 -24
  42. package/dist/tools/appautomate-utils/appautomate.d.ts +42 -0
  43. package/dist/tools/appautomate-utils/appautomate.js +63 -38
  44. package/dist/tools/appautomate-utils/types.d.ts +5 -0
  45. package/dist/tools/appautomate.d.ts +3 -0
  46. package/dist/tools/appautomate.js +24 -21
  47. package/dist/tools/applive-utils/device-search.d.ts +6 -0
  48. package/dist/tools/applive-utils/start-session.d.ts +15 -0
  49. package/dist/tools/applive-utils/start-session.js +11 -4
  50. package/dist/tools/applive-utils/types.d.ts +7 -0
  51. package/dist/tools/applive-utils/upload-app.d.ts +5 -0
  52. package/dist/tools/applive-utils/upload-app.js +8 -12
  53. package/dist/tools/applive-utils/version-utils.d.ts +4 -0
  54. package/dist/tools/applive.d.ts +13 -0
  55. package/dist/tools/applive.js +9 -7
  56. package/dist/tools/automate-utils/fetch-screenshots.d.ts +6 -0
  57. package/dist/tools/automate-utils/fetch-screenshots.js +16 -12
  58. package/dist/tools/automate.d.ts +9 -0
  59. package/dist/tools/automate.js +9 -7
  60. package/dist/tools/bstack-sdk.d.ts +17 -0
  61. package/dist/tools/bstack-sdk.js +15 -8
  62. package/dist/tools/failurelogs-utils/app-automate.d.ts +7 -0
  63. package/dist/tools/failurelogs-utils/app-automate.js +29 -11
  64. package/dist/tools/failurelogs-utils/automate.d.ts +6 -0
  65. package/dist/tools/failurelogs-utils/automate.js +27 -12
  66. package/dist/tools/failurelogs-utils/utils.d.ts +30 -0
  67. package/dist/tools/getFailureLogs.d.ts +14 -0
  68. package/dist/tools/getFailureLogs.js +15 -16
  69. package/dist/tools/live-utils/desktop-filter.d.ts +2 -0
  70. package/dist/tools/live-utils/mobile-filter.d.ts +2 -0
  71. package/dist/tools/live-utils/start-session.d.ts +6 -0
  72. package/dist/tools/live-utils/start-session.js +18 -5
  73. package/dist/tools/live-utils/types.d.ts +33 -0
  74. package/dist/tools/live.d.ts +3 -0
  75. package/dist/tools/live.js +28 -16
  76. package/dist/tools/observability.d.ts +5 -0
  77. package/dist/tools/observability.js +14 -11
  78. package/dist/tools/sdk-utils/commands.d.ts +3 -0
  79. package/dist/tools/sdk-utils/commands.js +5 -4
  80. package/dist/tools/sdk-utils/constants.d.ts +2 -0
  81. package/dist/tools/sdk-utils/constants.js +82 -21
  82. package/dist/tools/sdk-utils/instructions.d.ts +6 -0
  83. package/dist/tools/sdk-utils/instructions.js +8 -6
  84. package/dist/tools/sdk-utils/percy/constants.d.ts +3 -0
  85. package/dist/tools/sdk-utils/percy/constants.js +1 -0
  86. package/dist/tools/sdk-utils/percy/instructions.d.ts +10 -0
  87. package/dist/tools/sdk-utils/percy/types.d.ts +5 -0
  88. package/dist/tools/sdk-utils/types.d.ts +39 -0
  89. package/dist/tools/sdk-utils/types.js +1 -0
  90. package/dist/tools/selfheal-utils/selfheal.d.ts +11 -0
  91. package/dist/tools/selfheal-utils/selfheal.js +10 -6
  92. package/dist/tools/selfheal.d.ts +7 -0
  93. package/dist/tools/selfheal.js +9 -7
  94. package/dist/tools/testmanagement-utils/TCG-utils/api.d.ts +34 -0
  95. package/dist/tools/testmanagement-utils/TCG-utils/api.js +57 -44
  96. package/dist/tools/testmanagement-utils/TCG-utils/config.d.ts +5 -0
  97. package/dist/tools/testmanagement-utils/TCG-utils/helpers.d.ts +13 -0
  98. package/dist/tools/testmanagement-utils/TCG-utils/helpers.js +2 -1
  99. package/dist/tools/testmanagement-utils/TCG-utils/types.d.ts +26 -0
  100. package/dist/tools/testmanagement-utils/add-test-result.d.ts +42 -0
  101. package/dist/tools/testmanagement-utils/add-test-result.js +23 -10
  102. package/dist/tools/testmanagement-utils/create-lca-steps.d.ts +100 -0
  103. package/dist/tools/testmanagement-utils/create-lca-steps.js +64 -55
  104. package/dist/tools/testmanagement-utils/create-project-folder.d.ts +31 -0
  105. package/dist/tools/testmanagement-utils/create-project-folder.js +31 -21
  106. package/dist/tools/testmanagement-utils/create-testcase.d.ts +122 -0
  107. package/dist/tools/testmanagement-utils/create-testcase.js +13 -10
  108. package/dist/tools/testmanagement-utils/create-testrun.d.ts +82 -0
  109. package/dist/tools/testmanagement-utils/create-testrun.js +11 -8
  110. package/dist/tools/testmanagement-utils/list-testcases.d.ts +30 -0
  111. package/dist/tools/testmanagement-utils/list-testcases.js +9 -7
  112. package/dist/tools/testmanagement-utils/list-testruns.d.ts +22 -0
  113. package/dist/tools/testmanagement-utils/list-testruns.js +9 -7
  114. package/dist/tools/testmanagement-utils/poll-lca-status.d.ts +11 -0
  115. package/dist/tools/testmanagement-utils/poll-lca-status.js +12 -8
  116. package/dist/tools/testmanagement-utils/testcase-from-file.d.ts +4 -0
  117. package/dist/tools/testmanagement-utils/testcase-from-file.js +6 -6
  118. package/dist/tools/testmanagement-utils/update-testrun.d.ts +40 -0
  119. package/dist/tools/testmanagement-utils/update-testrun.js +11 -7
  120. package/dist/tools/testmanagement-utils/upload-file.d.ts +20 -0
  121. package/dist/tools/testmanagement-utils/upload-file.js +8 -6
  122. package/dist/tools/testmanagement.d.ts +60 -0
  123. package/dist/tools/testmanagement.js +53 -53
  124. package/package.json +1 -1
@@ -1,8 +1,7 @@
1
- import config from "../../config.js";
2
1
  /**
3
2
  * ---------- PYTHON INSTRUCTIONS ----------
4
3
  */
5
- const pythonInstructions = `
4
+ const pythonInstructions = (username, accessKey) => `
6
5
  ---STEP---
7
6
 
8
7
  Install the BrowserStack SDK:
@@ -14,7 +13,7 @@ python3 -m pip install browserstack-sdk
14
13
 
15
14
  Setup the BrowserStack SDK with your credentials:
16
15
  \`\`\`bash
17
- browserstack-sdk setup --username "${config.browserstackUsername}" --key "${config.browserstackAccessKey}"
16
+ browserstack-sdk setup --username "${username}" --key "${accessKey}"
18
17
  \`\`\`
19
18
 
20
19
  ---STEP---
@@ -24,10 +23,11 @@ Run your tests on BrowserStack:
24
23
  browserstack-sdk python <path-to-test-file>
25
24
  \`\`\`
26
25
  `;
27
- const generatePythonFrameworkInstructions = (framework) => `
26
+ const generatePythonFrameworkInstructions = (framework) => (username, accessKey) => `
28
27
  ---STEP---
29
28
 
30
29
  Install the BrowserStack SDK:
30
+
31
31
  \`\`\`bash
32
32
  python3 -m pip install browserstack-sdk
33
33
  \`\`\`
@@ -36,7 +36,7 @@ python3 -m pip install browserstack-sdk
36
36
 
37
37
  Setup the BrowserStack SDK with framework-specific configuration:
38
38
  \`\`\`bash
39
- browserstack-sdk setup --framework "${framework}" --username "${config.browserstackUsername}" --key "${config.browserstackAccessKey}"
39
+ browserstack-sdk setup --framework "${framework}" --username "${username}" --key "${accessKey}"
40
40
  \`\`\`
41
41
 
42
42
  ---STEP---
@@ -53,7 +53,7 @@ const pytestInstructions = generatePythonFrameworkInstructions("pytest");
53
53
  * ---------- JAVA INSTRUCTIONS ----------
54
54
  */
55
55
  const argsInstruction = '<argLine>-javaagent:"${com.browserstack:browserstack-java-sdk:jar}"</argLine>';
56
- const javaInstructions = `
56
+ const javaInstructions = (username, accessKey) => `
57
57
  ---STEP---
58
58
 
59
59
  Add the BrowserStack Java SDK dependency to your \`pom.xml\`:
@@ -79,8 +79,8 @@ dependencies {
79
79
 
80
80
  Export your BrowserStack credentials as environment variables:
81
81
  \`\`\`bash
82
- export BROWSERSTACK_USERNAME=${config.browserstackUsername}
83
- export BROWSERSTACK_ACCESS_KEY=${config.browserstackAccessKey}
82
+ export BROWSERSTACK_USERNAME=${username}
83
+ export BROWSERSTACK_ACCESS_KEY=${accessKey}
84
84
  \`\`\`
85
85
 
86
86
  ---STEP---
@@ -95,10 +95,66 @@ Or for Gradle:
95
95
  gradle clean test
96
96
  \`\`\`
97
97
  `;
98
+ const serenityInstructions = (username, accessKey) => `
99
+ ---STEP---
100
+
101
+ Set BrowserStack credentials as environment variables:
102
+ For macOS/Linux:
103
+ \`\`\`bash
104
+ export BROWSERSTACK_USERNAME=${username}
105
+ export BROWSERSTACK_ACCESS_KEY=${accessKey}
106
+ \`\`\`
107
+
108
+ For Windows Command Prompt:
109
+ \`\`\`cmd
110
+ set BROWSERSTACK_USERNAME=${username}
111
+ set BROWSERSTACK_ACCESS_KEY=${accessKey}
112
+ \`\`\`
113
+
114
+ ---STEP---
115
+
116
+ Add serenity-browserstack dependency in pom.xml:
117
+ Add the following dependency to your pom.xml file and save it:
118
+ \`\`\`xml
119
+ <dependency>
120
+ <groupId>net.serenity-bdd</groupId>
121
+ <artifactId>serenity-browserstack</artifactId>
122
+ <version>3.3.4</version>
123
+ </dependency>
124
+ \`\`\`
125
+
126
+ ---STEP---
127
+
128
+ Set up serenity.conf file:
129
+ Create or update your serenity.conf file in the project root with the following configuration:
130
+ \`\`\`
131
+ webdriver {
132
+ driver = remote
133
+ remote.url = "https://hub.browserstack.com/wd/hub"
134
+ }
135
+ browserstack.user="${username}"
136
+ browserstack.key="${accessKey}"
137
+ \`\`\`
138
+
139
+ ---STEP---
140
+
141
+ Run your Serenity tests:
142
+ You can continue running your tests as you normally would. For example:
143
+
144
+ Using Maven:
145
+ \`\`\`bash
146
+ mvn clean verify
147
+ \`\`\`
148
+
149
+ Using Gradle:
150
+ \`\`\`bash
151
+ gradle clean test
152
+ \`\`\`
153
+ `;
98
154
  /**
99
155
  * ---------- CSharp INSTRUCTIONS ----------
100
156
  */
101
- const csharpCommonInstructions = `
157
+ const csharpCommonInstructions = (username, accessKey) => `
102
158
  ---STEP---
103
159
 
104
160
  Install BrowserStack TestAdapter NuGet package:
@@ -117,7 +173,7 @@ dotnet build
117
173
 
118
174
  Set up BrowserStack SDK with your credentials:
119
175
  \`\`\`bash
120
- dotnet browserstack-sdk setup --userName ${config.browserstackUsername} --accessKey ${config.browserstackAccessKey}
176
+ dotnet browserstack-sdk setup --userName ${username} --accessKey ${accessKey}
121
177
  \`\`\`
122
178
 
123
179
  ---STEP---
@@ -160,7 +216,7 @@ Run the tests:
160
216
  dotnet test
161
217
  \`\`\`
162
218
  `;
163
- const csharpPlaywrightCommonInstructions = `
219
+ const csharpPlaywrightCommonInstructions = (username, accessKey) => `
164
220
  ---STEP---
165
221
 
166
222
  Install BrowserStack TestAdapter NuGet package:
@@ -179,7 +235,7 @@ dotnet build
179
235
 
180
236
  Set up BrowserStack SDK with your credentials:
181
237
  \`\`\`bash
182
- dotnet browserstack-sdk setup --userName ${config.browserstackUsername} --accessKey ${config.browserstackAccessKey}
238
+ dotnet browserstack-sdk setup --userName ${username} --accessKey ${accessKey}
183
239
  \`\`\`
184
240
 
185
241
  ---STEP---
@@ -238,7 +294,7 @@ Run the tests:
238
294
  /**
239
295
  * ---------- NODEJS INSTRUCTIONS ----------
240
296
  */
241
- const nodejsInstructions = `
297
+ const nodejsInstructions = (username, accessKey) => `
242
298
  ---STEP---
243
299
 
244
300
  Ensure \`browserstack-node-sdk\` is present in package.json with the latest version:
@@ -259,11 +315,15 @@ Add new scripts to package.json for running tests on BrowserStack:
259
315
 
260
316
  Export BrowserStack credentials as environment variables:
261
317
  Set the following environment variables before running tests.
318
+ \`\`\`bash
319
+ export BROWSERSTACK_USERNAME=${username}
320
+ export BROWSERSTACK_ACCESS_KEY=${accessKey}
321
+ \`\`\`
262
322
  `;
263
323
  /**
264
324
  * ---------- EXPORT CONFIG ----------
265
325
  */
266
- const webdriverioInstructions = `
326
+ const webdriverioInstructions = (username, accessKey) => `
267
327
  ---STEP---
268
328
 
269
329
  Set BrowserStack Credentials:
@@ -271,14 +331,14 @@ Export your BrowserStack username and access key as environment variables.
271
331
 
272
332
  For macOS/Linux:
273
333
  \`\`\`bash
274
- export BROWSERSTACK_USERNAME= ${config.browserstackUsername}
275
- export BROWSERSTACK_ACCESS_KEY= ${config.browserstackAccessKey}
334
+ export BROWSERSTACK_USERNAME=${username}
335
+ export BROWSERSTACK_ACCESS_KEY=${accessKey}
276
336
  \`\`\`
277
337
 
278
338
  For Windows PowerShell:
279
339
  \`\`\`powershell
280
- $env:BROWSERSTACK_USERNAME=${config.browserstackUsername}
281
- $env:BROWSERSTACK_ACCESS_KEY=${config.browserstackAccessKey}
340
+ $env:BROWSERSTACK_USERNAME=${username}
341
+ $env:BROWSERSTACK_ACCESS_KEY=${accessKey}
282
342
  \`\`\`
283
343
 
284
344
  ---STEP---
@@ -368,7 +428,7 @@ exports.config.capabilities.forEach(function (caps) {
368
428
  Run your tests:
369
429
  You can now run your tests on BrowserStack using your standard WebdriverIO command.
370
430
  `;
371
- const cypressInstructions = `
431
+ const cypressInstructions = (username, accessKey) => `
372
432
  ---STEP---
373
433
 
374
434
  Install the BrowserStack Cypress CLI:
@@ -397,8 +457,8 @@ Open the generated \`browserstack.json\` file and update it with your BrowserSta
397
457
  \`\`\`json
398
458
  {
399
459
  "auth": {
400
- "username": "${config.browserstackUsername}",
401
- "access_key": "${config.browserstackAccessKey}"
460
+ "username": "${username}",
461
+ "access_key": "${accessKey}"
402
462
  },
403
463
  "browsers": [
404
464
  {
@@ -462,6 +522,7 @@ export const SUPPORTED_CONFIGURATIONS = {
462
522
  cucumber: { instructions: javaInstructions },
463
523
  junit4: { instructions: javaInstructions },
464
524
  junit5: { instructions: javaInstructions },
525
+ serenity: { instructions: serenityInstructions },
465
526
  },
466
527
  },
467
528
  csharp: {
@@ -0,0 +1,6 @@
1
+ import { SDKSupportedLanguage } from "./types.js";
2
+ import { SDKSupportedBrowserAutomationFramework } from "./types.js";
3
+ import { SDKSupportedTestingFramework } from "./types.js";
4
+ export declare const getInstructionsForProjectConfiguration: (detectedBrowserAutomationFramework: SDKSupportedBrowserAutomationFramework, detectedTestingFramework: SDKSupportedTestingFramework, detectedLanguage: SDKSupportedLanguage, username: string, accessKey: string) => string;
5
+ export declare function generateBrowserStackYMLInstructions(desiredPlatforms: string[], enablePercy?: boolean): string;
6
+ export declare function formatInstructionsWithNumbers(instructionText: string, separator?: string): string;
@@ -1,6 +1,6 @@
1
1
  import { SUPPORTED_CONFIGURATIONS } from "./constants.js";
2
2
  const errorMessageSuffix = "Please open an issue at our Github repo: https://github.com/browserstack/browserstack-mcp-server/issues to request support for your project configuration";
3
- export const getInstructionsForProjectConfiguration = (detectedBrowserAutomationFramework, detectedTestingFramework, detectedLanguage) => {
3
+ export const getInstructionsForProjectConfiguration = (detectedBrowserAutomationFramework, detectedTestingFramework, detectedLanguage, username, accessKey) => {
4
4
  const configuration = SUPPORTED_CONFIGURATIONS[detectedLanguage];
5
5
  if (!configuration) {
6
6
  throw new Error(`BrowserStack MCP Server currently does not support ${detectedLanguage}, ${errorMessageSuffix}`);
@@ -11,17 +11,19 @@ export const getInstructionsForProjectConfiguration = (detectedBrowserAutomation
11
11
  if (!configuration[detectedBrowserAutomationFramework][detectedTestingFramework]) {
12
12
  throw new Error(`BrowserStack MCP Server currently does not support ${detectedTestingFramework} for ${detectedBrowserAutomationFramework} on ${detectedLanguage}, ${errorMessageSuffix}`);
13
13
  }
14
- return configuration[detectedBrowserAutomationFramework][detectedTestingFramework].instructions;
14
+ const instructionFunction = configuration[detectedBrowserAutomationFramework][detectedTestingFramework]
15
+ .instructions;
16
+ return instructionFunction(username, accessKey);
15
17
  };
16
18
  export function generateBrowserStackYMLInstructions(desiredPlatforms, enablePercy = false) {
17
19
  let ymlContent = `
18
20
  # ======================
19
21
  # BrowserStack Reporting
20
22
  # ======================
21
- # A single name for your project to organize all your tests. This is required for Percy.
22
- projectName: BrowserStack SDK Tests
23
- # A name for the group of tests you are running
24
- buildName: mcp-run
23
+ # Project and build names help organize your test runs in BrowserStack dashboard and Percy.
24
+ # TODO: Replace these sample values with your actual project details
25
+ projectName: Sample Project
26
+ buildName: Sample Build
25
27
 
26
28
  # =======================================
27
29
  # Platforms (Browsers / Devices to test)
@@ -0,0 +1,3 @@
1
+ import { PercyConfigMapping } from "./types.js";
2
+ export declare const nodejsSeleniumInstructions = "\nImport the BrowserStack Percy SDK in your test script:\nAdd the Percy import to your test file.\n\n---STEP---\n\nAdd screenshot capture method at required points:\nUse the `percy.snapshot(driver, name)` method at points in your test script where you want to capture screenshots.\n\n```javascript\nconst { percy } = require('browserstack-node-sdk');\ndescribe(\"sample Test\", () => {\n // ... other imports and setup\n \n test(\"my test\", async () => {\n // ....\n await percy.snapshot(driver, \"My Snapshot\")\n // ....\n });\n})\n```\n";
3
+ export declare const PERCY_INSTRUCTIONS: PercyConfigMapping;
@@ -153,6 +153,7 @@ export const PERCY_INSTRUCTIONS = {
153
153
  cucumber: { script_updates: javaSeleniumInstructions },
154
154
  junit4: { script_updates: javaSeleniumInstructions },
155
155
  junit5: { script_updates: javaSeleniumInstructions },
156
+ serenity: { script_updates: javaSeleniumInstructions },
156
157
  },
157
158
  },
158
159
  csharp: {
@@ -0,0 +1,10 @@
1
+ import { SDKSupportedBrowserAutomationFramework, SDKSupportedLanguage, SDKSupportedTestingFramework } from "../types.js";
2
+ import { PercyInstructions } from "./types.js";
3
+ /**
4
+ * Retrieves Percy-specific instructions for a given language and framework.
5
+ */
6
+ export declare function getPercyInstructions(language: SDKSupportedLanguage, automationFramework: SDKSupportedBrowserAutomationFramework, testingFramework: SDKSupportedTestingFramework): PercyInstructions | null;
7
+ /**
8
+ * Formats the retrieved Percy instructions into a user-friendly string.
9
+ */
10
+ export declare function formatPercyInstructions(instructions: PercyInstructions): string;
@@ -0,0 +1,5 @@
1
+ import { SDKSupportedBrowserAutomationFramework, SDKSupportedLanguage, SDKSupportedTestingFramework } from "../types.js";
2
+ export interface PercyInstructions {
3
+ script_updates: string;
4
+ }
5
+ export type PercyConfigMapping = Partial<Record<SDKSupportedLanguage, Partial<Record<SDKSupportedBrowserAutomationFramework, Partial<Record<SDKSupportedTestingFramework, PercyInstructions>>>>>>;
@@ -0,0 +1,39 @@
1
+ export declare enum SDKSupportedLanguageEnum {
2
+ nodejs = "nodejs",
3
+ python = "python",
4
+ java = "java",
5
+ csharp = "csharp"
6
+ }
7
+ export type SDKSupportedLanguage = keyof typeof SDKSupportedLanguageEnum;
8
+ export declare enum SDKSupportedBrowserAutomationFrameworkEnum {
9
+ playwright = "playwright",
10
+ selenium = "selenium",
11
+ cypress = "cypress"
12
+ }
13
+ export type SDKSupportedBrowserAutomationFramework = keyof typeof SDKSupportedBrowserAutomationFrameworkEnum;
14
+ export declare enum SDKSupportedTestingFrameworkEnum {
15
+ jest = "jest",
16
+ codeceptjs = "codeceptjs",
17
+ playwright = "playwright",
18
+ pytest = "pytest",
19
+ robot = "robot",
20
+ behave = "behave",
21
+ cucumber = "cucumber",
22
+ nightwatch = "nightwatch",
23
+ webdriverio = "webdriverio",
24
+ mocha = "mocha",
25
+ junit4 = "junit4",
26
+ junit5 = "junit5",
27
+ testng = "testng",
28
+ serenity = "serenity",
29
+ cypress = "cypress",
30
+ nunit = "nunit",
31
+ mstest = "mstest",
32
+ xunit = "xunit",
33
+ specflow = "specflow",
34
+ reqnroll = "reqnroll"
35
+ }
36
+ export type SDKSupportedTestingFramework = keyof typeof SDKSupportedTestingFrameworkEnum;
37
+ export type ConfigMapping = Record<SDKSupportedLanguageEnum, Partial<Record<SDKSupportedBrowserAutomationFrameworkEnum, Partial<Record<SDKSupportedTestingFrameworkEnum, {
38
+ instructions: (username: string, accessKey: string) => string;
39
+ }>>>>>;
@@ -26,6 +26,7 @@ export var SDKSupportedTestingFrameworkEnum;
26
26
  SDKSupportedTestingFrameworkEnum["junit4"] = "junit4";
27
27
  SDKSupportedTestingFrameworkEnum["junit5"] = "junit5";
28
28
  SDKSupportedTestingFrameworkEnum["testng"] = "testng";
29
+ SDKSupportedTestingFrameworkEnum["serenity"] = "serenity";
29
30
  SDKSupportedTestingFrameworkEnum["cypress"] = "cypress";
30
31
  SDKSupportedTestingFrameworkEnum["nunit"] = "nunit";
31
32
  SDKSupportedTestingFrameworkEnum["mstest"] = "mstest";
@@ -0,0 +1,11 @@
1
+ interface SelectorMapping {
2
+ originalSelector: string;
3
+ healedSelector: string;
4
+ context: {
5
+ before: string;
6
+ after: string;
7
+ };
8
+ }
9
+ import { BrowserStackConfig } from "../../lib/types.js";
10
+ export declare function getSelfHealSelectors(sessionId: string, config: BrowserStackConfig): Promise<SelectorMapping[]>;
11
+ export {};
@@ -1,17 +1,21 @@
1
1
  import { assertOkResponse } from "../../lib/utils.js";
2
- import config from "../../config.js";
3
- export async function getSelfHealSelectors(sessionId) {
4
- const credentials = `${config.browserstackUsername}:${config.browserstackAccessKey}`;
5
- const auth = Buffer.from(credentials).toString("base64");
2
+ import { getBrowserStackAuth } from "../../lib/get-auth.js";
3
+ import { apiClient } from "../../lib/apiClient.js";
4
+ export async function getSelfHealSelectors(sessionId, config) {
5
+ const authString = getBrowserStackAuth(config);
6
+ const auth = Buffer.from(authString).toString("base64");
6
7
  const url = `https://api.browserstack.com/automate/sessions/${sessionId}/logs`;
7
- const response = await fetch(url, {
8
+ const response = await apiClient.get({
9
+ url,
8
10
  headers: {
9
11
  "Content-Type": "application/json",
10
12
  Authorization: `Basic ${auth}`,
11
13
  },
12
14
  });
13
15
  await assertOkResponse(response, "session logs");
14
- const logText = await response.text();
16
+ const logText = typeof response.data === "string"
17
+ ? response.data
18
+ : JSON.stringify(response.data);
15
19
  return extractHealedSelectors(logText);
16
20
  }
17
21
  function extractHealedSelectors(logText) {
@@ -0,0 +1,7 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
+ import { BrowserStackConfig } from "../lib/types.js";
4
+ export declare function fetchSelfHealSelectorTool(args: {
5
+ sessionId: string;
6
+ }, config: BrowserStackConfig): Promise<CallToolResult>;
7
+ export default function addSelfHealTools(server: McpServer, config: BrowserStackConfig): Record<string, any>;
@@ -3,9 +3,9 @@ import { getSelfHealSelectors } from "./selfheal-utils/selfheal.js";
3
3
  import logger from "../logger.js";
4
4
  import { trackMCP } from "../lib/instrumentation.js";
5
5
  // Tool function that fetches self-healing selectors
6
- export async function fetchSelfHealSelectorTool(args) {
6
+ export async function fetchSelfHealSelectorTool(args, config) {
7
7
  try {
8
- const selectors = await getSelfHealSelectors(args.sessionId);
8
+ const selectors = await getSelfHealSelectors(args.sessionId, config);
9
9
  return {
10
10
  content: [
11
11
  {
@@ -22,16 +22,17 @@ export async function fetchSelfHealSelectorTool(args) {
22
22
  }
23
23
  }
24
24
  // Registers the fetchSelfHealSelector tool with the MCP server
25
- export default function addSelfHealTools(server) {
26
- server.tool("fetchSelfHealedSelectors", "Retrieves AI-generated, self-healed selectors for a BrowserStack Automate session to resolve flaky tests caused by dynamic DOM changes.", {
25
+ export default function addSelfHealTools(server, config) {
26
+ const tools = {};
27
+ tools.fetchSelfHealedSelectors = server.tool("fetchSelfHealedSelectors", "Retrieves AI-generated, self-healed selectors for a BrowserStack Automate session to resolve flaky tests caused by dynamic DOM changes.", {
27
28
  sessionId: z.string().describe("The session ID of the test run"),
28
29
  }, async (args) => {
29
30
  try {
30
- trackMCP("fetchSelfHealedSelectors", server.server.getClientVersion());
31
- return await fetchSelfHealSelectorTool(args);
31
+ trackMCP("fetchSelfHealedSelectors", server.server.getClientVersion(), undefined, config);
32
+ return await fetchSelfHealSelectorTool(args, config);
32
33
  }
33
34
  catch (error) {
34
- trackMCP("fetchSelfHealedSelectors", server.server.getClientVersion(), error);
35
+ trackMCP("fetchSelfHealedSelectors", server.server.getClientVersion(), error, config);
35
36
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
36
37
  return {
37
38
  content: [
@@ -43,4 +44,5 @@ export default function addSelfHealTools(server) {
43
44
  };
44
45
  }
45
46
  });
47
+ return tools;
46
48
  }
@@ -0,0 +1,34 @@
1
+ import { DefaultFieldMaps, Scenario, CreateTestCasesFromFileArgs } from "./types.js";
2
+ import { BrowserStackConfig } from "../../../lib/types.js";
3
+ /**
4
+ * Fetch default and custom form fields for a project.
5
+ */
6
+ export declare function fetchFormFields(projectId: string, config: BrowserStackConfig): Promise<{
7
+ default_fields: any;
8
+ custom_fields: any;
9
+ }>;
10
+ /**
11
+ * Trigger AI-based test case generation for a document.
12
+ */
13
+ export declare function triggerTestCaseGeneration(document: string, documentId: number, folderId: string, projectId: string, source: string, config: BrowserStackConfig): Promise<string>;
14
+ /**
15
+ * Initiate a fetch for test-case details; returns the traceRequestId for polling.
16
+ */
17
+ export declare function fetchTestCaseDetails(documentId: number, folderId: string, projectId: string, testCaseIds: string[], source: string, config: BrowserStackConfig): Promise<string>;
18
+ /**
19
+ * Poll for a given traceRequestId until all test-case details are returned.
20
+ */
21
+ export declare function pollTestCaseDetails(traceRequestId: string, config: BrowserStackConfig): Promise<Record<string, any>>;
22
+ /**
23
+ * Poll for scenarios & testcases, trigger detail fetches, then poll all details in parallel.
24
+ */
25
+ export declare function pollScenariosTestDetails(args: CreateTestCasesFromFileArgs, traceId: string, context: any, documentId: number, source: string, config: BrowserStackConfig): Promise<Record<string, Scenario>>;
26
+ /**
27
+ * Bulk-create generated test cases in BrowserStack.
28
+ */
29
+ export declare function bulkCreateTestCases(scenariosMap: Record<string, Scenario>, projectId: string, folderId: string, fieldMaps: DefaultFieldMaps, booleanFieldId: number | undefined, traceId: string, context: any, documentId: number, config: BrowserStackConfig): Promise<string>;
30
+ export declare function projectIdentifierToId(projectId: string, config: BrowserStackConfig): Promise<string>;
31
+ export declare function testCaseIdentifierToDetails(projectId: string, testCaseIdentifier: string, config: BrowserStackConfig): Promise<{
32
+ testCaseId: string;
33
+ folderId: string;
34
+ }>;