externalSelect
Index
Constructors
Methods
Constructors
externalconstructor
Returns Select
Methods
staticexternalvalue
Instantiates an interaction that instructs the actor to select a single
<option>
with a givenvalue
.,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
externalvalue: Answerable<string>
A value of the
option
element for theActor
to select
Returns { from: (pageElement: Answerable<PageElement<any>>) => Interaction }
externalfrom: (pageElement: Answerable<PageElement<any>>) => Interaction
Parameters
externalpageElement: Answerable<PageElement<any>>
Returns Interaction
staticexternalvalues
Instantiates an interaction that instructs the actor to select multiple
<option>
elements identified by theirvalue
s.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
externalrest...values: Answerable<string | string[]>[]
Values of the
option
elements for theActor
to select
Returns { from: (pageElement: Answerable<PageElement<any>>) => Interaction }
externalfrom: (pageElement: Answerable<PageElement<any>>) => Interaction
Parameters
externalpageElement: Answerable<PageElement<any>>
Returns 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
externalvalue: Answerable<string>
Text of the
option
element for theActor
to select
Returns { from: (pageElement: Answerable<PageElement<any>>) => Interaction }
externalfrom: (pageElement: Answerable<PageElement<any>>) => Interaction
Parameters
externalpageElement: Answerable<PageElement<any>>
Returns 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
externalrest...values: Answerable<string | string[]>[]
Text of the
option
elements for theActor
to select
Returns { from: (pageElement: Answerable<PageElement<any>>) => Interaction }
externalfrom: (pageElement: Answerable<PageElement<any>>) => Interaction
Parameters
externalpageElement: Answerable<PageElement<any>>
Returns Interaction
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
Selected