@browserstack/mcp-server 1.1.7 → 1.1.9
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 +71 -35
- package/dist/config.js +8 -2
- package/dist/index.js +1 -1
- package/dist/lib/local.js +9 -0
- package/dist/tools/accessibility.js +23 -0
- package/dist/tools/accessiblity-utils/accessibility-rag.js +47 -0
- package/dist/tools/accessiblity-utils/scanner.js +3 -0
- package/dist/tools/appautomate-utils/appautomate.js +68 -7
- package/dist/tools/appautomate-utils/types.js +6 -0
- package/dist/tools/appautomate.js +99 -4
- package/dist/tools/bstack-sdk.js +72 -10
- package/dist/tools/sdk-utils/commands.js +64 -0
- package/dist/tools/sdk-utils/constants.js +433 -38
- package/dist/tools/sdk-utils/instructions.js +47 -9
- package/dist/tools/sdk-utils/percy/constants.js +176 -0
- package/dist/tools/sdk-utils/percy/instructions.js +28 -0
- package/dist/tools/sdk-utils/percy/types.js +1 -0
- package/dist/tools/sdk-utils/types.js +35 -1
- package/package.json +1 -1
|
@@ -13,16 +13,15 @@ export const getInstructionsForProjectConfiguration = (detectedBrowserAutomation
|
|
|
13
13
|
}
|
|
14
14
|
return configuration[detectedBrowserAutomationFramework][detectedTestingFramework].instructions;
|
|
15
15
|
};
|
|
16
|
-
export function generateBrowserStackYMLInstructions(desiredPlatforms) {
|
|
17
|
-
|
|
18
|
-
Create a browserstack.yml file in the project root. The file should be in the following format:
|
|
19
|
-
|
|
20
|
-
\`\`\`yaml
|
|
16
|
+
export function generateBrowserStackYMLInstructions(desiredPlatforms, enablePercy = false) {
|
|
17
|
+
let ymlContent = `
|
|
21
18
|
# ======================
|
|
22
19
|
# BrowserStack Reporting
|
|
23
20
|
# ======================
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
26
25
|
|
|
27
26
|
# =======================================
|
|
28
27
|
# Platforms (Browsers / Devices to test)
|
|
@@ -47,13 +46,52 @@ platforms:
|
|
|
47
46
|
# Example 2 - If you have configured 1 platform and set \`parallelsPerPlatform\` as 5, a total of 5 (1 * 5) parallel threads will be used on BrowserStack
|
|
48
47
|
parallelsPerPlatform: 1
|
|
49
48
|
|
|
49
|
+
# =================
|
|
50
|
+
# Local Testing
|
|
51
|
+
# =================
|
|
52
|
+
# Set to true to test local
|
|
50
53
|
browserstackLocal: true
|
|
51
54
|
|
|
52
55
|
# ===================
|
|
53
56
|
# Debugging features
|
|
54
57
|
# ===================
|
|
55
|
-
debug: true
|
|
56
|
-
testObservability: true
|
|
58
|
+
debug: true # Visual logs, text logs, etc.
|
|
59
|
+
testObservability: true # For Test Observability`;
|
|
60
|
+
if (enablePercy) {
|
|
61
|
+
ymlContent += `
|
|
62
|
+
|
|
63
|
+
# =====================
|
|
64
|
+
# Percy Visual Testing
|
|
65
|
+
# =====================
|
|
66
|
+
# Set percy to true to enable visual testing.
|
|
67
|
+
# Set percyCaptureMode to 'manual' to control when screenshots are taken.
|
|
68
|
+
percy: true
|
|
69
|
+
percyCaptureMode: manual`;
|
|
70
|
+
}
|
|
71
|
+
return `
|
|
72
|
+
Create a browserstack.yml file in the project root. The file should be in the following format:
|
|
73
|
+
|
|
74
|
+
\`\`\`yaml${ymlContent}
|
|
57
75
|
\`\`\`
|
|
58
76
|
\n`;
|
|
59
77
|
}
|
|
78
|
+
export function formatInstructionsWithNumbers(instructionText, separator = "---STEP---") {
|
|
79
|
+
// Split the instructions by the separator
|
|
80
|
+
const steps = instructionText
|
|
81
|
+
.split(separator)
|
|
82
|
+
.map((step) => step.trim())
|
|
83
|
+
.filter((step) => step.length > 0);
|
|
84
|
+
// If no separators found, treat the entire text as one step
|
|
85
|
+
if (steps.length === 1 && !instructionText.includes(separator)) {
|
|
86
|
+
return `**Step 1:**\n${instructionText.trim()}\n\n**✅ Verification:**\nPlease verify that you have completed all the steps above to ensure proper setup.`;
|
|
87
|
+
}
|
|
88
|
+
// Format each step with numbering
|
|
89
|
+
const formattedSteps = steps
|
|
90
|
+
.map((step, index) => {
|
|
91
|
+
return `**Step ${index + 1}:**\n${step.trim()}`;
|
|
92
|
+
})
|
|
93
|
+
.join("\n\n");
|
|
94
|
+
// Add verification statement at the end
|
|
95
|
+
const verificationText = `\n\n**✅ Verification:**\nPlease verify that you have completed all ${steps.length} steps above to ensure proper setup. If you encounter any issues, double-check each step and ensure all commands executed successfully.`;
|
|
96
|
+
return formattedSteps + verificationText;
|
|
97
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
const javaSeleniumInstructions = `
|
|
2
|
+
Import the BrowserStack Percy SDK in your test script:
|
|
3
|
+
Add the Percy import to your test file.
|
|
4
|
+
|
|
5
|
+
---STEP---
|
|
6
|
+
|
|
7
|
+
Add screenshot capture method at required points:
|
|
8
|
+
Use the \`PercySDK.screenshot(driver, name)\` method at points in your test script where you want to capture screenshots.
|
|
9
|
+
|
|
10
|
+
Here's an example:
|
|
11
|
+
|
|
12
|
+
\`\`\`java
|
|
13
|
+
// ...imports
|
|
14
|
+
import com.browserstack.PercySDK;
|
|
15
|
+
|
|
16
|
+
public class YourTestClass extends YourBaseTest {
|
|
17
|
+
@Test
|
|
18
|
+
public void test() throws Exception {
|
|
19
|
+
// your test logic
|
|
20
|
+
// ...
|
|
21
|
+
|
|
22
|
+
// Capture a Percy screenshot
|
|
23
|
+
PercySDK.screenshot(driver, "My Screenshot Name");
|
|
24
|
+
|
|
25
|
+
// ...
|
|
26
|
+
// more test logic
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
\`\`\`
|
|
30
|
+
`;
|
|
31
|
+
export const nodejsSeleniumInstructions = `
|
|
32
|
+
Import the BrowserStack Percy SDK in your test script:
|
|
33
|
+
Add the Percy import to your test file.
|
|
34
|
+
|
|
35
|
+
---STEP---
|
|
36
|
+
|
|
37
|
+
Add screenshot capture method at required points:
|
|
38
|
+
Use the \`percy.snapshot(driver, name)\` method at points in your test script where you want to capture screenshots.
|
|
39
|
+
|
|
40
|
+
\`\`\`javascript
|
|
41
|
+
const { percy } = require('browserstack-node-sdk');
|
|
42
|
+
describe("sample Test", () => {
|
|
43
|
+
// ... other imports and setup
|
|
44
|
+
|
|
45
|
+
test("my test", async () => {
|
|
46
|
+
// ....
|
|
47
|
+
await percy.snapshot(driver, "My Snapshot")
|
|
48
|
+
// ....
|
|
49
|
+
});
|
|
50
|
+
})
|
|
51
|
+
\`\`\`
|
|
52
|
+
`;
|
|
53
|
+
const webdriverioPercyInstructions = `
|
|
54
|
+
Enable Percy in \`wdio.conf.js\`:
|
|
55
|
+
In your WebdriverIO configuration file, modify the 'browserstack' service options to enable Percy.
|
|
56
|
+
|
|
57
|
+
- Set \`percy: true\`.
|
|
58
|
+
- Set a \`projectName\`. This is required and will be used for both your Automate and Percy projects.
|
|
59
|
+
- Set \`percyCaptureMode\`. The default \`auto\` mode is recommended, which captures screenshots on events like clicks. Other modes are \`testcase\`, \`click\`, \`screenshot\`, and \`manual\`.
|
|
60
|
+
|
|
61
|
+
Here's how to modify the service configuration:
|
|
62
|
+
\`\`\`javascript
|
|
63
|
+
// in wdio.conf.js
|
|
64
|
+
|
|
65
|
+
exports.config = {
|
|
66
|
+
// ... other configs
|
|
67
|
+
services: [
|
|
68
|
+
[
|
|
69
|
+
'browserstack',
|
|
70
|
+
{
|
|
71
|
+
// ... other service options
|
|
72
|
+
percy: true,
|
|
73
|
+
percyCaptureMode: 'auto' // or 'manual', 'testcase', etc.
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
],
|
|
77
|
+
|
|
78
|
+
commonCapabilities: {
|
|
79
|
+
'bstack:options': {
|
|
80
|
+
projectName: "My Percy Project", // This is required for Percy
|
|
81
|
+
// ... other common capabilities
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
// ... rest of your config
|
|
85
|
+
};
|
|
86
|
+
\`\`\`
|
|
87
|
+
|
|
88
|
+
---STEP---
|
|
89
|
+
|
|
90
|
+
Manually Capturing Screenshots (Optional):
|
|
91
|
+
If you set \`percyCaptureMode: 'manual'\` or want to take extra screenshots in \`auto\` mode, you need to add screenshot commands to your tests.
|
|
92
|
+
|
|
93
|
+
First, install \`browserstack-node-sdk\`:
|
|
94
|
+
\`\`\`bash
|
|
95
|
+
npm install browserstack-node-sdk
|
|
96
|
+
\`\`\`
|
|
97
|
+
|
|
98
|
+
Then, in your test script, import \`percy\` and use it to take a snapshot:
|
|
99
|
+
\`\`\`javascript
|
|
100
|
+
// your_test_file.js
|
|
101
|
+
const { percy } = require('browserstack-node-sdk');
|
|
102
|
+
|
|
103
|
+
describe("My WebdriverIO Test", () => {
|
|
104
|
+
it("should take a percy snapshot", async () => {
|
|
105
|
+
// ... your test logic (e.g., browser.url('https://example.com'))
|
|
106
|
+
|
|
107
|
+
// Capture a Percy screenshot
|
|
108
|
+
await percy.screenshot(driver, "My Snapshot Name");
|
|
109
|
+
|
|
110
|
+
// ... more test logic
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
\`\`\`
|
|
114
|
+
`;
|
|
115
|
+
const csharpSeleniumInstructions = `
|
|
116
|
+
Import the BrowserStack Percy SDK in your test script:
|
|
117
|
+
Add the Percy import to your test file.
|
|
118
|
+
|
|
119
|
+
---STEP---
|
|
120
|
+
|
|
121
|
+
Add screenshot capture method at required points:
|
|
122
|
+
Use the \`PercySDK.Screenshot(driver, name)\` method at points in your test script where you want to capture screenshots.
|
|
123
|
+
|
|
124
|
+
Here's an example:
|
|
125
|
+
|
|
126
|
+
\`\`\`csharp
|
|
127
|
+
using BrowserStackSDK.Percy;
|
|
128
|
+
using NUnit.Framework;
|
|
129
|
+
|
|
130
|
+
namespace Tests;
|
|
131
|
+
|
|
132
|
+
public class MyTest
|
|
133
|
+
{
|
|
134
|
+
[Test]
|
|
135
|
+
public void SampleTest()
|
|
136
|
+
{
|
|
137
|
+
// your test logic
|
|
138
|
+
// ...
|
|
139
|
+
|
|
140
|
+
// Capture a Percy screenshot
|
|
141
|
+
PercySDK.Screenshot(driver, "Screenshot name");
|
|
142
|
+
|
|
143
|
+
// ...
|
|
144
|
+
// more test logic
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
\`\`\`
|
|
148
|
+
`;
|
|
149
|
+
export const PERCY_INSTRUCTIONS = {
|
|
150
|
+
java: {
|
|
151
|
+
selenium: {
|
|
152
|
+
testng: { script_updates: javaSeleniumInstructions },
|
|
153
|
+
cucumber: { script_updates: javaSeleniumInstructions },
|
|
154
|
+
junit4: { script_updates: javaSeleniumInstructions },
|
|
155
|
+
junit5: { script_updates: javaSeleniumInstructions },
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
csharp: {
|
|
159
|
+
selenium: {
|
|
160
|
+
nunit: { script_updates: csharpSeleniumInstructions },
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
nodejs: {
|
|
164
|
+
selenium: {
|
|
165
|
+
mocha: {
|
|
166
|
+
script_updates: nodejsSeleniumInstructions,
|
|
167
|
+
},
|
|
168
|
+
jest: {
|
|
169
|
+
script_updates: nodejsSeleniumInstructions,
|
|
170
|
+
},
|
|
171
|
+
webdriverio: {
|
|
172
|
+
script_updates: webdriverioPercyInstructions,
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PERCY_INSTRUCTIONS } from "./constants.js";
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves Percy-specific instructions for a given language and framework.
|
|
4
|
+
*/
|
|
5
|
+
export function getPercyInstructions(language, automationFramework, testingFramework) {
|
|
6
|
+
const langConfig = PERCY_INSTRUCTIONS[language];
|
|
7
|
+
if (!langConfig) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const frameworkConfig = langConfig[automationFramework];
|
|
11
|
+
if (!frameworkConfig) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const percyInstructions = frameworkConfig[testingFramework];
|
|
15
|
+
if (!percyInstructions) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return percyInstructions;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Formats the retrieved Percy instructions into a user-friendly string.
|
|
22
|
+
*/
|
|
23
|
+
export function formatPercyInstructions(instructions) {
|
|
24
|
+
return `\n\n## Percy Visual Testing Setup
|
|
25
|
+
To enable visual testing with Percy, you need to make the following changes to your project configuration and test scripts.
|
|
26
|
+
${instructions.script_updates}
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1,35 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var SDKSupportedLanguageEnum;
|
|
2
|
+
(function (SDKSupportedLanguageEnum) {
|
|
3
|
+
SDKSupportedLanguageEnum["nodejs"] = "nodejs";
|
|
4
|
+
SDKSupportedLanguageEnum["python"] = "python";
|
|
5
|
+
SDKSupportedLanguageEnum["java"] = "java";
|
|
6
|
+
SDKSupportedLanguageEnum["csharp"] = "csharp";
|
|
7
|
+
})(SDKSupportedLanguageEnum || (SDKSupportedLanguageEnum = {}));
|
|
8
|
+
export var SDKSupportedBrowserAutomationFrameworkEnum;
|
|
9
|
+
(function (SDKSupportedBrowserAutomationFrameworkEnum) {
|
|
10
|
+
SDKSupportedBrowserAutomationFrameworkEnum["playwright"] = "playwright";
|
|
11
|
+
SDKSupportedBrowserAutomationFrameworkEnum["selenium"] = "selenium";
|
|
12
|
+
SDKSupportedBrowserAutomationFrameworkEnum["cypress"] = "cypress";
|
|
13
|
+
})(SDKSupportedBrowserAutomationFrameworkEnum || (SDKSupportedBrowserAutomationFrameworkEnum = {}));
|
|
14
|
+
export var SDKSupportedTestingFrameworkEnum;
|
|
15
|
+
(function (SDKSupportedTestingFrameworkEnum) {
|
|
16
|
+
SDKSupportedTestingFrameworkEnum["jest"] = "jest";
|
|
17
|
+
SDKSupportedTestingFrameworkEnum["codeceptjs"] = "codeceptjs";
|
|
18
|
+
SDKSupportedTestingFrameworkEnum["playwright"] = "playwright";
|
|
19
|
+
SDKSupportedTestingFrameworkEnum["pytest"] = "pytest";
|
|
20
|
+
SDKSupportedTestingFrameworkEnum["robot"] = "robot";
|
|
21
|
+
SDKSupportedTestingFrameworkEnum["behave"] = "behave";
|
|
22
|
+
SDKSupportedTestingFrameworkEnum["cucumber"] = "cucumber";
|
|
23
|
+
SDKSupportedTestingFrameworkEnum["nightwatch"] = "nightwatch";
|
|
24
|
+
SDKSupportedTestingFrameworkEnum["webdriverio"] = "webdriverio";
|
|
25
|
+
SDKSupportedTestingFrameworkEnum["mocha"] = "mocha";
|
|
26
|
+
SDKSupportedTestingFrameworkEnum["junit4"] = "junit4";
|
|
27
|
+
SDKSupportedTestingFrameworkEnum["junit5"] = "junit5";
|
|
28
|
+
SDKSupportedTestingFrameworkEnum["testng"] = "testng";
|
|
29
|
+
SDKSupportedTestingFrameworkEnum["cypress"] = "cypress";
|
|
30
|
+
SDKSupportedTestingFrameworkEnum["nunit"] = "nunit";
|
|
31
|
+
SDKSupportedTestingFrameworkEnum["mstest"] = "mstest";
|
|
32
|
+
SDKSupportedTestingFrameworkEnum["xunit"] = "xunit";
|
|
33
|
+
SDKSupportedTestingFrameworkEnum["specflow"] = "specflow";
|
|
34
|
+
SDKSupportedTestingFrameworkEnum["reqnroll"] = "reqnroll";
|
|
35
|
+
})(SDKSupportedTestingFrameworkEnum || (SDKSupportedTestingFrameworkEnum = {}));
|