Skip to content

Commit 8a41b1d

Browse files
Merge pull request #23 from sushobhit-lt/main
add parallel config sample
2 parents b7c744a + 0ee3a58 commit 8a41b1d

File tree

3 files changed

+118
-1
lines changed

3 files changed

+118
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"scripts": {
1313
"start": "node ./tests/generalCases/index.js",
1414
"test": "node ./tests/generalCases/test.js",
15-
"multiple": "node ./tests/generalCases/multiple-urls/multiple-url-tests-sample.js"
15+
"multiple": "node ./tests/generalCases/multiple-urls/multiple-url-tests-sample.js",
16+
"multiple-config": "node ./tests/generalCases/multiple-urls/parallel-config-sample.js"
1617
},
1718
"repository": {
1819
"type": "git",
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
const webdriver = require("selenium-webdriver");
2+
const automationConfig = require("./parallel-config.json");
3+
const smartUITests = require("./urls.json");
4+
5+
// USERNAME: Username can be found at automation dashboard
6+
const USERNAME = process.env.LT_USERNAME || "<Your_Username>";
7+
8+
// KEY: AccessKey can be generated from automation dashboard or profile section
9+
const KEY = process.env.LT_ACCESS_KEY || "<Your_Access_key>";
10+
11+
//connect to Lambdatest hub
12+
const GRID_HOST = process.env.GRID_HOST || "@hub.lambdatest.com/wd/hub";
13+
14+
const gridUrl = "https://" + USERNAME + ":" + KEY + GRID_HOST;
15+
16+
// Selenium WebDriver Function
17+
18+
async function runSmartUIonLambdatest() {
19+
// Lambdatest Cloud Selenium Grid Connection
20+
21+
// Printing the Lambdatest Cloud Information for the test
22+
23+
console.log("Please visit https://smartui.lambdatest.com to see your SmartUI - Visual Regression Tests");
24+
const smartuiBuild = "smartui-build-"+ (Math.random() + 1).toString(36).substring(7);
25+
console.log("smartuiBuild", smartuiBuild);
26+
try {
27+
automationConfig.forEach(async (config) => {
28+
console.log("########################")
29+
config["smartUI.build"] = smartuiBuild
30+
console.log(config)
31+
const driver = await new webdriver.Builder()
32+
.usingServer(gridUrl)
33+
.withCapabilities(config)
34+
.build();
35+
try {
36+
smartUITests.forEach((smartUITest) => {
37+
console.log("Opening URL ")
38+
console.log(smartUITest)
39+
let smartUI_ScreenshotName = smartUITest.screenshotName;
40+
let smartUI_url = smartUITest.url;
41+
smartUISeleniumTest(driver, smartUI_url, smartUI_ScreenshotName);
42+
});
43+
} catch (err) {
44+
console.log(err);
45+
}
46+
// Closing the Browser Session
47+
await driver.executeScript("lambda-status=passed");
48+
await driver.quit();
49+
});
50+
} catch (err) {
51+
console.log(JSON.stringify(err));
52+
await driver.executeScript("lambda-status=failed");
53+
}
54+
}
55+
56+
async function smartUISeleniumTest(driver, url, screenshotName) {
57+
await driver
58+
.get(url)
59+
.then(() => {
60+
// For Smartui TakeScreenshot
61+
console.log(`Capturing the Screenshot Name: ${screenshotName} | URL: ${url}`);
62+
driver
63+
.executeScript(`smartui.takeScreenshot=${screenshotName}`)
64+
.then((result) => {
65+
console.log("Result :", result);
66+
});
67+
})
68+
.catch((err) => {
69+
console.log(err);
70+
});
71+
}
72+
73+
// Executing the tests in parallel of multiple urls
74+
runSmartUIonLambdatest();
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[
2+
{
3+
"platform": "Windows 10",
4+
"browserName": "chrome",
5+
"version": "latest",
6+
"visual": "true",
7+
"name": "SmartUi Transparency Test",
8+
"build": "Smart Ui Transparency Build",
9+
"smartUI.project": "SmartUI Nodejs Sample Project",
10+
"selenium_version": "4.0.0"
11+
},
12+
{
13+
"platform": "Windows 10",
14+
"browserName": "firefox",
15+
"version": "latest",
16+
"visual": "true",
17+
"name": "SmartUi Transparency Test",
18+
"build": "Smart Ui Transparency Build",
19+
"smartUI.project": "SmartUI Nodejs Sample Project",
20+
"selenium_version": "4.0.0"
21+
},
22+
{
23+
"platform": "ventura",
24+
"browserName": "safari",
25+
"version": "latest",
26+
"visual": "true",
27+
"name": "SmartUi Transparency Test",
28+
"build": "Smart Ui Transparency Build",
29+
"smartUI.project": "SmartUI Nodejs Sample Project",
30+
"selenium_version": "4.0.0"
31+
},
32+
{
33+
"platform": "ventura",
34+
"browserName": "edge",
35+
"version": "latest",
36+
"visual": "true",
37+
"name": "SmartUi Transparency Test",
38+
"build": "Smart Ui Transparency Build",
39+
"smartUI.project": "SmartUI Nodejs Sample Project",
40+
"selenium_version": "4.0.0"
41+
}
42+
]

0 commit comments

Comments
 (0)