Skip to main content

Value

Uses the actor’s ability to BrowseTheWeb to retrieve the value attribute of a given PageElement.

Example widget

<input type="text" id="username" value="Alice" />

Retrieve the value of a given PageElement

import { actorCalled } from '@serenity-js/core'
import { Ensure, equals } from '@serenity-js/assertions'
import { By, PageElement, Value } from '@serenity-js/web'

const usernameField = () =>
PageElement.located(By.id('username'))
.describedAs('username field')

await actorCalled('Lisa')
.attemptsTo(
Ensure.that(Value.of(usernameField), equals('Alice')),
)

Using Value as QuestionAdapter

import { actorCalled } from '@serenity-js/core'
import { Ensure, equals } from '@serenity-js/assertions'
import { By, PageElement, Value } from '@serenity-js/web'

const usernameField = () =>
PageElement.located(By.id('username'))
.describedAs('username field')

await actorCalled('Lisa')
.attemptsTo(
Ensure.that(
Value.of(usernameField).toLocaleLowerCase()[0],
equals('a') // [a]lice
),
)

Learn more

Index

Constructors

Methods

Constructors

constructor

Methods

staticof