Clear
Instructs the Actor to
clear the value
of a form input
.
Extends:
Examples:
<form>
<input type="text" name="example" id="example" />
</form>
import { Target } from '@serenity-js/protractor';
import { by } from 'protractor';
class Form {
static exampleInput = Target.the('example input')
.located(by.id('example'));
}
import { actorCalled } from '@serenity-js/core';
import { BrowseTheWeb, Clear, Enter, Value } from '@serenity-js/protractor';
import { Ensure, equals } from '@serenity-js/assertions';
import { protractor } from 'protractor';
actorCalled('Inés')
.whoCan(BrowseTheWeb.using(protractor.browser))
.attemptsTo(
Enter.theValue('Hello world!').into(Form.exampleInput),
Ensure.that(Value.of(Form.exampleInput), equals('Hello world!')),
Clear.theValueOf(Form.exampleInput),
Ensure.that(Value.of(Form.exampleInput), equals('')),
);
Static Method Summary
Static Public Methods | ||
public static |
theValueOf(field: Question<ElementFinder> | ElementFinder): Interaction Instantiates this Interaction. |
Constructor Summary
Public Constructor | ||
public |
constructor(field: Question<ElementFinder> | ElementFinder) |
Method Summary
Public Methods | ||
public |
performAs(actor: UsesAbilities & AnswersQuestions): PromiseLike<void> Makes the provided Actor perform this Interaction. |
|
public |
toString(): string Generates a description to be used when reporting this Activity. |
Static Public Methods
public static theValueOf(field: Question<ElementFinder> | ElementFinder): Interaction source
Instantiates this Interaction.
Params:
Name | Type | Attribute | Description |
field | Question<ElementFinder> | ElementFinder | The field to be cleared |
Tests:
- Clear allows the actor to clear the value of a date field
- Clear allows the actor to clear the value of an RTL input field
- Clear complains if the element cannot be cleared
- Clear allows the actor to clear the value of an empty input field
- Clear allows the actor to clear the value of an empty input with no "value" attribute
- Clear allows the actor to clear the value of an input field
- Clear allows the actor to clear the value of an number field
Public Constructors
public constructor(field: Question<ElementFinder> | ElementFinder) source
Params:
Name | Type | Attribute | Description |
field | Question<ElementFinder> | ElementFinder | The field to be cleared |
Public Methods
public performAs(actor: UsesAbilities & AnswersQuestions): PromiseLike<void> source
Makes the provided Actor perform this Interaction.
Params:
Name | Type | Attribute | Description |
actor | UsesAbilities & AnswersQuestions | An Actor to perform this Interaction |
Returns:
PromiseLike<void> |