Currently, I am utilizing Protractor with TypeScript and Cucumber for automation purposes. After going through some informative articles, I have successfully incorporated feature files and step definitions into my end-to-end project.
Below is the structure of my feature file:
Feature: Homepage
Scenario: Visit Homepage
Given I am on the homepage
Then I should see a "navbar"
And I should see a "login" link
And I should see a "register" link
Here are the Steps Definitions implemented:
var pc = require('protractor-cucumber');
module.exports = steps;
var steps = function() {
this.Given('I am on the homepage', function (callback) {
support.get(this, 'http://localhost:5000', function(result){
setTimeout(callback, 1000);
});
});
this.Then('I should see a {stringInDoubleQuotes}', function (link, callback) {
support.findByBinding(this, link, function(result){
result.getText().then(function(text){
text.trim().toLowerCase().should.equal(link.trim().toLowerCase());
setTimeout(callback, 1000);
});
});
});
};
The Support.ts used in my project includes the following functionalities:
var support = require('../support');
var Support = function(){};
Support.prototype.get = function(sut, url, callback){
sut.browser.get(url).then(function(result) {
callback(result)
});
};
Support.prototype.findByBinding = function(sut, item, callback){
sut.browser.findElement(sut.by.binding(item)).then(function(result) {
callback(result);
});
};
// Additional functions omitted for brevity
module.exports = new Support();
This is the content of my Protractor.conf.js:
exports.config = {
// Configuration details here
};
And finally, here is an excerpt from my package.json showing dependencies and scripts used:
{
// Package.json contents here
}
Upon running the command "Protractor Protractor.conf.js", I encountered the following specific error:
// Error message details