For AI agents and LLMs: a machine-readable index is available at llms.txt. A plain-Markdown version of any documentation page is available by appending .md to its URL.
Skip to main content

SmartUI Hooks: Layout, Full-Page Screenshots, and Smart Ignore

Use this page when you run SmartUI Hooks on LambdaTest (for example Selenium executeScript without the smartui exec CLI wrapper) and need layout comparison, full-page capture, or Smart Ignore.

Capability vs hook, read this first

For Hooks, engineering behavior is:

GoalWhere to configureNotes
Layout comparisonsmartui.takeScreenshot hook options (per screenshot)Pass ignoreType: ["layout"] (and related layout flags) in the Map/object passed to executeScript("smartui.takeScreenshot", options). Layout is not enabled for Hooks by setting layout fields only in LT:Options capabilities. That path is not supported the way teams often expect.
Smart IgnoreLT:OptionsSet smartUI.smartIgnore: true on the session for baseline and comparison runs.
ProjectLT:OptionsSet smartUI.project (and visual, auth) as usual.

If you need layout via capabilities alone (no hook options), treat that as a feature request and raise it with your account team. This doc reflects current Hooks behavior.

Smart Ignore vs Ignore DOM / Select DOM

With Smart Ignore, use either Ignore DOM or Select DOM in the dashboard where applicable, not both on the same flow.

1. Session capabilities (LT:Options)​

Always (Hooks)​

  • username, accessKey, visual: true, smartUI.project

Smart Ignore (Hooks)​

Set on LT:Options for the whole session (baseline and comparison):

import java.util.HashMap;
import org.openqa.selenium.chrome.ChromeOptions;

ChromeOptions browserOptions = new ChromeOptions();
HashMap<String, Object> ltOptions = new HashMap<>();
ltOptions.put("username", System.getenv("LT_USERNAME"));
ltOptions.put("accessKey", System.getenv("LT_ACCESS_KEY"));
ltOptions.put("visual", true);
ltOptions.put("smartUI.project", "Your_Project_Name");
ltOptions.put("smartUI.smartIgnore", true);

browserOptions.setCapability("LT:Options", ltOptions);

JavaScript / Node

'LT:Options': {
user: process.env.LT_USERNAME,
accessKey: process.env.LT_ACCESS_KEY,
visual: true,
'smartUI.project': 'Your_Project_Name',
'smartUI.smartIgnore': true,
},

C#

capabilities.SetCapability("visual", true);
capabilities.SetCapability("smartUI.project", "Your_Project_Name");
capabilities.SetCapability("smartUI.smartIgnore", true);
Do not use these for Smart Ignore (Hooks + Java)

These patterns do not turn on Smart Ignore reliably:

  • ltOptions.put("ignoreType", Arrays.asList("smartignore")); without smartUI.smartIgnore
  • ltOptions.put("smartignore", true); at the root of LT:Options

Use smartUI.smartIgnore: true only.

Layout: not via standalone layout capabilities for Hooks​

Do not expect ignoreType: ["layout"], smartUI.layout, or nested smartUI.options layout blocks alone in LT:Options to enable layout comparison for Hooks. Validated behavior is: pass layout in the hook (next section).


2. Layout comparison: pass options to smartui.takeScreenshot​

Pass a single map to executeScript("smartui.takeScreenshot", options) including screenshotName and ignoreType.

Java (validated pattern)​

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.openqa.selenium.JavascriptExecutor;

Map<String, Object> options = new HashMap<>();
options.put("ignoreType", Arrays.asList("layout"));
options.put("screenshotName", "my-layout-screenshot-01");

((JavascriptExecutor) driver).executeScript("smartui.takeScreenshot", options);

Session LT:Options for this flow typically needs at least smartUI.project (and visual, credentials), not a separate layout capability block for the same effect.

JavaScript​

await driver.executeScript('smartui.takeScreenshot', {
screenshotName: 'my-layout-screenshot-01',
ignoreType: ['layout'],
});

C#​

var options = new Dictionary<string, object>
{
{ "screenshotName", "my-layout-screenshot-01" },
{ "ignoreType", new[] { "layout" } }
};
((IJavaScriptExecutor)driver).ExecuteScript("smartui.takeScreenshot", options);

Add fullPage: true in the same map when you need a full-page capture for that shot.


3. Full-page screenshot (name-only hook)​

((JavascriptExecutor) driver).executeScript("smartui.takeFullPageScreenshot=Home_Page_Desktop");
((IJavaScriptExecutor)driver).ExecuteScript("smartui.takeFullPageScreenshot=Home_Page_Desktop");

For layout + full page in one call, prefer the config object form in §2 with fullPage: true and ignoreType: ["layout"].


4. Baseline and comparison​

  1. Same smartUI.project and screenshot names.
  2. Smart Ignore: same smartUI.smartIgnore on baseline and comparison sessions.
  3. Layout: same ignoreType: ["layout"] (and other layout flags) in the hook for matching screenshot names on baseline and comparison runs.
  4. Changing strategy or options usually requires a new baseline.

5. Strict comparison vs Smart Ignore​

If the project or build is still effectively in strict (pixel) comparison, some Smart Ignore–specific UI flows behave differently. Align dashboard comparison mode with session capabilities.


6. Build attribution (creator name)​

Runs using a project token may show the project creator. Use the intended automation username / access key / project where the product allows.


7. Troubleshooting​

ProblemWhat to do
Layout never activates; only tried LT:OptionsMove ignoreType: ["layout"] into smartui.takeScreenshot options (§2).
Smart Ignore never activatesSet smartUI.smartIgnore: true in LT:Options; verify in session metadata.
Tried smartUI.layoutNot the supported Hooks switch for layout; use hook options instead.
Want to rely on dashboard toggles onlyHooks still need the correct hook + capability split per this page.

Terminal First Testing With Kane CLI

Natural language browser & mobile app tests right from terminal.

×
Schedule Your Personal Demo
Kane CLI terminal

Help and Support

Related Articles