Having recently started using protractor cucumber, I have created the following feature. Upon launching protractor protractor.conf.js
, the browser opens and immediately closes, displaying that my tests have passed. Is this the expected testing behavior? Shouldn't I see interactions in the browser during the login process?
Scenario: Open the browser and login Given I am on the login page When I should be able to login with my credentials When I logout Then I should be able to see login page
Scenario: Open the browser and login
√ Given I am on the login page
√ When I should be able to login with my credentials
√ When I logout
√ Then I should be able to see login pagelogin page
1 scenario (1 passed) 4 steps (4 passed) 0m00.005s
this.Given('I am on the login page', function() {
browser.driver.get(browser.baseUrl);
});
this.When('I should be able to login with my credentials', function() {
let inputUsernameField = element(by.css(USERNAME_NAME));
inputUsernameField.sendKeys(username);
let inputPasswordField = element(by.css(PASSWORD_NAME));
inputPasswordField.sendKeys(password);
element(by.id(LOGIN_BUTTON_ID)).click();
});
this.When('I logout', function() {
element(by.className(HAMBERBURGER_MENU_ICON_CLASS)).click();
element(by.className(LOGOUT_BUTTON_CLASS)).click();
});
this.Then('I should be able to see login page', {timeout:120*1000},function() {
browser.driver.wait(protractor.ExpectedConditions.presenceOf($('#login_button')), 5000);
});
Below is the protractor.conf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
getPageTimeout: 600000,
allScriptsTimeout: 500000,
defaultTimeoutInterval: 30000,
framework: 'custom',
// path relative to the current config file
frameworkPath: require.resolve('protractor-cucumber-framework'),
multiCapabilities:
[
{
'browserName': 'chrome'
},
{
'browserName': 'firefox'
}],
// Spec patterns are relative to this directory.
specs: [
'features/*.feature'
],
baseURL: 'http://localhost:8080/',
ignoreSynchronization: true,
cucumberOpts: {
strict: true,
require: [
'hooks/reporter/js',
'specs/*Spec.js'
],
tags: false,
profile: false,
format: 'json:e2e/reports/cucumber-report.json',
resultJsonOutputFile: 'e2e/reports/cucumber-report.json'
},
onPrepare: function() {
var chai = require('chai');
chai.use(require('chai-as-promised'));
global.expect = chai.expect;
global.baseURL = this.baseURL;
browser.ignoreSynchronization = true;
browser.driver.manage().window().maximize();
browser.waitForAngular();
browser.driver.manage().timeouts().implicitlyWait(30000);
},
onComplete: function() {
const report = require('multiple-cucumber-html-reporter');
report.generate({
jsonDir: 'e2e/reports/',
reportPath: 'e2e/reports/',
});
}
}