I have the following code which uses Chai, but when executed fails and console returns "TypeError: browser.getTitle is not a function."
My path to Globals.js is correct because if I do something like this, it works - expect('Test abc').toContain('abc')
. Please help.
const Globals = require('../utilities/Globals');
const browser = require('protractor');
const { Given } = require('cucumber');
// Chai
const globals = new Globals();
const expect = globals.expect;
Given('I am on google page with title {string}', function (title) {
return expect(browser.getTitle()).to.eventually.equal(title);
});
This is Globals.js -
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
class Globals {
constructor() {
this.expect = chai.expect;
chai.use(chaiAsPromised);
}
}
module.exports = Globals;