UNPKG

@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

35 lines 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PageElementsLocator = void 0; const core_1 = require("@serenity-js/core"); const abilities_1 = require("../abilities"); /** * @group Models */ class PageElementsLocator extends core_1.Question { locator; static fromDocumentRoot(selector) { return new PageElementsLocator(core_1.Question.about((0, core_1.the) `page elements located ${selector}`, async (actor) => { const bySelector = await actor.answer(selector); const currentPage = await abilities_1.BrowseTheWeb.as(actor).currentPage(); return currentPage.locate(bySelector).locator; })); } constructor(locator) { super((0, core_1.the) `${locator}`); this.locator = locator; } of(parent) { return new PageElementsLocator(core_1.Question.about((0, core_1.the) `${this} of ${parent}`, async (actor) => { const locator = await actor.answer(this.locator); const parentElement = await actor.answer(parent); return locator.of(parentElement.locator); })); } async answeredBy(actor) { const resolved = await actor.answer(this.locator); return resolved.allElements(); } } exports.PageElementsLocator = PageElementsLocator; //# sourceMappingURL=PageElementsLocator.js.map