UNPKG

@serenity-js/protractor

Version:

Adapter that integrates @serenity-js/web with Protractor, enabling Serenity/JS reporting and using the Screenplay Pattern to write end-to-end test scenarios

83 lines 2.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProtractorParam = void 0; const core_1 = require("@serenity-js/core"); const abilities_1 = require("../abilities"); /** * Returns a Protractor configuration parameter specified in `protractor.conf.js` * and identified by name. Protractor configuration parameters can be overridden via the command line. * * **Warning:** this question is Protractor-specific, so using it in your tests * will reduce their portability across test integration tools. * * ```js * // protractor.conf.js * exports.config = { * params: { * login: { * username: 'jane@example.org' * password: process.env.PASSWORD * } * } * // ... * } * ``` * * ## Overriding configuration parameter using the command line * * ```shell * npx protractor ./protractor.conf.js --params.login.username="bob@example.org" * ``` * * ## Using as `QuestionAdapter` * * ```ts * import { actorCalled } from '@serenity-js/core' * import { BrowseTheWebWithProtractor, ProtractorParam } from '@serenity-js/protractor' * import { Enter } from '@serenity-js/web' * import { protractor } from 'protractor' * * await actorCalled('Jane') * .whoCan( BrowseTheWebWithProtractor.using(protractor.browser)) * .attemptsTo( * Enter.theValue(ProtractorParam.called('login').username).into(Form.exampleInput), * ) * ``` * * ## Specifying path to param as string * * ```ts * import { actorCalled } from '@serenity-js/core' * import { BrowseTheWebWithProtractor, ProtractorParam } from '@serenity-js/protractor' * import { Enter } from '@serenity-js/web' * import { protractor } from 'protractor * * await actorCalled('Jane') * .whoCan(BrowseTheWebWithProtractor.using(protractor.browser)) * .attemptsTo( * Enter.theValue(ProtractorParam.called('login.username')).into(Form.exampleInput), * ); * ``` * * ## Learn more * - [`BrowseTheWebWithProtractor.param`](https://serenity-js.org/api/protractor/class/BrowseTheWebWithProtractor/#param) * * @group Questions */ class ProtractorParam { /** * Name of the parameter to retrieve. This could also be a dot-delimited path, * e.g. `login.username` * * @param name */ static called(name) { return core_1.Question.about((0, core_1.the) `the ${name} param specified in Protractor config`, async (actor) => { const paramName = await actor.answer(name); const browseTheWeb = abilities_1.BrowseTheWebWithProtractor.as(actor); return browseTheWeb.param(paramName); }); } } exports.ProtractorParam = ProtractorParam; //# sourceMappingURL=ProtractorParam.js.map