Select
Instructs the Actor to
select an option from a HTML <select>
element,
either by its display name, or by value.
Tests:
See also:
Static Method Summary
Static Public Methods | ||
public static |
option(value: string | Answerable<string>): SelectBuilder Instantiates this Interaction
with a single |
|
public static |
options(values: Array<Answerable<string[]|string>>): SelectBuilder Instantiates this Interaction
with |
|
public static |
value(value: string | Answerable<string>): SelectBuilder Instantiates this Interaction
with a |
|
public static |
values(values: Array<Answerable<string[]|string>>): SelectBuilder Instantiates this Interaction
with |
Static Public Methods
public static option(value: string | Answerable<string>): SelectBuilder source
Instantiates this Interaction
with a single option
for the Actor to select.
Params:
Name | Type | Attribute | Description |
value | string | Answerable<string> | Text of the |
Examples:
<select data-test='countries'>
<option value='UK'>United Kingdom</option>
<option value='PL'>Poland</option>
<option value='US'>United States</option>
</select>
import { Target } from '@serenity-js/protractor';
import { browser, by } from 'protractor';
class Countries {
static dropdown = Target.the('countries dropdown')
.located(by.css('[data-test="countries"]'));
}
import { actorCalled } from '@serenity-js/core';
import { BrowseTheWeb, Select, Selected } from '@serenity-js/protractor';
import { Ensure, equals } from '@serenity-js/assertions';
import { protractor } from 'protractor';
actorCalled('Nick')
.whoCan(BrowseTheWeb.using(protractor.browser))
.attemptsTo(
Select.option('Poland').from(Countries.dropdown),
Ensure.that(
Selected.optionIn(Countries.dropdown),
equals('Poland')
),
);
public static options(values: Array<Answerable<string[]|string>>): SelectBuilder source
Instantiates this Interaction
with option
s
for the Actor to select.
Params:
Name | Type | Attribute | Description |
values | Array<Answerable<string[]|string>> | Text of the |
Examples:
<select multiple data-test='countries'>
<option value='UK'>United Kingdom</option>
<option value='PL'>Poland</option>
<option value='US'>United States</option>
</select>
import { Target } from '@serenity-js/protractor';
import { browser, by } from 'protractor';
class Countries {
static dropdown = Target.the('countries dropdown')
.located(by.css('[data-test="countries"]'));
}
import { actorCalled } from '@serenity-js/core';
import { BrowseTheWeb, Select, Selected } from '@serenity-js/protractor';
import { Ensure, equals } from '@serenity-js/assertions';
import { protractor } from 'protractor';
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' ])
),
);
public static value(value: string | Answerable<string>): SelectBuilder source
Instantiates this Interaction
with a value
of a single <option>
for the Actor to select.
Params:
Name | Type | Attribute | Description |
value | string | Answerable<string> | A value of the |
Examples:
<select data-test='countries'>
<option value='UK'>United Kingdom</option>
<option value='PL'>Poland</option>
<option value='US'>United States</option>
</select>
import { Target } from '@serenity-js/protractor';
import { browser, by } from 'protractor';
class Countries {
static dropdown = Target.the('countries dropdown')
.located(by.css('[data-test="countries"]'));
}
import { actorCalled } from '@serenity-js/core';
import { BrowseTheWeb, Select, Selected } from '@serenity-js/protractor';
import { Ensure, equals } from '@serenity-js/assertions';
import { protractor } from 'protractor';
actorCalled('Nick')
.whoCan(BrowseTheWeb.using(protractor.browser))
.attemptsTo(
Select.value('UK').from(Countries.dropdown),
Ensure.that(Selected.valueOf(Countries.dropdown), equals('UK')),
);
public static values(values: Array<Answerable<string[]|string>>): SelectBuilder source
Instantiates this Interaction
with value
s
of multiple <option>
elements
for the Actor to select.
Params:
Name | Type | Attribute | Description |
values | Array<Answerable<string[]|string>> | Values of the |
Examples:
<select multiple data-test='countries'>
<option value='UK'>United Kingdom</option>
<option value='PL'>Poland</option>
<option value='US'>United States</option>
</select>
import { Target } from '@serenity-js/protractor';
import { browser, by } from 'protractor';
class Countries {
static dropdown = Target.the('countries dropdown')
.located(by.css('[data-test="countries"]'));
}
import { actorCalled } from '@serenity-js/core';
import { BrowseTheWeb, Select, Selected } from '@serenity-js/protractor';
import { Ensure, equals } from '@serenity-js/assertions';
import { protractor } from 'protractor';
actorCalled('Nick')
.whoCan(BrowseTheWeb.using(protractor.browser))
.attemptsTo(
Select.values('UK').from(Countries.dropdown),
Ensure.that(Selected.valuesOf(Countries.dropdown), equals([ 'UK' ])),
);