Skip to main content

externalNavigation

Interaction object for navigating between views via the sidebar.

Unlike most interaction objects in the HTML reporter, Navigation does not extend InteractionObject — it operates on global page elements (the sidebar, hamburger menu, theme toggle) rather than a scoped root element.

Handles responsive navigation transparently: on mobile viewports where the sidebar is hidden behind a hamburger menu, openView() and selectTheme() open the menu first before interacting with navigation items.

Instantiation

import { Navigation } from '@serenity-js/html-reporter/serenity';

const navigation = new Navigation();

Usage in a test

await actor.attemptsTo(
navigation.openView('Test Scenarios'),
Ensure.that(scenariosView.scenarioCount(), isGreaterThan(0)),
);

Wiring into view interaction objects

Views typically accept a Navigation instance and delegate via an open() method:

export class ScenariosView<NET> extends InteractionObject<NET> {
constructor(rootElement, private readonly navigation: Navigation) { ... }

open = (): Task =>
Task.where('#actor opens the Scenarios view',
this.navigation.openView('Test Scenarios'),
);
}

Index

Constructors

externalconstructor

Methods

externalsummaryLink

  • The href attribute of the <link rel="alternate"> element pointing to the machine-readable summary.json file.

    Example

    await actor.attemptsTo(
    Ensure.that(navigation.summaryLink(), includes('summary.json')),
    );

    Returns QuestionAdapter<string>

externalsummaryLinkTitle

  • The title attribute of the <link rel="alternate"> element for summary.json.

    Example

    await actor.attemptsTo(
    Ensure.that(navigation.summaryLinkTitle(), equals('Test results summary (JSON)')),
    );

    Returns QuestionAdapter<string>

externalopenView

  • Navigates to a view by clicking its sidebar navigation item.

    On mobile viewports where the sidebar is hidden, this opens the hamburger menu first, then clicks the nav item. Waits until the route has changed before completing.

    Example

    await actor.attemptsTo(
    navigation.openView('Test Scenarios'),
    Ensure.that(scenariosView.scenarioCount(), isGreaterThan(0)),
    );

    Parameters

    • externalviewName: Answerable<string>

      The visible text of the sidebar navigation item (e.g. 'Dashboard', 'Test Scenarios', 'Capabilities', 'Consistency')

    Returns Task

externalselectTheme

  • selectTheme(preference: string): Task
  • Switches the report's colour theme via the sidebar theme toggle.

    On mobile viewports where the sidebar is hidden, this opens the hamburger menu first before interacting with the theme switcher.

    Example

    await actor.attemptsTo(
    navigation.selectTheme('dark'),
    );

    Parameters

    • externalpreference: string

      The theme to activate (e.g. 'light', 'dark', 'system')

    Returns Task