Just a simple boilerplate for BDD style Webdriver Tests.
- install Node.js 4 or higher
- clone this repo
- Write your tests in BDD style
- Page Object Pattern
- Includes Selenium Server
- Junit Reporting
- Screenshots on failed tests
Execute:
npm test
- Add a .feature file in the features folder. The feature file needs to be in the Gherkin format see this article for more details.
- implement the steps in features/step_definitions See the [https://github.com/cucumber/cucumber-js](CucumberJs documentation) for details. Ensure that you use the promise-style of writing your steps. in your steps you can use this.[pageName]Page:
this.When(/^I go to the README file$/, function () {
return this.homePage.openReadme();
});
- Create the page objects in the folder pages, make sure that pages file name ends on '.page.js'
a page has the following components:
- object 'selectors' with all the CSS selectors you would like to use on this page
- Object.Create which contains all the functions which are used in the step definitions
in the functions you can access WebdriverIO using
this.browser.[function]
see the [http://webdriver.io/api.html](WebdriverIO API) for more info
var Page = require('./page');
const selectors = {
readme : "a[title='README.md']"
}
var HomePage = Object.create(Page, {
openReadme: {
value: function () {
return this.browser.click(selectors.readme);
}
},
});
module.exports = HomePage;