Skip to main content

externalSelect

Instructs an actor who has the ability to BrowseTheWeb to select an option from a HTML <select> element, either by its display name, or by value.

Learn more

Index

Constructors

externalconstructor

Methods

staticexternalvalue

  • Instantiates an interaction that instructs the actor to select a single <option> with a given value.,

    Example widget

    <select data-test='countries'>
    <option value='UK'>United Kingdom</option>
    <option value='PL'>Poland</option>
    <option value='US'>United States</option>
    </select>
    ```C

    #### Lean Page Object describing the widget

    ```ts
    import { By, PageElement } from '@serenity-js/web'

    class Countries {
    static dropdown = () =>
    PageElement.located(By.css('[data-test="countries"]'))
    .describedAs('countries dropdown')
    }

    Retrieving the selected value

    import { actorCalled } from '@serenity-js/core'
    import { Select, Selected } from '@serenity-js/web';
    import { Ensure, equals } from '@serenity-js/assertions'

    await actorCalled('Nick')
    .attemptsTo(
    Select.value('UK').from(Countries.dropdown()),
    Ensure.that(Selected.valueOf(Countries.dropdown()), equals('UK')),
    )

    Learn more


    Parameters

    Returns { from: (pageElement: Answerable<PageElement<any>>) => Interaction }

staticexternalvalues

  • Instantiates an interaction that instructs the actor to select multiple <option> elements identified by their values.

    Example widget

    <select multiple data-test='countries'>
    <option value='UK'>United Kingdom</option>
    <option value='PL'>Poland</option>
    <option value='US'>United States</option>
    </select>

    Lean Page Object describing the widget

    import { By, PageElement } from '@serenity-js/web'

    class Countries {
    static dropdown = () =>
    PageElement.located(By.css('[data-test="countries"]'))
    .describedAs('countries dropdown')
    }

    Retrieving the selected value

    import { actorCalled } from '@serenity-js/core'
    import { Select, Selected } from '@serenity-js/web'
    import { Ensure, equals } from '@serenity-js/assertions'

    await actorCalled('Nick')
    .attemptsTo(
    Select.values('UK').from(Countries.dropdown()),
    Ensure.that(Selected.valuesOf(Countries.dropdown()), equals([ 'UK' ])),
    )

    Learn more


    Parameters

    Returns { from: (pageElement: Answerable<PageElement<any>>) => Interaction }

staticexternaloption

  • Instantiates an interaction that instructs the actor to select a single <option> with a given description.

    Example widget

    <select data-test='countries'>
    <option value='UK'>United Kingdom</option>
    <option value='PL'>Poland</option>
    <option value='US'>United States</option>
    </select>

    Lean Page Object describing the widget

    import { By, PageElement } from '@serenity-js/by'

    class Countries {
    static dropdown = () =>
    PageElement.located(By.css('[data-test="countries"]'))
    .describedAs('countries dropdown')
    }

    Retrieving the selected value

    import { actorCalled } from '@serenity-js/core'
    import { Select, Selected } from '@serenity-js/web'
    import { Ensure, equals } from '@serenity-js/assertions'

    await actorCalled('Nick')
    .whoCan(BrowseTheWeb.using(protractor.browser))
    .attemptsTo(
    Select.option('Poland').from(Countries.dropdown()),
    Ensure.that(
    Selected.optionIn(Countries.dropdown()),
    equals('Poland')
    ),
    )

    Learn more


    Parameters

    Returns { from: (pageElement: Answerable<PageElement<any>>) => Interaction }

staticexternaloptions

  • Instantiates an interaction that instructs the actor to select multiple <option> elements identified by their descriptions.

    Example widget

    <select multiple data-test='countries'>
    <option value='UK'>United Kingdom</option>
    <option value='PL'>Poland</option>
    <option value='US'>United States</option>
    </select>

    Lean Page Object describing the widget

    import { By, PageElement } from '@serenity-js/web'

    class Countries {
    static dropdown = () =>
    PageElement.located(By.css('[data-test="countries"]'))
    .describedAs('countries dropdown')
    }
    Retrieving the selected value
    import { actorCalled } from '@serenity-js/core'
    import { Select, Selected } from '@serenity-js/web'
    import { Ensure, equals } from '@serenity-js/assertions'

    await actorCalled('Nick')
    .whoCan(BrowseTheWeb.using(protractor.browser))
    .attemptsTo(
    Select.options('Poland', 'United States').from(Countries.dropdown()),
    Ensure.that(
    Selected.optionsIn(Countries.dropdown()),
    equals([ 'Poland', 'United States' ])
    ),
    )

    Learn more


    Parameters

    Returns { from: (pageElement: Answerable<PageElement<any>>) => Interaction }