[SOLVED] Protractor example include external js class definition

So you have an external PageObject class you would like to include:
This is your PageObject placed in the AngularHomepage.js file
[code language=”javascript”]
exports.AngularHomepage = function() {
this.nameInput = element(by.model(‘yourName’));
this.greeting = element(by.binding(‘yourName’));</code>

this.get = function() {
browser.get(‘http://www.angularjs.org’);
};

this.setName = function(name) {
this.nameInput.sendKeys(name);
};
};
[/code]
The main script is (specs.js):
[code language=”javascript”]
var homepage = require(‘./AngularHomepage.js’);
describe(‘angularjs homepage’, function() {
it(‘should greet the named user’, function() {
var angularHomepage = new homepage.AngularHomepage();
angularHomepage.get();</code>

angularHomepage.setName(‘Julie’);

expect(angularHomepage.greeting.getText()).toEqual(‘Hello Julie!’);
});
});
[/code]

Leave a Reply

Your email address will not be published. Required fields are marked *