UNPKG

@serenity-js/webdriverio

Version:

Adapter that integrates @serenity-js/web with the latest stable version of WebdriverIO, enabling Serenity/JS reporting and using the Screenplay Pattern to write web and mobile test scenarios

50 lines 2.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BrowseTheWebWithWebdriverIO = void 0; require("webdriverio"); const web_1 = require("@serenity-js/web"); const index_js_1 = require("../models/index.js"); /** * This implementation of the [ability](https://serenity-js.org/api/core/class/Ability/) to [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb/) * enables the [`Actor`](https://serenity-js.org/api/core/class/Actor/) to interact with web front-ends using [WebdriverIO](https://webdriver.io/). * * ## Using WebdriverIO to `BrowseTheWeb` * * ```ts * import { actorCalled } from '@serenity-js/core' * import { BrowseTheWebWithWebdriverIO } from '@serenity-js/webdriverio-8-8' * import { By, Navigate, PageElement, Text } from '@serenity-js/web' * import { Ensure, equals } from '@serenity-js/assertions' * import { browser } from '@wdio/globals' * * const HomePage = { * title: () => * PageElement.located(By.css('h1')).describedAs('title') * } * * await actorCalled('Wendy') * .whoCan(BrowseTheWebWithWebdriverIO.using(browser)) // `browser` is global in WebdriverIO tests * .attemptsTo( * Navigate.to(`https://serenity-js.org`), * Ensure.that(Text.of(HomePage.title()), equals('Serenity/JS')), * ); * ``` * * ## Learn more * - [WebdriverIO website](https://webdriver.io/) * - [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb/) * - [`Ability`](https://serenity-js.org/api/core/class/Ability/) * - [`Actor`](https://serenity-js.org/api/core/class/Actor/) * * @group Abilities */ class BrowseTheWebWithWebdriverIO extends web_1.BrowseTheWeb { static using(browserInstance) { return new BrowseTheWebWithWebdriverIO(new index_js_1.WebdriverIOBrowsingSession(browserInstance)); } async discard() { await this.session.discard(); } } exports.BrowseTheWebWithWebdriverIO = BrowseTheWebWithWebdriverIO; //# sourceMappingURL=BrowseTheWebWithWebdriverIO.js.map