@serenity-js/web
Version:
Serenity/JS Screenplay Pattern library offering a flexible, web driver-agnostic approach for interacting with web-based user interfaces and components, suitable for various testing contexts
33 lines • 1.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PageElementInteraction = void 0;
const core_1 = require("@serenity-js/core");
/**
* A base class for interactions with [`PageElement`](https://serenity-js.org/api/web/class/PageElement/) objects.
*
* **Note:** The recommended way to implement custom interactions
* in your code is to use the [`Interaction.where`](https://serenity-js.org/api/core/class/Interaction/#where) factory method.
*
* @group Activities
*/
class PageElementInteraction extends core_1.Interaction {
constructor(description, location = core_1.Interaction.callerLocation(4)) {
super(description, location);
}
/**
* Returns the resolved [`PageElement`](https://serenity-js.org/api/web/class/PageElement/), or throws a [`LogicError`](https://serenity-js.org/api/core/class/LogicError/)
* if the element is `undefined`.
*
* @param actor
* @param element
*/
async resolve(actor, element) {
const resolved = await actor.answer(element);
if (!resolved) {
throw new core_1.LogicError((0, core_1.d) `Couldn't find ${element}`);
}
return resolved;
}
}
exports.PageElementInteraction = PageElementInteraction;
//# sourceMappingURL=PageElementInteraction.js.map