Skip to main content

Selected

Uses the actor’s ability to BrowseTheWeb to retrieve options and values selected in a HTML <select> element.

Learn more

Index

Constructors

constructor

Methods

staticvalueOf

  • valueOf(pageElement: Answerable<PageElement<any>>): QuestionAdapter<string>
  • Uses the actor’s ability to BrowseTheWeb to retrieve a single option selected in an HTML <select> element.

    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.value('UK').from(Countries.dropdown),
    Ensure.that(Selected.valueOf(Countries.dropdown), equals('UK')),
    )

    Learn more


    Parameters

    Returns QuestionAdapter<string>

staticvaluesOf

  • valuesOf(pageElement: Answerable<PageElement<any>>): QuestionAdapter<string[]>
  • Uses the actor’s ability to BrowseTheWeb to retrieve values of options selected in an HTML <select multiple> element

    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.values('UK').from(Countries.dropdown),
    Ensure.that(Selected.valuesOf(Countries.dropdown), equals([ 'UK' ])),
    )

    Learn more


    Parameters

    Returns QuestionAdapter<string[]>

staticoptionIn

  • optionIn(pageElement: Answerable<PageElement<any>>): QuestionAdapter<string>
  • Uses the actor’s ability to BrowseTheWeb to retrieve a single option selected in an HTML <select> element

    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.option('Poland').from(Countries.dropdown),
    Ensure.that(
    Selected.optionIn(Countries.dropdown),
    equals('Poland')
    ),
    )

    Learn more


    Parameters

    Returns QuestionAdapter<string>

staticoptionsIn

  • optionsIn(pageElement: Answerable<PageElement<any>>): QuestionAdapter<string[]>
  • Uses the actor’s ability to BrowseTheWeb to retrieve options selected in an HTML <select multiple> element

    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.options('Poland', 'United States').from(Countries.dropdown),
    Ensure.that(
    Selected.optionsIn(Countries.dropdown),
    equals([ 'Poland', 'United States' ])
    ),
    )

    Learn more


    Parameters

    Returns QuestionAdapter<string[]>