Skip to content

Commit 1faef7d

Browse files
authored
Merge pull request #2 from Saurabh-LT/parameterisedSDKCloud
Create parameterisedSDKCloud.js
2 parents eeec5ef + 0337f9b commit 1faef7d

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

sdk/parameterisedSDKCloud.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const { chromium } = require("playwright");
2+
const { expect } = require("@playwright/test");
3+
const smartuiSnapshot = require("@lambdatest/playwright-driver");
4+
5+
6+
// username: Username can be found at automation dashboard
7+
const USERNAME = process.env.LT_USERNAME || "<USERNAME>";
8+
9+
// AccessKey: AccessKey can be generated from automation dashboard or profile section
10+
const KEY = process.env.LT_ACCESS_KEY || "<ACCESS_KEY>";
11+
12+
// export BROWSER_NAME=pw-webkit | export BROWSER_NAME=pw-firefox | export BROWSER_NAME=MicrosoftEdge | export BROWSER_NAME=Chrome | export BROWSER_NAME=pw-chromium
13+
const BROWSER_NAME = process.env.BROWSER_NAME || "Chrome";
14+
15+
16+
(async () => {
17+
const capabilities = {
18+
browserName: BROWSER_NAME,
19+
browserVersion: "latest",
20+
"LT:Options": {
21+
platform: "Windows 10",
22+
build: "Playwright SmartUI Build",
23+
name: "Playwright SmartUI Test " + BROWSER_NAME,
24+
user: USERNAME,
25+
accessKey: KEY,
26+
network: true,
27+
video: true,
28+
console: true,
29+
},
30+
};
31+
32+
const githubURL = process.env.GITHUB_URL;
33+
if (githubURL) {
34+
capabilities["LT:Options"]["github"] = {
35+
url: githubURL,
36+
};
37+
}
38+
39+
const browser = await chromium.connect({
40+
wsEndpoint: `wss://cdp.lambdatest.com/playwright?capabilities=${encodeURIComponent(
41+
JSON.stringify(capabilities)
42+
)}`,
43+
});
44+
45+
const page = await browser.newPage();
46+
47+
await page.goto("https://www.lambdatest.com");
48+
49+
// Add the following command in order to take screenshot in SmartUI
50+
await smartuiSnapshot.smartuiSnapshot(page, "LT-Home");
51+
await browser.close();
52+
})();

0 commit comments

Comments
 (0)