Skip to content

parameterisedSDKCloud #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 17, 2024
Merged
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
52 changes: 52 additions & 0 deletions sdk/parameterisedSDKCloud.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const { chromium } = require("playwright");
const { expect } = require("@playwright/test");
const smartuiSnapshot = require("@lambdatest/playwright-driver");


// username: Username can be found at automation dashboard
const USERNAME = process.env.LT_USERNAME || "<USERNAME>";

// AccessKey: AccessKey can be generated from automation dashboard or profile section
const KEY = process.env.LT_ACCESS_KEY || "<ACCESS_KEY>";

// export BROWSER_NAME=pw-webkit | export BROWSER_NAME=pw-firefox | export BROWSER_NAME=MicrosoftEdge | export BROWSER_NAME=Chrome | export BROWSER_NAME=pw-chromium
const BROWSER_NAME = process.env.BROWSER_NAME || "Chrome";


(async () => {
const capabilities = {
browserName: BROWSER_NAME,
browserVersion: "latest",
"LT:Options": {
platform: "Windows 10",
build: "Playwright SmartUI Build",
name: "Playwright SmartUI Test " + BROWSER_NAME,
user: USERNAME,
accessKey: KEY,
network: true,
video: true,
console: true,
},
};

const githubURL = process.env.GITHUB_URL;
if (githubURL) {
capabilities["LT:Options"]["github"] = {
url: githubURL,
};
}

const browser = await chromium.connect({
wsEndpoint: `wss://cdp.lambdatest.com/playwright?capabilities=${encodeURIComponent(
JSON.stringify(capabilities)
)}`,
});

const page = await browser.newPage();

await page.goto("https://www.lambdatest.com");

// Add the following command in order to take screenshot in SmartUI
await smartuiSnapshot.smartuiSnapshot(page, "LT-Home");
await browser.close();
})();