Skip to content

Commit b745d0b

Browse files
feat: add error handling for Percy support and include C# Selenium instructions
1 parent dad3ac8 commit b745d0b

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

src/tools/bstack-sdk.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ export async function bootstrapProjectWithSDK({
5555
);
5656
if (percyInstructions) {
5757
instructions += formatPercyInstructions(percyInstructions);
58+
} else {
59+
throw new Error(
60+
`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.`,
61+
);
5862
}
5963
}
6064
return {
@@ -91,7 +95,9 @@ export async function bootstrapProjectWithSDK({
9195
if (percyInstructions) {
9296
fullInstructions += formatPercyInstructions(percyInstructions);
9397
} else {
94-
fullInstructions += `\n\nNote: Percy SDK instructions for ${detectedLanguage} with ${detectedTestingFramework} are not yet available through this tool. Please refer to the official BrowserStack Percy documentation.`;
98+
throw new Error(
99+
`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.`,
100+
);
95101
}
96102
}
97103

src/tools/sdk-utils/percy/constants.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,38 @@ describe("My WebdriverIO Test", () => {
110110
\`\`\`
111111
`;
112112

113+
const csharpSeleniumInstructions = `
114+
To manually capture screenshots alongside the auto mode, implement the following steps in your test script:
115+
116+
1. **Import the BrowserStack Percy SDK** in your test script.
117+
2. Add the \`PercySDK.Screenshot(driver, name)\` method at required points in your test script to get the screenshots you want.
118+
119+
Here's an example:
120+
121+
\`\`\`csharp
122+
using BrowserStackSDK.Percy;
123+
using NUnit.Framework;
124+
125+
namespace Tests;
126+
127+
public class MyTest
128+
{
129+
[Test]
130+
public void SampleTest()
131+
{
132+
// your test logic
133+
// ...
134+
135+
// Capture a Percy screenshot
136+
PercySDK.Screenshot(driver, "Screenshot name");
137+
138+
// ...
139+
// more test logic
140+
}
141+
}
142+
\`\`\`
143+
`;
144+
113145
export const PERCY_INSTRUCTIONS: PercyConfigMapping = {
114146
java: {
115147
selenium: {
@@ -119,6 +151,11 @@ export const PERCY_INSTRUCTIONS: PercyConfigMapping = {
119151
junit5: { script_updates: javaSeleniumInstructions },
120152
},
121153
},
154+
csharp: {
155+
selenium: {
156+
nunit: { script_updates: csharpSeleniumInstructions },
157+
},
158+
},
122159
nodejs: {
123160
selenium: {
124161
mocha: {

0 commit comments

Comments
 (0)