id | title | hide_title | sidebar_label | description | keywords | url | site_name | slug | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
hyperexecute-smart-ui-testing-using-selenium |
Smart UI Testing Using HyperExecute |
true |
Using Selenium |
Accelerate bug identification with HyperExecute's intelligent UI testing via Selenium. Conduct Visual UI Regression Testing for flawless application deployment. |
|
LambdaTest |
hyperexecute-smart-ui-testing-using-selenium/ |
Smart UI Testing is a powerful tool that enables you to execute regression testing effortlessly and identify Visual UI Regression bugs with ease. This guide will walk you through the process of running Smart UI tests on the HyperExecute platform
-
LambdaTest Authentication Credentials
- Keep your LambdaTest login, access key, and HubURL handy for authentication purposes. They must be configured as environment variables. You can find them on your LambdaTest automation dashboard by clicking on the key symbol next to the help button.
-
Basic understanding of Selenium and WebDriver is required.
-
To run Smart UI tests, you need to have a Baseline Image and a Comparison image. A baseline image is the reference image with which you want to compare. You can either upload this image from your computer or take a screenshot from your browser.
To get started with Smart UI testing, you need to create a project that will consolidate all your builds for testing. Follow these steps to set up your SmartUI Project:
- Go to LambdaTest SmartUI Dashboard
- Click on "Create a new project"
- Select the Platform either Web or Real Devices. For this demo we are selecting Web.
- Provide the Project Name, Approvers for the changes found, and Tags for any filter or easy navigation.
- Click on the Create Button.
Once you have created a SmartUI Project, you can generate screenshots by running automation scripts. Follow the below steps to successfully generate screenshots -
- Clone the sample repository
:::tip Sample repo
All the code samples in this documentation can be found on LambdaTest's Github Repository. You can either download or clone the repository to quickly run your tests. <img loading="lazy" src={require('../assets/images/icons/github.png').default} alt="Image" className="doc_img"/> View on GitHub
:::
- Run the below mentioned commands in the terminal to setup the environment variables.
For macOS / Linux:
export LT_USERNAME=YOUR_LT_USERNAME
export LT_ACCESS_KEY=YOUR_LT_ACCESS_KEY
For Windows:
set LT_USERNAME=YOUR_LT_USERNAME
set LT_ACCESS_KEY=YOUR_LT_ACCESS_KEY
-
Configure your Test Environment by following the instructions mentioned in the README.md file.
-
Edit the required capabilities for your test suite. Replace the capabilities in your Remote WebDriver DesiredCapabilities configuration with the appropriate values.
let capabilities = {
platform: "Windows 10", // Configure your OS for Selenium test
browserName: "chrome", // Configure your Browser for Selenium test
version: "latest", // Configure your Browser Version for Selenium test
visual: true, // Configure your Capture screenshot for Selenium test
name: "test session", // name of the test for Selenium
build: "Automation Build", // name of the build for Selenium
//highlight-next-line
"smartUI.project": "<Your Project Name>", // Replace the name of project with the new project name
};
// Connecting to the Lambdatest Selenium Cloud Grid with Smart UI (Beta)
// Enter your UserName and Access Key
let gridUrl =
"https://" +
//highlight-next-line
"<Your Username>" +
":" +
//highlight-next-line
"<Your Access Key>" +
`@beta-hub.lambdatest.com/wd/hub`;
// Here is your Remote WebDrive Connection
let driver = await new webdriver.Builder()
.usingServer(gridUrl)
.withCapabilities(capabilities)
.build();
- Webhook for taking screenshot -
driver.executeScript("smartui.takeScreenshot");
- Installing dependency and for executing the test.
$ npm i
$ node test.js
Once the test is executed, you can check the results at LambdaTest SmartUI. Make all the desired changes, re-run your tests and then re-visit the Dashboard and check your Baseline Screenshot as well as Comparable Screenshot
<img loading="lazy" src={require('../assets/images/hyperexecute/integration/lt-products/smart-ui/selenium/smart-ui-3.webp').default} alt="cmd" width="768" height="373" className="doc_img"/>
Here you can see the difference.
<img loading="lazy" src={require('../assets/images/hyperexecute/integration/lt-products/smart-ui/selenium/smart-ui-4.webp').default} alt="cmd" width="768" height="373" className="doc_img"/>
For any websites that provide a scrolling feature on their application user interface, you can take a screenshot of the entire page. You can capture full page screenshot for your Selenium functional testing with the section of code below:
driver.executeScript("smartui.takeFullPageScreenshot");
This section of code must be attached below the relevant portion of the Selenium script from which the screenshot will be taken.
driver.executeScript("smartui.takeScreenshot");
This section of code should be used to configure your Smart UI test with the host
const GRID_HOST = "@beta-hub.lambdatest.com/wd/hub";
Key | Description |
---|---|
transparency |
Command to adjust test transparency settings |
largeImageThreshold |
Command to set the threshold value for the comparison output |
BoundingBoxes: [box1, box2] |
Command to narrow down the area of comparison by specifying a bounding box measured in pixels from the top left |
ignoredBoxes: [box1, box2] |
Command to exclude part of the image from comparison, by specifying the excluded area in pixels from the top left |
ignoredAreasColoredWith: color |
Command to exclude pixels that match the specific color on a reference image from comparison |