I am trying to find out a bit more cucumbers using webdriverIO and I am having problems running my tests.
Actually, I want to highlight this simple function:
Feature: Example Feature
In order to become productive
As a test automation engineer
I want to understand the basics of cucumber
Scenario: My First Test Scenario
Given I have open "https://google.com"
Then the title should be "Google".
And the bar should be empty.
With this test:
const assert = require('assert');
module.exports = function() {
this.Given(/^I have open "([^"]*)"$/, function(arg1, callback) {
browser
.url(arg1)
.call(callback);
});
this.Then(/^the title should be "([^"]*)"\.$/, function(arg1, callback) {
const title = browser.getTitle();
assert(title, arg1);
browser
.getTitle()
.then(title2 => {
assert(title2, arg1);
callback();
});
});
this.Then(/^the bar should be empty\.$/, function(callback) {
callback(null, 'pending');
});
}
My configuration file:
"use strict";
const WebDriverIO = require('webdriverio');
const browser = WebDriverIO.remote({
baseUrl: 'https://google.com',
host: 'localhost',
port: 4444,
waitforTimeout: 120 * 1000,
logLevel: 'silent',
screenshotPath: `${__dirname}/documentation/screenshots/`,
desiredCapabilities: {
browserName: process.env.SELENIUM_BROWSER || 'chrome',
},
});
global.browser = browser;
module.exports = function() {
this.registerHandler('BeforeFeatures', function(event, done) {
browser.init().call(done);
});
this.registerHandler('AfterFeatures', function(event, done) {
browser.end().call(done);
});
};
My problem
My problems:
- I never go into the .call (callback) function
- If I go around the previous point by adding a callback () immediately after .url (arg1), I go to the next point
- In the first case, neither the first solution nor the second solution seems to work. Although I am trying to write the value of the const header, I have the expected promise. But when I try to resolve this promise (second case), I never register anything (even in the case of rejection).
Limitations
- I do not want to use wdio
- I am using selenium 2.53
- I am using cucumberjs 1.3.1
- webdriverio 4.4.0
- Nodejs v4.6.0
EDIT: