Skip to content

Commit 0ea6358

Browse files
Merge pull request #162 from tech-sushant/playwright-instruction
fix: Update playwright instruction
2 parents a8929a0 + d1f4a99 commit 0ea6358

File tree

6 files changed

+38
-22
lines changed

6 files changed

+38
-22
lines changed

src/lib/version-resolver.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ export function resolveVersion(requested: string, available: string[]): string {
2727
return requested;
2828
}
2929

30+
const caseInsensitiveMatch = uniq.find(
31+
(v) => v.toLowerCase() === requested.toLowerCase(),
32+
);
33+
if (caseInsensitiveMatch) {
34+
return caseInsensitiveMatch;
35+
}
36+
3037
// Try major version matching (e.g., "14" matches "14.0", "14.1", etc.)
3138
const reqNum = parseFloat(requested);
3239
if (!isNaN(reqNum)) {

src/tools/automate-utils/fetch-screenshots.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ async function convertUrlsToBase64(
5959
): Promise<Array<{ url: string; base64: string }>> {
6060
const screenshots = await Promise.all(
6161
urls.map(async (url) => {
62-
const response = await apiClient.get({
63-
url,
64-
responseType: "arraybuffer"
62+
const response = await apiClient.get({
63+
url,
64+
responseType: "arraybuffer",
6565
});
6666
// Axios returns response.data as a Buffer for binary data
6767
const base64 = Buffer.from(response.data).toString("base64");

src/tools/sdk-utils/bstack/commands.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ Alternative setup for Gradle users:
9999
${GRADLE_SETUP_INSTRUCTIONS}`;
100100
}
101101

102+
function getPythonSDKInstructions(username: string, accessKey: string): string {
103+
return `---STEP---
104+
Install BrowserStack Python SDK and setup:
105+
\`\`\`bash
106+
pip install browserstack-sdk
107+
browserstack-sdk setup --username "${username}" --key "${accessKey}"
108+
\`\`\``;
109+
}
110+
102111
// Main function to get SDK setup commands based on language and framework
103112
export function getSDKPrefixCommand(
104113
language: SDKSupportedLanguage,
@@ -112,7 +121,8 @@ export function getSDKPrefixCommand(
112121

113122
case "java":
114123
return getJavaSDKInstructions(framework, username, accessKey);
115-
124+
case "python":
125+
return getPythonSDKInstructions(username, accessKey);
116126
default:
117127
return "";
118128
}

src/tools/sdk-utils/bstack/configUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function generateBrowserStackYMLInstructions(config: {
1313
const platformConfigs = generatePlatformConfigs(config);
1414

1515
const stepTitle =
16-
"Create a browserstack.yml file in the project root with your validated device configurations:";
16+
"Create a browserstack.yml file in the project root with your validated device configurations:If already exists, update it with the following content for devices and project details.";
1717

1818
const buildName = `${projectName}-Build`;
1919

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

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,35 @@ import { ConfigMapping } from "../common/types.js";
44
* ---------- PYTHON INSTRUCTIONS ----------
55
*/
66

7-
export const pythonInstructions = (username: string, accessKey: string) => {
7+
export const pythonInstructions = () => {
88
const setup = `
99
---STEP---
1010
1111
Install the BrowserStack SDK:
1212
\`\`\`bash
1313
python3 -m pip install browserstack-sdk
1414
\`\`\`
15-
16-
---STEP---
17-
18-
Setup the BrowserStack SDK with your credentials:
19-
\`\`\`bash
20-
browserstack-sdk setup --username "${username}" --key "${accessKey}"
21-
\`\`\`
2215
`;
2316

2417
const run = `
2518
---STEP---
2619
2720
Run your tests on BrowserStack:
2821
\`\`\`bash
29-
browserstack-sdk python <path-to-test-file>
22+
browserstack-sdk pytest -s tests/<example_test>.py
23+
\`\`\`
24+
25+
Or run all tests in a directory:
26+
\`\`\`bash
27+
browserstack-sdk pytest <path-to-test-directory>
3028
\`\`\`
3129
`;
3230

3331
return { setup, run };
3432
};
3533

3634
export const generatePythonFrameworkInstructions =
37-
(framework: string) => (username: string, accessKey: string) => {
35+
(framework: string) => () => {
3836
const setup = `
3937
---STEP---
4038
@@ -43,13 +41,6 @@ Install the BrowserStack SDK:
4341
\`\`\`bash
4442
python3 -m pip install browserstack-sdk
4543
\`\`\`
46-
47-
---STEP---
48-
49-
Setup the BrowserStack SDK with framework-specific configuration:
50-
\`\`\`bash
51-
browserstack-sdk setup --framework "${framework}" --username "${username}" --key "${accessKey}"
52-
\`\`\`
5344
`;
5445

5546
const run = `

src/tools/sdk-utils/common/device-validator.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,14 @@ export async function validateDevices(
316316
validatedEnvironments.push(validatedEnv);
317317
}
318318

319+
if (framework === SDKSupportedBrowserAutomationFrameworkEnum.playwright) {
320+
validatedEnvironments.forEach((env) => {
321+
if (env.browser) {
322+
env.browser = env.browser.toLowerCase();
323+
}
324+
});
325+
}
326+
319327
return validatedEnvironments;
320328
}
321329

0 commit comments

Comments
 (0)