Press
Instructs the Actor to send a key press or a sequence of keys to a Web element.
Please note that modifier keys, such as Command ⌘, won't work on Mac
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, Press, Value } from '@serenity-js/protractor';
import { Ensure, equals } from '@serenity-js/assertions';
import { protractor, Key } from 'protractor';
actorCalled('Priyanka')
.whoCan(BrowseTheWeb.using(protractor.browser))
.attemptsTo(
Press.the('H', 'i', '!', Key.ENTER).in(Form.exampleInput),
Ensure.that(Value.of(Form.exampleInput), equals('Hi!')),
);
Tests:
See also:
Static Method Summary
Static Public Methods | ||
public static |
the(keys: ...keys: string[]): PressBuilder Instantiates this Interaction. |
Constructor Summary
Public Constructor | ||
public |
constructor(keys: string[], 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 the(keys: ...keys: string[]): PressBuilder source
Instantiates this Interaction.
Params:
Name | Type | Attribute | Description |
keys | ...keys: string[] | A sequence of one or more keys to press |
Public Constructors
public constructor(keys: string[], field: Question<ElementFinder> | ElementFinder) source
Params:
Name | Type | Attribute | Description |
keys | string[] | A sequence of one or more keys to press |
|
field | Question<ElementFinder> | ElementFinder | Web element to send the keys to |
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> |