|
| 1 | +const { Builder, By, Key, until } = require('selenium-webdriver'); |
| 2 | +const assert = require('assert'); |
| 3 | +const { smartuiSnapshot } = require('@lambdatest/selenium-driver'); |
| 4 | + |
| 5 | +// username: Username can be found at automation dashboard |
| 6 | +const USERNAME = process.env.LT_USERNAME || "<USERNAME>"; |
| 7 | + |
| 8 | +// AccessKey: AccessKey can be generated from automation dashboard or profile section |
| 9 | +const KEY = process.env.LT_ACCESS_KEY || "<ACCESS_KEY>"; |
| 10 | +let capabilities = { |
| 11 | + platform: "catalina", |
| 12 | + browserName: "chrome", |
| 13 | + version: "latest", |
| 14 | + "LT:Options": { |
| 15 | + username: USERNAME, |
| 16 | + accessKey: KEY, |
| 17 | + project: "<PROJECT_NAME>", |
| 18 | + w3c: true, |
| 19 | + name: "<TEST_NAME>", // name of the test |
| 20 | + build: "<BUILD_NAME", // name of the build |
| 21 | + visual: true, |
| 22 | + }, |
| 23 | +}; |
| 24 | + |
| 25 | +(async function example() { |
| 26 | + // Setup Input capabilities |
| 27 | + var gridUrl = |
| 28 | + "https://" + USERNAME + ":" + KEY + "@hub.lambdatest.com/wd/hub"; |
| 29 | + |
| 30 | + let driver = await new Builder() |
| 31 | + .usingServer(gridUrl) |
| 32 | + .withCapabilities(capabilities) |
| 33 | + .build(); |
| 34 | + driver.manage().window().fullscreen(); |
| 35 | + try { |
| 36 | + await driver.get("https://www.lambdatest.com/visual-regression-testing"); |
| 37 | + let options = { |
| 38 | + 'sync': true |
| 39 | + } |
| 40 | + let response = await smartuiSnapshot(driver, "LT-SmartUI",options); // Capture Screenshot |
| 41 | + assert.equal(response.snapshotName,'LT-SmartUI'); |
| 42 | + assert.equal(response.error,''); |
| 43 | + assert.equal(response.screenshots.length,14); |
| 44 | + } finally { |
| 45 | + await driver.quit(); |
| 46 | + } |
| 47 | +})(); |
0 commit comments