@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
package/dist/tools/bstack-sdk.js
CHANGED
|
@@ -1,37 +1,98 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { generateBrowserStackYMLInstructions, getInstructionsForProjectConfiguration, } from "./sdk-utils/instructions.js";
|
|
3
2
|
import { trackMCP } from "../lib/instrumentation.js";
|
|
3
|
+
import { getSDKPrefixCommand } from "./sdk-utils/commands.js";
|
|
4
|
+
import { SDKSupportedLanguageEnum, SDKSupportedBrowserAutomationFrameworkEnum, SDKSupportedTestingFrameworkEnum, } from "./sdk-utils/types.js";
|
|
5
|
+
import { generateBrowserStackYMLInstructions, getInstructionsForProjectConfiguration, formatInstructionsWithNumbers, } from "./sdk-utils/instructions.js";
|
|
6
|
+
import { formatPercyInstructions, getPercyInstructions, } from "./sdk-utils/percy/instructions.js";
|
|
4
7
|
/**
|
|
5
8
|
* BrowserStack SDK hooks into your test framework to seamlessly run tests on BrowserStack.
|
|
6
9
|
* This tool gives instructions to setup a browserstack.yml file in the project root and installs the necessary dependencies.
|
|
7
10
|
*/
|
|
8
|
-
export async function bootstrapProjectWithSDK({ detectedBrowserAutomationFramework, detectedTestingFramework, detectedLanguage, desiredPlatforms, }) {
|
|
9
|
-
|
|
11
|
+
export async function bootstrapProjectWithSDK({ detectedBrowserAutomationFramework, detectedTestingFramework, detectedLanguage, desiredPlatforms, enablePercy, }) {
|
|
12
|
+
// Handle frameworks with unique setup instructions that don't use browserstack.yml
|
|
13
|
+
if (detectedBrowserAutomationFramework === "cypress" ||
|
|
14
|
+
detectedTestingFramework === "webdriverio") {
|
|
15
|
+
let combinedInstructions = getInstructionsForProjectConfiguration(detectedBrowserAutomationFramework, detectedTestingFramework, detectedLanguage);
|
|
16
|
+
if (enablePercy) {
|
|
17
|
+
const percyInstructions = getPercyInstructions(detectedLanguage, detectedBrowserAutomationFramework, detectedTestingFramework);
|
|
18
|
+
if (percyInstructions) {
|
|
19
|
+
combinedInstructions +=
|
|
20
|
+
"\n\n" + formatPercyInstructions(percyInstructions);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
throw new Error(`Percy is currently not supported through MCP for ${detectedLanguage} with ${detectedTestingFramework}. If you want to run the test cases without Percy, disable Percy and run it again.`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// Apply consistent formatting for all configurations
|
|
27
|
+
return formatFinalInstructions(combinedInstructions);
|
|
28
|
+
}
|
|
29
|
+
// Handle default flow using browserstack.yml
|
|
30
|
+
const sdkSetupCommand = getSDKPrefixCommand(detectedLanguage, detectedTestingFramework);
|
|
31
|
+
const ymlInstructions = generateBrowserStackYMLInstructions(desiredPlatforms, enablePercy);
|
|
10
32
|
const instructionsForProjectConfiguration = getInstructionsForProjectConfiguration(detectedBrowserAutomationFramework, detectedTestingFramework, detectedLanguage);
|
|
33
|
+
let combinedInstructions = "";
|
|
34
|
+
// Step 1: Add SDK setup command
|
|
35
|
+
if (sdkSetupCommand) {
|
|
36
|
+
combinedInstructions += sdkSetupCommand;
|
|
37
|
+
}
|
|
38
|
+
// Step 2: Add browserstack.yml setup
|
|
39
|
+
if (ymlInstructions) {
|
|
40
|
+
combinedInstructions += "\n\n---STEP---\n" + ymlInstructions;
|
|
41
|
+
}
|
|
42
|
+
// Step 3: Add language/framework-specific setup
|
|
43
|
+
if (instructionsForProjectConfiguration) {
|
|
44
|
+
combinedInstructions += "\n\n" + instructionsForProjectConfiguration;
|
|
45
|
+
}
|
|
46
|
+
// Step 4: Add Percy setup if applicable
|
|
47
|
+
if (enablePercy) {
|
|
48
|
+
const percyInstructions = getPercyInstructions(detectedLanguage, detectedBrowserAutomationFramework, detectedTestingFramework);
|
|
49
|
+
if (percyInstructions) {
|
|
50
|
+
combinedInstructions +=
|
|
51
|
+
"\n\n" + formatPercyInstructions(percyInstructions);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
throw new Error(`Percy is currently not supported through MCP for ${detectedLanguage} with ${detectedTestingFramework}. If you want to run the test cases without Percy, disable Percy and run it again.`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Apply consistent formatting for all configurations
|
|
58
|
+
return formatFinalInstructions(combinedInstructions);
|
|
59
|
+
}
|
|
60
|
+
// Helper function to apply consistent formatting to all instruction types
|
|
61
|
+
function formatFinalInstructions(combinedInstructions) {
|
|
62
|
+
const fullInstructions = `⚠️ IMPORTANT: DO NOT SKIP ANY STEP
|
|
63
|
+
All the setup steps described in this file MUST be executed regardless of any existing configuration or setup.
|
|
64
|
+
This ensures proper BrowserStack SDK setup.
|
|
65
|
+
|
|
66
|
+
${formatInstructionsWithNumbers(combinedInstructions)}`;
|
|
11
67
|
return {
|
|
12
68
|
content: [
|
|
13
69
|
{
|
|
14
70
|
type: "text",
|
|
15
|
-
text:
|
|
71
|
+
text: fullInstructions,
|
|
16
72
|
isError: false,
|
|
17
73
|
},
|
|
18
74
|
],
|
|
19
75
|
};
|
|
20
76
|
}
|
|
21
77
|
export default function addSDKTools(server) {
|
|
22
|
-
server.tool("runTestsOnBrowserStack", "Use this tool to get instructions for running tests on BrowserStack.", {
|
|
78
|
+
server.tool("runTestsOnBrowserStack", "Use this tool to get instructions for running tests on BrowserStack and BrowserStack Percy. It sets up the BrowserStack SDK and runs your test cases on BrowserStack.", {
|
|
23
79
|
detectedBrowserAutomationFramework: z
|
|
24
|
-
.
|
|
80
|
+
.nativeEnum(SDKSupportedBrowserAutomationFrameworkEnum)
|
|
25
81
|
.describe("The automation framework configured in the project. Example: 'playwright', 'selenium'"),
|
|
26
82
|
detectedTestingFramework: z
|
|
27
|
-
.
|
|
28
|
-
.describe("The testing framework used in the project. Example: 'jest', 'pytest'"),
|
|
83
|
+
.nativeEnum(SDKSupportedTestingFrameworkEnum)
|
|
84
|
+
.describe("The testing framework used in the project. Be precise with framework selection Example: 'webdriverio', 'jest', 'pytest', 'junit4', 'junit5', 'mocha'"),
|
|
29
85
|
detectedLanguage: z
|
|
30
|
-
.
|
|
31
|
-
.describe("The programming language used in the project. Example: 'nodejs', 'python'"),
|
|
86
|
+
.nativeEnum(SDKSupportedLanguageEnum)
|
|
87
|
+
.describe("The programming language used in the project. Example: 'nodejs', 'python', 'java', 'csharp'"),
|
|
32
88
|
desiredPlatforms: z
|
|
33
89
|
.array(z.enum(["windows", "macos", "android", "ios"]))
|
|
34
90
|
.describe("The platforms the user wants to test on. Always ask this to the user, do not try to infer this."),
|
|
91
|
+
enablePercy: z
|
|
92
|
+
.boolean()
|
|
93
|
+
.optional()
|
|
94
|
+
.default(false)
|
|
95
|
+
.describe("Set to true if the user wants to enable Percy for visual testing. Defaults to false."),
|
|
35
96
|
}, async (args) => {
|
|
36
97
|
try {
|
|
37
98
|
trackMCP("runTestsOnBrowserStack", server.server.getClientVersion());
|
|
@@ -40,6 +101,7 @@ export default function addSDKTools(server) {
|
|
|
40
101
|
detectedTestingFramework: args.detectedTestingFramework,
|
|
41
102
|
detectedLanguage: args.detectedLanguage,
|
|
42
103
|
desiredPlatforms: args.desiredPlatforms,
|
|
104
|
+
enablePercy: args.enablePercy,
|
|
43
105
|
});
|
|
44
106
|
}
|
|
45
107
|
catch (error) {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Framework mapping for Java Maven archetype generation
|
|
2
|
+
const JAVA_FRAMEWORK_MAP = {
|
|
3
|
+
testng: "testng",
|
|
4
|
+
junit5: "junit5",
|
|
5
|
+
junit4: "junit4",
|
|
6
|
+
cucumber: "cucumber-testng",
|
|
7
|
+
};
|
|
8
|
+
// Common Gradle setup instructions (platform-independent)
|
|
9
|
+
const GRADLE_SETUP_INSTRUCTIONS = `
|
|
10
|
+
**For Gradle setup:**
|
|
11
|
+
1. Add browserstack-java-sdk to dependencies:
|
|
12
|
+
compileOnly 'com.browserstack:browserstack-java-sdk:latest.release'
|
|
13
|
+
|
|
14
|
+
2. Add browserstackSDK path variable:
|
|
15
|
+
def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }
|
|
16
|
+
|
|
17
|
+
3. Add javaagent to gradle tasks:
|
|
18
|
+
jvmArgs "-javaagent:\${browserstackSDKArtifact.file}"
|
|
19
|
+
`;
|
|
20
|
+
export function getSDKPrefixCommand(language, framework) {
|
|
21
|
+
switch (language) {
|
|
22
|
+
case "nodejs":
|
|
23
|
+
return `---STEP---
|
|
24
|
+
Install BrowserStack Node SDK using command:
|
|
25
|
+
\`\`\`bash
|
|
26
|
+
npm i -D browserstack-node-sdk@latest
|
|
27
|
+
\`\`\`
|
|
28
|
+
---STEP---
|
|
29
|
+
Run the following command to setup browserstack sdk:
|
|
30
|
+
\`\`\`bash
|
|
31
|
+
npx setup --username ${process.env.BROWSERSTACK_USERNAME} --key ${process.env.BROWSERSTACK_ACCESS_KEY}
|
|
32
|
+
\`\`\`
|
|
33
|
+
---STEP---
|
|
34
|
+
Edit the browserstack.yml file that was created in the project root to add your desired platforms and browsers.`;
|
|
35
|
+
case "java": {
|
|
36
|
+
const mavenFramework = getJavaFrameworkForMaven(framework);
|
|
37
|
+
const isWindows = process.platform === "win32";
|
|
38
|
+
const mavenCommand = isWindows
|
|
39
|
+
? `mvn archetype:generate -B -DarchetypeGroupId="com.browserstack" -DarchetypeArtifactId="browserstack-sdk-archetype-integrate" -DarchetypeVersion="1.0" -DgroupId="com.browserstack" -DartifactId="browserstack-sdk-archetype-integrate" -Dversion="1.0" -DBROWSERSTACK_USERNAME="${process.env.BROWSERSTACK_USERNAME}" -DBROWSERSTACK_ACCESS_KEY="${process.env.BROWSERSTACK_ACCESS_KEY}" -DBROWSERSTACK_FRAMEWORK="${mavenFramework}"`
|
|
40
|
+
: `mvn archetype:generate -B -DarchetypeGroupId=com.browserstack \\
|
|
41
|
+
-DarchetypeArtifactId=browserstack-sdk-archetype-integrate -DarchetypeVersion=1.0 \\
|
|
42
|
+
-DgroupId=com.browserstack -DartifactId=browserstack-sdk-archetype-integrate -Dversion=1.0 \\
|
|
43
|
+
-DBROWSERSTACK_USERNAME="${process.env.BROWSERSTACK_USERNAME}" \\
|
|
44
|
+
-DBROWSERSTACK_ACCESS_KEY="${process.env.BROWSERSTACK_ACCESS_KEY}" \\
|
|
45
|
+
-DBROWSERSTACK_FRAMEWORK="${mavenFramework}"`;
|
|
46
|
+
const platformLabel = isWindows ? "Windows" : "macOS/Linux";
|
|
47
|
+
return `---STEP---
|
|
48
|
+
Install BrowserStack Java SDK
|
|
49
|
+
|
|
50
|
+
**Maven command for ${framework} (${platformLabel}):**
|
|
51
|
+
Run the command, it is required to generate the browserstack-sdk-archetype-integrate project:
|
|
52
|
+
${mavenCommand}
|
|
53
|
+
|
|
54
|
+
Alternative setup for Gradle users:
|
|
55
|
+
${GRADLE_SETUP_INSTRUCTIONS}`;
|
|
56
|
+
}
|
|
57
|
+
// Add more languages as needed
|
|
58
|
+
default:
|
|
59
|
+
return "";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export function getJavaFrameworkForMaven(framework) {
|
|
63
|
+
return JAVA_FRAMEWORK_MAP[framework] || framework;
|
|
64
|
+
}
|
|
@@ -1,37 +1,62 @@
|
|
|
1
1
|
import config from "../../config.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
\`\`\`json
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test:browserstack": "npx browserstack-node-sdk <framework-specific-test-execution-command>"
|
|
8
|
-
}
|
|
9
|
-
\`\`\`
|
|
10
|
-
- Add to dependencies:
|
|
11
|
-
\`\`\`json
|
|
12
|
-
"browserstack-node-sdk": "latest"
|
|
13
|
-
\`\`\`
|
|
14
|
-
- Inform user to export BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY as environment variables.
|
|
15
|
-
`;
|
|
2
|
+
/**
|
|
3
|
+
* ---------- PYTHON INSTRUCTIONS ----------
|
|
4
|
+
*/
|
|
16
5
|
const pythonInstructions = `
|
|
17
|
-
|
|
6
|
+
---STEP---
|
|
7
|
+
|
|
8
|
+
Install the BrowserStack SDK:
|
|
18
9
|
\`\`\`bash
|
|
19
10
|
python3 -m pip install browserstack-sdk
|
|
20
11
|
\`\`\`
|
|
21
12
|
|
|
22
|
-
|
|
13
|
+
---STEP---
|
|
14
|
+
|
|
15
|
+
Setup the BrowserStack SDK with your credentials:
|
|
23
16
|
\`\`\`bash
|
|
24
17
|
browserstack-sdk setup --username "${config.browserstackUsername}" --key "${config.browserstackAccessKey}"
|
|
25
18
|
\`\`\`
|
|
26
19
|
|
|
27
|
-
|
|
20
|
+
---STEP---
|
|
21
|
+
|
|
22
|
+
Run your tests on BrowserStack:
|
|
28
23
|
\`\`\`bash
|
|
29
24
|
browserstack-sdk python <path-to-test-file>
|
|
30
25
|
\`\`\`
|
|
31
26
|
`;
|
|
27
|
+
const generatePythonFrameworkInstructions = (framework) => `
|
|
28
|
+
---STEP---
|
|
29
|
+
|
|
30
|
+
Install the BrowserStack SDK:
|
|
31
|
+
\`\`\`bash
|
|
32
|
+
python3 -m pip install browserstack-sdk
|
|
33
|
+
\`\`\`
|
|
34
|
+
|
|
35
|
+
---STEP---
|
|
36
|
+
|
|
37
|
+
Setup the BrowserStack SDK with framework-specific configuration:
|
|
38
|
+
\`\`\`bash
|
|
39
|
+
browserstack-sdk setup --framework "${framework}" --username "${config.browserstackUsername}" --key "${config.browserstackAccessKey}"
|
|
40
|
+
\`\`\`
|
|
41
|
+
|
|
42
|
+
---STEP---
|
|
43
|
+
|
|
44
|
+
Run your ${framework} tests on BrowserStack:
|
|
45
|
+
\`\`\`bash
|
|
46
|
+
browserstack-sdk ${framework} <path-to-test-files>
|
|
47
|
+
\`\`\`
|
|
48
|
+
`;
|
|
49
|
+
const robotInstructions = generatePythonFrameworkInstructions("robot");
|
|
50
|
+
const behaveInstructions = generatePythonFrameworkInstructions("behave");
|
|
51
|
+
const pytestInstructions = generatePythonFrameworkInstructions("pytest");
|
|
52
|
+
/**
|
|
53
|
+
* ---------- JAVA INSTRUCTIONS ----------
|
|
54
|
+
*/
|
|
32
55
|
const argsInstruction = '<argLine>-javaagent:"${com.browserstack:browserstack-java-sdk:jar}"</argLine>';
|
|
33
56
|
const javaInstructions = `
|
|
34
|
-
|
|
57
|
+
---STEP---
|
|
58
|
+
|
|
59
|
+
Add the BrowserStack Java SDK dependency to your \`pom.xml\`:
|
|
35
60
|
\`\`\`xml
|
|
36
61
|
<dependency>
|
|
37
62
|
<groupId>com.browserstack</groupId>
|
|
@@ -50,13 +75,17 @@ dependencies {
|
|
|
50
75
|
}
|
|
51
76
|
\`\`\`
|
|
52
77
|
|
|
53
|
-
|
|
78
|
+
---STEP---
|
|
79
|
+
|
|
80
|
+
Export your BrowserStack credentials as environment variables:
|
|
54
81
|
\`\`\`bash
|
|
55
82
|
export BROWSERSTACK_USERNAME=${config.browserstackUsername}
|
|
56
83
|
export BROWSERSTACK_ACCESS_KEY=${config.browserstackAccessKey}
|
|
57
84
|
\`\`\`
|
|
58
85
|
|
|
59
|
-
|
|
86
|
+
---STEP---
|
|
87
|
+
|
|
88
|
+
Run your tests using Maven:
|
|
60
89
|
\`\`\`bash
|
|
61
90
|
mvn clean test
|
|
62
91
|
\`\`\`
|
|
@@ -66,7 +95,388 @@ Or for Gradle:
|
|
|
66
95
|
gradle clean test
|
|
67
96
|
\`\`\`
|
|
68
97
|
`;
|
|
98
|
+
/**
|
|
99
|
+
* ---------- CSharp INSTRUCTIONS ----------
|
|
100
|
+
*/
|
|
101
|
+
const csharpCommonInstructions = `
|
|
102
|
+
---STEP---
|
|
103
|
+
|
|
104
|
+
Install BrowserStack TestAdapter NuGet package:
|
|
105
|
+
\`\`\`bash
|
|
106
|
+
dotnet add package BrowserStack.TestAdapter
|
|
107
|
+
\`\`\`
|
|
108
|
+
|
|
109
|
+
---STEP---
|
|
110
|
+
|
|
111
|
+
Build the project:
|
|
112
|
+
\`\`\`bash
|
|
113
|
+
dotnet build
|
|
114
|
+
\`\`\`
|
|
115
|
+
|
|
116
|
+
---STEP---
|
|
117
|
+
|
|
118
|
+
Set up BrowserStack SDK with your credentials:
|
|
119
|
+
\`\`\`bash
|
|
120
|
+
dotnet browserstack-sdk setup --userName ${config.browserstackUsername} --accessKey ${config.browserstackAccessKey}
|
|
121
|
+
\`\`\`
|
|
122
|
+
|
|
123
|
+
---STEP---
|
|
124
|
+
|
|
125
|
+
Detect if you are running on Apple Silicon (macOS only):
|
|
126
|
+
Run this check to determine if Apple Silicon-specific setup is required:
|
|
127
|
+
\`\`\`bash
|
|
128
|
+
ARCH="$(uname -m)"
|
|
129
|
+
if [ "$ARCH" = "arm64" ]; then
|
|
130
|
+
echo "Detected arm64 architecture - running Apple-Silicon flow"
|
|
131
|
+
fi
|
|
132
|
+
\`\`\`
|
|
133
|
+
|
|
134
|
+
---STEP---
|
|
135
|
+
|
|
136
|
+
macOS (Apple Silicon) setup (Strictly follow if arm64 detected):
|
|
137
|
+
Install the x64 version of .NET for BrowserStack compatibility.
|
|
138
|
+
|
|
139
|
+
- Check your current .NET version:
|
|
140
|
+
\`\`\`bash
|
|
141
|
+
dotnet --version
|
|
142
|
+
\`\`\`
|
|
143
|
+
|
|
144
|
+
- Ensure the path exists strictly; if not, create it first and then run the setup:
|
|
145
|
+
This automatically installs the x64 version of .NET in the specified path. No need to install it from external sources.
|
|
146
|
+
\`\`\`bash
|
|
147
|
+
sudo dotnet browserstack-sdk setup-dotnet --dotnet-path "<your-chosen-path>" --dotnet-version "<your-dotnet-version>"
|
|
148
|
+
\`\`\`
|
|
149
|
+
Common paths: /usr/local/share/dotnet, ~/dotnet-x64, or /opt/dotnet-x64
|
|
150
|
+
|
|
151
|
+
---STEP---
|
|
152
|
+
|
|
153
|
+
Run the tests:
|
|
154
|
+
- For macOS (Apple Silicon), use the full path where the x64 version of .NET is installed:
|
|
155
|
+
\`\`\`bash
|
|
156
|
+
<your-chosen-path>/dotnet browserstack-sdk
|
|
157
|
+
\`\`\`
|
|
158
|
+
- For Windows, Intel Macs, or if dotnet alias is configured:
|
|
159
|
+
\`\`\`bash
|
|
160
|
+
dotnet test
|
|
161
|
+
\`\`\`
|
|
162
|
+
`;
|
|
163
|
+
const csharpPlaywrightCommonInstructions = `
|
|
164
|
+
---STEP---
|
|
165
|
+
|
|
166
|
+
Install BrowserStack TestAdapter NuGet package:
|
|
167
|
+
\`\`\`bash
|
|
168
|
+
dotnet add package BrowserStack.TestAdapter
|
|
169
|
+
\`\`\`
|
|
170
|
+
|
|
171
|
+
---STEP---
|
|
172
|
+
|
|
173
|
+
Build the project:
|
|
174
|
+
\`\`\`bash
|
|
175
|
+
dotnet build
|
|
176
|
+
\`\`\`
|
|
177
|
+
|
|
178
|
+
---STEP---
|
|
179
|
+
|
|
180
|
+
Set up BrowserStack SDK with your credentials:
|
|
181
|
+
\`\`\`bash
|
|
182
|
+
dotnet browserstack-sdk setup --userName ${config.browserstackUsername} --accessKey ${config.browserstackAccessKey}
|
|
183
|
+
\`\`\`
|
|
184
|
+
|
|
185
|
+
---STEP---
|
|
186
|
+
|
|
187
|
+
Choose supported browser:
|
|
188
|
+
Use exactly one of the following (case-sensitive):
|
|
189
|
+
\`chrome\`, \`edge\`, \`playwright-chromium\`, \`playwright-webkit\`, \`playwright-firefox\`
|
|
190
|
+
|
|
191
|
+
---STEP---
|
|
192
|
+
|
|
193
|
+
Detect if you are running on Apple Silicon (macOS only):
|
|
194
|
+
Run this check to determine if Apple Silicon-specific setup is required:
|
|
195
|
+
\`\`\`bash
|
|
196
|
+
ARCH="$(uname -m)"
|
|
197
|
+
if [ "$ARCH" = "arm64" ]; then
|
|
198
|
+
echo "Detected arm64 architecture - running Apple-Silicon flow"
|
|
199
|
+
fi
|
|
200
|
+
\`\`\`
|
|
201
|
+
|
|
202
|
+
---STEP---
|
|
203
|
+
|
|
204
|
+
macOS (Apple Silicon) setup (required only if arm64 detected):
|
|
205
|
+
Install the x64 version of .NET for compatibility with BrowserStack.
|
|
206
|
+
|
|
207
|
+
- Check your .NET version:
|
|
208
|
+
\`\`\`bash
|
|
209
|
+
dotnet --version
|
|
210
|
+
\`\`\`
|
|
211
|
+
|
|
212
|
+
- Ensure the path exists strictly; if not, create it first and then run the setup:
|
|
213
|
+
This automatically installs the x64 version of .NET in the specified path. No need to install it from external sources.
|
|
214
|
+
\`\`\`bash
|
|
215
|
+
sudo dotnet browserstack-sdk setup-dotnet --dotnet-path "<your-chosen-path>" --dotnet-version "<your-dotnet-version>"
|
|
216
|
+
\`\`\`
|
|
217
|
+
Common paths: /usr/local/share/dotnet, ~/dotnet-x64, or /opt/dotnet-x64
|
|
218
|
+
|
|
219
|
+
---STEP---
|
|
220
|
+
|
|
221
|
+
Fix for Playwright architecture (macOS only):
|
|
222
|
+
If the folder exists:
|
|
223
|
+
\`<project-folder>/bin/Debug/net8.0/.playwright/node/darwin-arm64\`
|
|
224
|
+
Rename \`darwin-arm64\` to \`darwin-x64\`
|
|
225
|
+
|
|
226
|
+
---STEP---
|
|
227
|
+
|
|
228
|
+
Run the tests:
|
|
229
|
+
- For macOS (Apple Silicon), use the full path:
|
|
230
|
+
\`\`\`bash
|
|
231
|
+
<your-chosen-path>/dotnet browserstack-sdk
|
|
232
|
+
\`\`\`
|
|
233
|
+
- For Windows, Intel Macs, or if dotnet alias is configured:
|
|
234
|
+
\`\`\`bash
|
|
235
|
+
dotnet test
|
|
236
|
+
\`\`\`
|
|
237
|
+
`;
|
|
238
|
+
/**
|
|
239
|
+
* ---------- NODEJS INSTRUCTIONS ----------
|
|
240
|
+
*/
|
|
241
|
+
const nodejsInstructions = `
|
|
242
|
+
---STEP---
|
|
243
|
+
|
|
244
|
+
Ensure \`browserstack-node-sdk\` is present in package.json with the latest version:
|
|
245
|
+
\`\`\`json
|
|
246
|
+
"browserstack-node-sdk": "latest"
|
|
247
|
+
\`\`\`
|
|
248
|
+
|
|
249
|
+
---STEP---
|
|
250
|
+
|
|
251
|
+
Add new scripts to package.json for running tests on BrowserStack:
|
|
252
|
+
\`\`\`json
|
|
253
|
+
"scripts": {
|
|
254
|
+
"test:browserstack": "npx browserstack-node-sdk <framework-specific-test-execution-command>"
|
|
255
|
+
}
|
|
256
|
+
\`\`\`
|
|
257
|
+
|
|
258
|
+
---STEP---
|
|
259
|
+
|
|
260
|
+
Export BrowserStack credentials as environment variables:
|
|
261
|
+
Set the following environment variables before running tests.
|
|
262
|
+
`;
|
|
263
|
+
/**
|
|
264
|
+
* ---------- EXPORT CONFIG ----------
|
|
265
|
+
*/
|
|
266
|
+
const webdriverioInstructions = `
|
|
267
|
+
---STEP---
|
|
268
|
+
|
|
269
|
+
Set BrowserStack Credentials:
|
|
270
|
+
Export your BrowserStack username and access key as environment variables.
|
|
271
|
+
|
|
272
|
+
For macOS/Linux:
|
|
273
|
+
\`\`\`bash
|
|
274
|
+
export BROWSERSTACK_USERNAME= ${config.browserstackUsername}
|
|
275
|
+
export BROWSERSTACK_ACCESS_KEY= ${config.browserstackAccessKey}
|
|
276
|
+
\`\`\`
|
|
277
|
+
|
|
278
|
+
For Windows PowerShell:
|
|
279
|
+
\`\`\`powershell
|
|
280
|
+
$env:BROWSERSTACK_USERNAME=${config.browserstackUsername}
|
|
281
|
+
$env:BROWSERSTACK_ACCESS_KEY=${config.browserstackAccessKey}
|
|
282
|
+
\`\`\`
|
|
283
|
+
|
|
284
|
+
---STEP---
|
|
285
|
+
|
|
286
|
+
Install the BrowserStack WDIO Service:
|
|
287
|
+
Add the service to your project's dev dependencies.
|
|
288
|
+
\`\`\`bash
|
|
289
|
+
npm install @wdio/browserstack-service --save-dev
|
|
290
|
+
\`\`\`
|
|
291
|
+
|
|
292
|
+
---STEP---
|
|
293
|
+
|
|
294
|
+
Update your WebdriverIO Config File (e.g., wdio.conf.js):
|
|
295
|
+
Modify your configuration file to use the BrowserStack service and define the platforms you want to test on.
|
|
296
|
+
|
|
297
|
+
Here is an example configuration:
|
|
298
|
+
|
|
299
|
+
\`\`\`javascript
|
|
300
|
+
exports.config = {
|
|
301
|
+
// Set your BrowserStack credentials
|
|
302
|
+
user: process.env.BROWSERSTACK_USERNAME,
|
|
303
|
+
key: process.env.BROWSERSTACK_ACCESS_KEY,
|
|
304
|
+
|
|
305
|
+
// Set BrowserStack hostname
|
|
306
|
+
hostname: 'hub.browserstack.com',
|
|
307
|
+
|
|
308
|
+
// Add browserstack service
|
|
309
|
+
services: [
|
|
310
|
+
[
|
|
311
|
+
'browserstack',
|
|
312
|
+
{
|
|
313
|
+
// Set to true to test local websites
|
|
314
|
+
browserstackLocal: false,
|
|
315
|
+
// Other service options...
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
],
|
|
319
|
+
|
|
320
|
+
// Define platforms to test on
|
|
321
|
+
capabilities: [
|
|
322
|
+
{
|
|
323
|
+
browserName: 'Chrome',
|
|
324
|
+
'bstack:options': {
|
|
325
|
+
browserVersion: 'latest',
|
|
326
|
+
os: 'Windows',
|
|
327
|
+
osVersion: '11'
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
browserName: 'Safari',
|
|
332
|
+
'bstack:options': {
|
|
333
|
+
browserVersion: 'latest',
|
|
334
|
+
os: 'OS X',
|
|
335
|
+
osVersion: 'Sonoma'
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
],
|
|
339
|
+
|
|
340
|
+
// Set common capabilities for all test environments
|
|
341
|
+
commonCapabilities: {
|
|
342
|
+
'bstack:options': {
|
|
343
|
+
buildName: "my-webdriverio-build",
|
|
344
|
+
buildIdentifier: "#\${BUILD_NUMBER}", // Example for CI
|
|
345
|
+
projectName: "My WebdriverIO Project",
|
|
346
|
+
testObservability: true,
|
|
347
|
+
debug: true, // Enables visual logs
|
|
348
|
+
networkLogs: true, // Enables network logs
|
|
349
|
+
consoleLogs: "info" // Sets console log level
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
|
|
353
|
+
// The number of parallel tests running at the same time
|
|
354
|
+
maxInstances: 5,
|
|
355
|
+
|
|
356
|
+
// ... other wdio configurations
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
// This loop merges commonCapabilities into each capability
|
|
360
|
+
exports.config.capabilities.forEach(function (caps) {
|
|
361
|
+
for (let i in exports.config.commonCapabilities)
|
|
362
|
+
caps[i] = { ...caps[i], ...exports.config.commonCapabilities[i]};
|
|
363
|
+
});
|
|
364
|
+
\`\`\`
|
|
365
|
+
|
|
366
|
+
---STEP---
|
|
367
|
+
|
|
368
|
+
Run your tests:
|
|
369
|
+
You can now run your tests on BrowserStack using your standard WebdriverIO command.
|
|
370
|
+
`;
|
|
371
|
+
const cypressInstructions = `
|
|
372
|
+
---STEP---
|
|
373
|
+
|
|
374
|
+
Install the BrowserStack Cypress CLI:
|
|
375
|
+
Install the CLI as a dev dependency in your project.
|
|
376
|
+
\`\`\`bash
|
|
377
|
+
npm install browserstack-cypress-cli --save-dev
|
|
378
|
+
\`\`\`
|
|
379
|
+
|
|
380
|
+
---STEP---
|
|
381
|
+
|
|
382
|
+
Create the Configuration File:
|
|
383
|
+
Generate the \`browserstack.json\` configuration file in your project's root directory by running the following command:
|
|
384
|
+
\`\`\`bash
|
|
385
|
+
npx browserstack-cypress init
|
|
386
|
+
\`\`\`
|
|
387
|
+
|
|
388
|
+
---STEP---
|
|
389
|
+
|
|
390
|
+
Configure \`browserstack.json\`:
|
|
391
|
+
Open the generated \`browserstack.json\` file and update it with your BrowserStack credentials and desired capabilities. Below is an example configuration.
|
|
392
|
+
|
|
393
|
+
* **auth**: Your BrowserStack username and access key.
|
|
394
|
+
* **browsers**: The list of browser and OS combinations you want to test on.
|
|
395
|
+
* **run_settings**: Project-level settings, including the path to your Cypress config file, build name, and parallels.
|
|
396
|
+
|
|
397
|
+
\`\`\`json
|
|
398
|
+
{
|
|
399
|
+
"auth": {
|
|
400
|
+
"username": "${config.browserstackUsername}",
|
|
401
|
+
"access_key": "${config.browserstackAccessKey}"
|
|
402
|
+
},
|
|
403
|
+
"browsers": [
|
|
404
|
+
{
|
|
405
|
+
"browser": "chrome",
|
|
406
|
+
"os": "Windows 10",
|
|
407
|
+
"versions": ["latest", "latest - 1"]
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
"browser": "firefox",
|
|
411
|
+
"os": "OS X Mojave",
|
|
412
|
+
"versions": ["latest", "latest - 1"]
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
"browser": "edge",
|
|
416
|
+
"os": "OS X Catalina",
|
|
417
|
+
"versions": ["latest"]
|
|
418
|
+
}
|
|
419
|
+
],
|
|
420
|
+
"run_settings": {
|
|
421
|
+
"cypress_config_file": "./cypress.config.js",
|
|
422
|
+
"cypress_version": "12",
|
|
423
|
+
"project_name": "My Cypress Project",
|
|
424
|
+
"build_name": "Build #1",
|
|
425
|
+
"parallels": 5,
|
|
426
|
+
"testObservability": true
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
\`\`\`
|
|
430
|
+
|
|
431
|
+
**Note:** For Cypress v9 or lower, use \`"cypress_config_file": "./cypress.json"\`. The \`testObservability: true\` flag enables the [Test Reporting & Analytics dashboard](https://www.browserstack.com/docs/test-management/test-reporting-and-analytics) for deeper insights into your test runs.
|
|
432
|
+
|
|
433
|
+
---STEP---
|
|
434
|
+
|
|
435
|
+
Run Your Tests on BrowserStack:
|
|
436
|
+
Execute your tests on BrowserStack using the following command:
|
|
437
|
+
\`\`\`bash
|
|
438
|
+
npx browserstack-cypress run --sync
|
|
439
|
+
\`\`\`
|
|
440
|
+
|
|
441
|
+
After the tests complete, you can view the results on your [BrowserStack Automate Dashboard](https://automate.browserstack.com/dashboard/).
|
|
442
|
+
`;
|
|
69
443
|
export const SUPPORTED_CONFIGURATIONS = {
|
|
444
|
+
python: {
|
|
445
|
+
playwright: {
|
|
446
|
+
pytest: { instructions: pythonInstructions },
|
|
447
|
+
},
|
|
448
|
+
selenium: {
|
|
449
|
+
pytest: { instructions: pytestInstructions },
|
|
450
|
+
robot: { instructions: robotInstructions },
|
|
451
|
+
behave: { instructions: behaveInstructions },
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
java: {
|
|
455
|
+
playwright: {
|
|
456
|
+
junit4: { instructions: javaInstructions },
|
|
457
|
+
junit5: { instructions: javaInstructions },
|
|
458
|
+
testng: { instructions: javaInstructions },
|
|
459
|
+
},
|
|
460
|
+
selenium: {
|
|
461
|
+
testng: { instructions: javaInstructions },
|
|
462
|
+
cucumber: { instructions: javaInstructions },
|
|
463
|
+
junit4: { instructions: javaInstructions },
|
|
464
|
+
junit5: { instructions: javaInstructions },
|
|
465
|
+
},
|
|
466
|
+
},
|
|
467
|
+
csharp: {
|
|
468
|
+
playwright: {
|
|
469
|
+
nunit: { instructions: csharpPlaywrightCommonInstructions },
|
|
470
|
+
mstest: { instructions: csharpPlaywrightCommonInstructions },
|
|
471
|
+
},
|
|
472
|
+
selenium: {
|
|
473
|
+
xunit: { instructions: csharpCommonInstructions },
|
|
474
|
+
nunit: { instructions: csharpCommonInstructions },
|
|
475
|
+
mstest: { instructions: csharpCommonInstructions },
|
|
476
|
+
specflow: { instructions: csharpCommonInstructions },
|
|
477
|
+
reqnroll: { instructions: csharpCommonInstructions },
|
|
478
|
+
},
|
|
479
|
+
},
|
|
70
480
|
nodejs: {
|
|
71
481
|
playwright: {
|
|
72
482
|
jest: { instructions: nodejsInstructions },
|
|
@@ -75,29 +485,14 @@ export const SUPPORTED_CONFIGURATIONS = {
|
|
|
75
485
|
},
|
|
76
486
|
selenium: {
|
|
77
487
|
jest: { instructions: nodejsInstructions },
|
|
78
|
-
webdriverio: { instructions:
|
|
488
|
+
webdriverio: { instructions: webdriverioInstructions },
|
|
79
489
|
mocha: { instructions: nodejsInstructions },
|
|
80
490
|
cucumber: { instructions: nodejsInstructions },
|
|
81
491
|
nightwatch: { instructions: nodejsInstructions },
|
|
82
492
|
codeceptjs: { instructions: nodejsInstructions },
|
|
83
493
|
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
playwright: {
|
|
87
|
-
pytest: { instructions: pythonInstructions },
|
|
88
|
-
},
|
|
89
|
-
selenium: {
|
|
90
|
-
pytest: { instructions: pythonInstructions },
|
|
91
|
-
robot: { instructions: pythonInstructions },
|
|
92
|
-
behave: { instructions: pythonInstructions },
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
java: {
|
|
96
|
-
playwright: {},
|
|
97
|
-
selenium: {
|
|
98
|
-
testng: { instructions: javaInstructions },
|
|
99
|
-
cucumber: { instructions: javaInstructions },
|
|
100
|
-
junit: { instructions: javaInstructions },
|
|
494
|
+
cypress: {
|
|
495
|
+
cypress: { instructions: cypressInstructions },
|
|
101
496
|
},
|
|
102
497
|
},
|
|
103
498
|
};
|