|
| 1 | +--- |
| 2 | +id: kaneai-smartui-visual-testing |
| 3 | +title: Visual Regression Testing |
| 4 | +hide_title: false |
| 5 | +sidebar_label: Visual Testing |
| 6 | +description: A step-by-step guide on using KaneAI to automate visual regression tests. Learn to capture screenshots, establish baselines, compare visual changes with SmartUI, and schedule automated runs. |
| 7 | +keywords: |
| 8 | + - lambdatest kaneai |
| 9 | + - kaneai |
| 10 | + - smartui |
| 11 | + - visual testing |
| 12 | + - visual regression |
| 13 | + - automation |
| 14 | +url: https://www.lambdatest.com/support/docs/kaneai-smartui-visual-testing |
| 15 | +site_name: LambdaTest |
| 16 | +slug: kaneai-smartui-visual-testing/ |
| 17 | +--- |
| 18 | + |
| 19 | +import Tabs from '@theme/Tabs'; |
| 20 | +import TabItem from '@theme/TabItem'; |
| 21 | + |
| 22 | +<script type="application/ld+json" |
| 23 | + dangerouslySetInnerHTML={{ __html: JSON.stringify({ |
| 24 | + "@context": "https://schema.org", |
| 25 | + "@type": "BreadcrumbList", |
| 26 | + "itemListElement": [{ |
| 27 | + "@type": "ListItem", |
| 28 | + "position": 1, |
| 29 | + "name": "Home", |
| 30 | + "item": "https://www.lambdatest.com" |
| 31 | + },{ |
| 32 | + "@type": "ListItem", |
| 33 | + "position": 2, |
| 34 | + "name": "Support", |
| 35 | + "item": "https://www.lambdatest.com/support/docs/" |
| 36 | + },{ |
| 37 | + "@type": "ListItem", |
| 38 | + "position": 3, |
| 39 | + "name": "Visual Regression Testing with KaneAI and SmartUI", |
| 40 | + "item": "https://www.lambdatest.com/support/docs/kaneai-smartui-visual-testing" |
| 41 | + }] |
| 42 | + }) |
| 43 | + }} |
| 44 | +></script> |
| 45 | + |
| 46 | +This guide provides a detailed walkthrough on how to leverage KaneAI to create, manage, and automate visual regression tests. By integrating with SmartUI, you can capture screenshots, compare visual changes, and maintain UI consistency throughout your development lifecycle. |
| 47 | + |
| 48 | +## Creating Your First Visual Test |
| 49 | + |
| 50 | +### Step 1: Initiate a Web Test |
| 51 | +To begin, navigate to the [KaneAI dashboard](https://kaneai.lambdatest.com/dashboard) and click **Create a Web Test**. You can configure network settings before clicking **Start Testing** to launch the test authoring environment. |
| 52 | + |
| 53 | + |
| 54 | +<img loading="lazy" src={require('../assets/images/kane-ai/smartui/initiate-web-test.png').default} alt="Initiate a Web Test in KaneAI" className="doc_img"/> |
| 55 | + |
| 56 | +### Step 2: Add a Visual Comparison Step |
| 57 | +Author your test by writing steps in plain language, such as `go to lambdatest`. |
| 58 | + |
| 59 | +<img loading="lazy" src={require('../assets/images/kane-ai/smartui/kane-dashboard.jpeg').default} alt="KaneAI Dashboard" className="doc_img"/> |
| 60 | + |
| 61 | + To add a visual test step, type `/` in the "Write a step" editor and select **Visual Comparison** from the command menu. |
| 62 | + |
| 63 | +<img loading="lazy" src={require('../assets/images/kane-ai/smartui/add-visual-comparison-step.jpeg').default} alt="Add Visual Comparison Step" className="doc_img"/> |
| 64 | + |
| 65 | +### Step 3: Configure Your Screenshot |
| 66 | +A configuration modal will appear for your screenshot. |
| 67 | +* **Screenshot Name (Required):** You must provide a descriptive name for the screenshot. |
| 68 | +* **Mis-Match Threshold (Optional):** Set an acceptable percentage of difference below which changes are auto-approved. The default is 0%. |
| 69 | +* **Screenshot Type (Optional):** Choose between **View Port** (default) or **Full Page**. |
| 70 | + |
| 71 | +Click **Create** to add the step to your test flow. |
| 72 | + |
| 73 | +<img loading="lazy" src={require('../assets/images/kane-ai/smartui/configure-screenshot.png').default} alt="Configure Screenshot Settings" className="doc_img"/> |
| 74 | + |
| 75 | +## Analyzing Baselines and Regressions |
| 76 | + |
| 77 | +### Step 4: Establish the Baseline |
| 78 | +The first time the test is executed, it captures an initial screenshot that becomes the **Baseline** for all future comparisons. You can view this image by clicking **Show Baseline**. |
| 79 | + |
| 80 | +<img loading="lazy" src={require('../assets/images/kane-ai/smartui/establish-baseline.jpeg').default} alt="Baseline screenshot created" className="doc_img"/> |
| 81 | + |
| 82 | +### Step 5: Rerun and Analyze the Comparison |
| 83 | +When you rerun the test, a new screenshot is captured and compared against the baseline. Click **Show Comparison** to open the SmartUI view. This interface highlights any visual differences found between the two images. |
| 84 | + |
| 85 | +<img loading="lazy" src={require('../assets/images/kane-ai/smartui/analyze-comparison.png').default} alt="Analyze the visual comparison between baseline and new screenshot" className="doc_img"/> |
| 86 | + |
| 87 | +### Step 6: Approve or Reject Changes |
| 88 | +Within the comparison view, you can review the changes and decide on a verdict. |
| 89 | +* **Reject Screenshot:** If the changes are unintended defects, you may reject the comparison. |
| 90 | +* **Approve Screenshot:** If the changes are intentional, you may accept the comparison. This will update the baseline with the new image. |
| 91 | + |
| 92 | +You can also adjust project settings like **Compare Type** and **Mis-Match Threshold** directly from this view. |
| 93 | + |
| 94 | +<img loading="lazy" src={require('../assets/images/kane-ai/smartui/approve-reject-changes.jpeg').default} alt="Approve or Reject Screenshot Changes" className="doc_img"/> |
| 95 | + |
| 96 | +## Saving and Automating Your Visual Test |
| 97 | + |
| 98 | +### Step 7: Save Your Test Case |
| 99 | +Once your test flow is complete, click **Finish test**. You will be prompted to save the session, where you can define the **Project**, **Folder**, **Test Name**, and **Description**. |
| 100 | + |
| 101 | +<img loading="lazy" src={require('../assets/images/kane-ai/smartui/save-test-case.png').default} alt="Save the test case session" className="doc_img"/> |
| 102 | + |
| 103 | +### Step 8: Schedule the Test for Automation |
| 104 | +You can access your saved tests via the **Test Manager**. To automate execution, navigate to **Test Runs** and schedule the finalized test[cite: 225]. When creating the run, provide a name and select **KaneAI Generated** as the `Type`. You can then set a recurring schedule for execution. Scheduled runs will automatically capture screenshots and store them in the SmartUI project for continuous comparison. |
| 105 | + |
| 106 | +<img loading="lazy" src={require('../assets/images/kane-ai/smartui/schedule-test-run.png').default} alt="Schedule the Test Run for automation" className="doc_img"/> |
| 107 | + |
| 108 | +## Step 9: View Your Visual Test Results on SmartUI |
| 109 | + |
| 110 | +After the HyperExecute job is finished, all screenshots captured using the `takeScreenshot` command will be available in your SmartUI project for review. |
| 111 | + |
| 112 | +<img loading="lazy" src={require('../assets/images/smart-visual-testing/smartui-sdk-results-primer.webp').default} alt="SmartUI Results" width="768" height="373" className="doc_img"/> |
| 113 | + |
| 114 | +1. Navigate to the [SmartUI Dashboard](https://smartui.lambdatest.com/). |
| 115 | +2. Select your project and the most recent build. |
| 116 | +3. Here, you can compare screenshots against the baseline, highlight differences, and approve or reject changes. You can use features like Smart Ignore to mask dynamic areas for more stable comparisons. |
0 commit comments