diff --git a/README.md b/README.md index 577a8f50..1797c445 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,16 @@ -
+
+ Blog ⋅ Docs @@ -17,19 +25,20 @@
+ -*Learn the how to get started with testing GitHub app integration with SmartUI on the LambdaTest platform.* -[
](https://accounts.lambdatest.com/register?utm_source=github&utm_medium=repo&utm_campaign=playwright-sample)
+*Learn the how to get started with testing GitHub app integration with SmartUI on the LambdaTest platform.*
+[](https://accounts.lambdatest.com/register?utm_source=github&utm_medium=repo&utm_campaign=playwright-sample)
## Table of Contents:
+
* [Pre-requisites](#pre-requisites)
* [Getting Started With Github App Integration with SmartUI](#getting-started-with-github-app-integration-with-smartui)
-
## Pre-requisites
* An account with Github with valid permission to install new applications to your repositories.
@@ -38,7 +47,7 @@
## Getting Started With Github App Integration with SmartUI
-### Steps 1: Integrate the your Lambdatest Account with GitHub App.
+### Steps 1: Integrate the your Lambdatest Account with GitHub App.
You can integrate your LambdaTest account with the GiHub application in the following ways:
@@ -46,8 +55,7 @@ You can integrate your LambdaTest account with the GiHub application in the foll

-
-### Step 2: Select your GitHub repository
+### Step 2: Select your GitHub repository
Go to your GitHub repository where you want to configure your SmartUI project. Check out our GitHub sample [here](https://github.com/LambdaTest/smartui-node-sample).
@@ -55,7 +63,7 @@ Go to your GitHub repository where you want to configure your SmartUI project. C
Add the `Github` capability to your current test configuration:
-```bash
+```bash {"id":"01HWAFWEYGEXVSMJCB2CKFCSDN"}
const capabilities: {
platform: "Windows 10",
browserName: "chrome",
@@ -76,12 +84,14 @@ Setting up your CI workflow to execute on GitHub. Here is an example setup with
Go to `.github/workflows/
](https://accounts.lambdatest.com/register?utm_source=github&utm_medium=repo&utm_campaign=playwright-sample)
-
+
+[](https://accounts.lambdatest.com/register?utm_source=github&utm_medium=repo&utm_campaign=playwright-sample)
+
## We are here to help you :headphones:
* Got a query? we are available 24x7 to help. [Contact Us](mailto:support@lambdatest.com)
* For more info, visit - [LambdaTest](https://www.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=playwright-sample)
-
+
diff --git a/tests/test.js b/tests/test.js
index 71e16666..9c77224a 100644
--- a/tests/test.js
+++ b/tests/test.js
@@ -1,109 +1,149 @@
const webdriver = require("selenium-webdriver");
const By = webdriver.By;
-var moment = require("moment");
-var waitTime = 2 // 2 seconds
+const moment = require("moment");
+
+const waitTime = 2; // 2 seconds
// username: Username can be found at automation dashboard
-const USERNAME = process.env.LT_USERNAME || "username";
+// const USERNAME = process.env.LT_USERNAME || "haiderk";
-// AccessKey: AccessKey can be generated from automation dashboard or profile section
-const KEY = process.env.LT_ACCESS_KEY || "accessKey";
+// AccessKey: AccessKey can be generated from automation dashboard or profile section
+// const KEY = process.env.LT_ACCESS_KEY || "i7vF5r66IYgsgE9Hp5t6hZqd5PkQX021FgpWRC70mp0ShbFh1R";
// gridUrl: gridUrl can be found at automation dashboard
-const GRID_HOST =
-process.env.GRID_HOST || "@hub.lambdatest.com/wd/hub"; //connect to lambdatest hub
+// const GRID_HOST = process.env.GRID_HOST || "@hub.lambdatest.com/wd/hub"; //connect to lambdatest hub
+
+// const GRID_URL = process.env.GRID_URL || "GRID_URL";
+const GRID_URL = "https://haiderk:W0AB7YqcubvLeUNPD65N2XANdVq55VZO8KdmLAEO1fbrSFC97B@stage-hub.lambdatestinternal.com/wd/hub";
+// const GRID_URL = "https://smartui-internal:jNbKw8iwoDlqGuBfIBtd5F1Cnr4A0H07ifYNDGpylobjWyA2QX@stage-hub.lambdatestinternal.com/wd/hub";
+// const GRID_URL = "https://haiderk:i7vF5r66IYgsgE9Hp5t6hZqd5PkQX021FgpWRC70mp0ShbFh1R@hub.lambdatest.com/wd/hub";
+// const GRID_URL = "https://ltgdprhak:1JF7nbtNVDTSFQdstywJQxVqaaIEX87sP7q7ghbFjwpcm5Kbgv@stage-hub-eu.lambdatestinternal.com/wd/hub";
+// const GRID_URL = "https://gdpreu:svffEGGVpCulkAYtaqCRVbHIwrZor4aD0BeF89I3xbaPLTpcXz@hub-eu.lambdatest.com/wd/hub";
+
-const GRID_URL = process.env.GRID_URL || "GRID_URL";
async function searchTextOnGoogle() {
- var keys = process.argv;
+ const keys = process.argv;
console.log(keys);
- let parallelCount = keys[2] || 1;
- let tunnel = keys[3] || false;
- let platform = keys[4] || "Windows 10";
- let browserName = keys[5] || "chrome";
- let version = keys[6] || "latest";
+ const parallelCount = keys[2] || 1;
+ const tunnel = keys[3] || false;
+ const platform = keys[4] || "Windows 10";
+ // const platform = keys[4] || "bigsur";
+ const browserName = keys[5] || "chrome";
+ const version = keys[6] || "latest";
// Setup Input capabilities
- let capabilities = {
+ const capabilities = {
platform: platform,
browserName: browserName,
version: version,
queueTimeout: 300,
visual: true,
- user: USERNAME,
- accessKey: KEY,
+ user: process.env.LT_USERNAME,
+ accessKey: process.env.LT_ACCESS_KEY,
name: "test session", // name of the test
- build: platform + browserName + version, // name of the build
- "smartUI.project": "github-integration-demo",
+ build: `${platform}${browserName}${version}`, // name of the build
+ "smartUI.smartIgnore":true,
+ "smartUI.project": "[Git_Branching#ComparisonStrategy]",
+
+
github: {
url: process.env.GITHUB_URL,
},
- };
+ };
if (tunnel === "true") {
capabilities.tunnel = true;
}
- var gridUrl = GRID_URL;
- console.log("gridUrl : ", gridUrl);
- console.log("GITHUB_REPOSITORY : ", process.env.GITHUB_REPOSITORY);
+ console.log("gridUrl: ", GRID_URL);
+ console.log("GITHUB_REPOSITORY: ", process.env.GITHUB_REPOSITORY);
console.log(capabilities);
- console.log("Running " + parallelCount + " parallel tests ");
- let i = 1;
- for (i = 1; i <= parallelCount; i++) {
- startTest(gridUrl, capabilities, "Test " + i);
+ console.log(`Running ${parallelCount} parallel tests`);
+
+ for (let i = 1; i <= parallelCount; i++) {
+ startTest(GRID_URL, capabilities, `Test ${i}`);
}
}
-
-searchTextOnGoogle();
-
async function startTest(gridUrl, capabilities, name) {
- const caps = capabilities;
- var start_date = moment();
-
- const driver = await new webdriver.Builder()
- .usingServer(gridUrl)
- .withCapabilities(caps)
- .build();
-
- var end_date = moment();
- var duration = moment.duration(end_date.diff(start_date));
- console.log(caps.name, " : Setup Time :", duration.asSeconds());
-
- // navigate to a url
- let url = "https://www.lambdatest.com";
- url = "https://www.lambdatest.com/enterprise";
- console.log(url);
- await driver
- .get(url)
- .then(function () {
- const session = driver.getSession();
-
- // For Smartui TakeScreenshot
- setTimeout(function () {
- console.log("taking screenshot ...")
- driver.executeScript(`smartui.takeScreenshot,{"screenshotName":"sample-screenshot"}`).then(out => {
- console.log("RESPONSE :", out)
- return
+ const caps = { ...capabilities, name };
+
+ try {
+ const start_date = moment();
+
+ const driver = await new webdriver.Builder()
+ .usingServer(gridUrl)
+ .withCapabilities(caps)
+ .build();
+
+ const end_date = moment();
+ const duration = moment.duration(end_date.diff(start_date));
+ console.log(`${caps.name} : Setup Time: ${duration.asSeconds()} seconds`);
+
+ // const url = "https://www.lambdatest.com/";
+ // const url = "https://www.flipkart.com/";
+ const url = "https://www.samsung.com/";
+ console.log(url);
+ await driver.get(url);
+
+ console.log("taking screenshot ...");
+ setTimeout(() => {
+ driver.executeScript(`smartui.takeScreenshot=TEST`).then(() => {
+
+ driver.executeScript(`smartui.fetchScreenshotStatus=TEST`).then(out => {
+ console.log("response:", out);
+ }).catch(err => {
+ console.error("Error fetching screenshot status:", err);
});
- }, waitTime * 1000);
-
-
- driver.getTitle().then(function (title) {
- setTimeout(function () {
- driver.executeScript("lambda-status=passed");
+ }).catch(err => {
+ console.error("Error taking screenshot:", err);
+ });
+ }, waitTime * 1000);
+
+ driver.getTitle().then(function (title) {
+ console.log("Title:", title);
+ setTimeout(function () {
+ driver.executeScript("lambda-status=passed").then(() => {
driver.quit();
- }, 15000);
+ }).catch(err => {
+ console.error("Error setting lambda status to passed:", err);
+ driver.quit();
+ });
+ }, 15000);
+ }).catch(err => {
+ console.error("Error getting title:", err);
+ driver.executeScript("lambda-status=failed").then(() => {
+ driver.quit();
+ }).catch(scriptError => {
+ console.error("Failed to set lambda status:", scriptError);
+ driver.quit();
});
- })
- .catch(function (err) {
- error = JSON.stringify(err);
- console.log(error);
- console.log("test failed with reason " + err);
- driver.executeScript("lambda-status=failed");
- driver.quit();
});
+ } catch (err) {
+ console.error("Test failed with reason:", err);
+ try {
+ await driver.executeScript("lambda-status=failed");
+ } catch (scriptError) {
+ console.error("Failed to set lambda status:", scriptError);
+ }
+ await driver.quit();
+ }
}
+searchTextOnGoogle();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+