Package Exports
- @serenity-js/webdriverio
- @serenity-js/webdriverio/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@serenity-js/webdriverio) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Serenity/JS
Serenity/JS is an innovative framework designed to make acceptance and regression testing of complex software systems faster, more collaborative and easier to scale.
To get started, check out the comprehensive Serenity/JS Handbook, API documentation, and Serenity/JS project templates on GitHub.
If you have any questions or just want to say hello, join the Serenity/JS Community Chat.
Serenity/JS WebdriverIO
@serenity-js/webdriverio module is a Screenplay Pattern-style adapter
for WebdriverIO, that helps with testing Web-based and mobile apps.
Installation
To install this module, run the following command in your WebdriverIO project directory:
npm install --save-dev @serenity-js/{assertions,console-reporter,core,serenity-bdd,web,webdriverio}Next, install one of the below test runner adapters.
Usage with Cucumber.js
To use Serenity/JS WebdriverIO with Cucumber.js, install the following adapter:
npm install --save-dev @serenity-js/cucumberPlease note that Serenity/JS WebdriverIO / Cucumber integration supports both Serenity/JS reporting services and native Cucumber.js reporters.
Usage with Jasmine
To use Serenity/JS WebdriverIO with Jasmine, install the following adapter:
npm install --save-dev @serenity-js/jasmineUsage with Mocha
To use Serenity/JS WebdriverIO with Mocha, install the following adapter:
npm install --save-dev @serenity-js/mochaConfiguring Webdriverio
// serenity/Actors.ts
import { Actor, Cast } from '@serenity-js/core';
import { BrowseTheWebWithWebdriverIO } from '@serenity-js/webdriverio';
import * as wdio from 'webdriverio';
// example Actors class, confgures Serenity/JS actors to use WebdriverIO
class Actors implements Cast {
constructor(private readonly browser: wdio.Browser<'async'>) {
}
prepare(actor: Actor): Actor {
return actor.whoCan(
BrowseTheWebWithWebdriverIO.using(this.browser),
// ... add other abilities as needed, like CallAnApi or TakeNotes
);
}
}
// wdio.conf.ts
// Import Serenity/JS reporting services, a.k.a. the "Stage Crew Members"
import { Actors } from './serenity/Actors.ts'
export const config: WebdriverIOConfig = {
// Tell WebdriverIO to use Serenity/JS framework
framework: '@serenity-js/webdriverio',
serenity: {
// Configure Serenity/JS to use an appropriate test runner adapter
runner: 'cucumber',
// runner: 'mocha',
// runner: 'jasmine',
// register custom Actors class to configure your Serenity/JS actors
actors: new Actors(),
// Register StageCrewMembers we've imported at the top of this file
crew: [
'@serenity-js/console-reporter',
'@serenity-js/serenity-bdd',
[ '@serenity-js/core:ArtifactArchiver', { outputDirectory: 'target/site/serenity' } ],
[ '@serenity-js/web:Photographer', {
strategy: 'TakePhotosOfFailures', // or: 'TakePhotosOfInteractions'
} ],
]
},
// configure Cucumber runner
cucumberOpts: {
// see the Cucumber configuration options below
},
// or Jasmine runner
jasmineOpts: {
// see the Jasmine configuration options below
},
// or Mocha runner
mochaOpts: {
// see the Mocha configuration options below
},
specs: [
// load Cucumber feature files
'./features/**/*.feature',
// or Mocha/Jasmine spec files
// './spec/**/*.spec.ts',
],
// add any additional native WebdriverIO reports
// reporters: [
// 'spec',
// ],
// ... other WebdriverIO-specific configuration
};Learn more about:
- Cucumber configuration options
- Jasmine configuration options
- Mocha configuration options
- WebdriverIO configuration file
Usage with Mocha
import { actorCalled } from '@serenity-js/core';
import { Ensure, equals } from '@serenity-js/assertions';
import { By, Navigate, PageElement, Text } from '@serenity-js/web';
import { BrowseTheWebWithWebdriverIO } from '@serenity-js/webdriverio';
// example Lean Page Object describing a widget we interact with in the test
class SerenityJSWebsite {
static header = () =>
PageElement.located(By.css('h1')) // selector to identify the interactable element
.describedAs('header'); // description to be used in reports
}
describe('Serenity/JS', () => {
it('works with WebdriverIO and Mocha', async () => {
// actorCalled(name) instantiates or retrieves an existing actor identified by name
// Actors class configures the actors to use WebdriverIO
await actorCalled('Wendy')
.attemptsTo(
Navigate.to('https://serenity-js.org'),
Ensure.that(
Text.of(SerenityJSWebsite.header()),
equals('Next generation acceptance testing')
),
)
})
});To learn more, check out the example projects.
Template Repositories
The easiest way for you to start writing web-based acceptance tests using Serenity/JS, WebdriverIO and either Mocha, Cucumber or Jasmine is by using one of the below template repositories:
- Serenity/JS, Mocha, and WebdriverIO template
- Serenity/JS, Cucumber, and WebdriverIO template
- Serenity/JS, Jasmine, and WebdriverIO template (coming soon!)
More coming soon!
New features, tutorials, and demos are coming soon, so follow us on LinkedIn and join the Serenity/JS Community Chat channel to stay up to date!