Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/lib/version-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ export function resolveVersion(requested: string, available: string[]): string {
return requested;
}

const caseInsensitiveMatch = uniq.find(
(v) => v.toLowerCase() === requested.toLowerCase(),
);
if (caseInsensitiveMatch) {
return caseInsensitiveMatch;
}

// Try major version matching (e.g., "14" matches "14.0", "14.1", etc.)
const reqNum = parseFloat(requested);
if (!isNaN(reqNum)) {
Expand Down
6 changes: 3 additions & 3 deletions src/tools/automate-utils/fetch-screenshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ async function convertUrlsToBase64(
): Promise<Array<{ url: string; base64: string }>> {
const screenshots = await Promise.all(
urls.map(async (url) => {
const response = await apiClient.get({
url,
responseType: "arraybuffer"
const response = await apiClient.get({
url,
responseType: "arraybuffer",
});
// Axios returns response.data as a Buffer for binary data
const base64 = Buffer.from(response.data).toString("base64");
Expand Down
12 changes: 11 additions & 1 deletion src/tools/sdk-utils/bstack/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ Alternative setup for Gradle users:
${GRADLE_SETUP_INSTRUCTIONS}`;
}

function getPythonSDKInstructions(username: string, accessKey: string): string {
return `---STEP---
Install BrowserStack Python SDK and setup:
\`\`\`bash
pip install browserstack-sdk
browserstack-sdk setup --username "${username}" --key "${accessKey}"
\`\`\``;
}

// Main function to get SDK setup commands based on language and framework
export function getSDKPrefixCommand(
language: SDKSupportedLanguage,
Expand All @@ -112,7 +121,8 @@ export function getSDKPrefixCommand(

case "java":
return getJavaSDKInstructions(framework, username, accessKey);

case "python":
return getPythonSDKInstructions(username, accessKey);
default:
return "";
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/sdk-utils/bstack/configUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function generateBrowserStackYMLInstructions(config: {
const platformConfigs = generatePlatformConfigs(config);

const stepTitle =
"Create a browserstack.yml file in the project root with your validated device configurations:";
"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.";

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

Expand Down
25 changes: 8 additions & 17 deletions src/tools/sdk-utils/bstack/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,35 @@ import { ConfigMapping } from "../common/types.js";
* ---------- PYTHON INSTRUCTIONS ----------
*/

export const pythonInstructions = (username: string, accessKey: string) => {
export const pythonInstructions = () => {
const setup = `
---STEP---

Install the BrowserStack SDK:
\`\`\`bash
python3 -m pip install browserstack-sdk
\`\`\`

---STEP---

Setup the BrowserStack SDK with your credentials:
\`\`\`bash
browserstack-sdk setup --username "${username}" --key "${accessKey}"
\`\`\`
`;

const run = `
---STEP---

Run your tests on BrowserStack:
\`\`\`bash
browserstack-sdk python <path-to-test-file>
browserstack-sdk pytest -s tests/<example_test>.py
\`\`\`

Or run all tests in a directory:
\`\`\`bash
browserstack-sdk pytest <path-to-test-directory>
\`\`\`
`;

return { setup, run };
};

export const generatePythonFrameworkInstructions =
(framework: string) => (username: string, accessKey: string) => {
(framework: string) => () => {
const setup = `
---STEP---

Expand All @@ -43,13 +41,6 @@ Install the BrowserStack SDK:
\`\`\`bash
python3 -m pip install browserstack-sdk
\`\`\`

---STEP---

Setup the BrowserStack SDK with framework-specific configuration:
\`\`\`bash
browserstack-sdk setup --framework "${framework}" --username "${username}" --key "${accessKey}"
\`\`\`
`;

const run = `
Expand Down
8 changes: 8 additions & 0 deletions src/tools/sdk-utils/common/device-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,14 @@ export async function validateDevices(
validatedEnvironments.push(validatedEnv);
}

if (framework === SDKSupportedBrowserAutomationFrameworkEnum.playwright) {
validatedEnvironments.forEach((env) => {
if (env.browser) {
env.browser = env.browser.toLowerCase();
}
});
}

return validatedEnvironments;
}

Expand Down