0

I have this in a file page.js

var Page = function () {
    this.examStatus = element(by.id('examStatusSelect'));
    this.examType = element(by.id('examTypeSelect'));
}
module.exports = new Page();

and this in file admin.js

var Admin = function () {
    this.newButton = element(by.id('newButton'));
    this.saveButton = element(by.id('saveButton'));
}
module.exports = new Admin();

Is there a way that I could do something like this in the page.js file

var admin = require('./admin.js');

so as to bring in the items contained in admin.js and make them available as part of the Page function so that I effectively have four properties in the Page function instead of two?

I know I can bring in elements but can I have them appear just like those in admin.js so that I can do:

page.examStatus
page.examType
page.newButton
page.saveButton

From a script that uses page.js ?

1
  • Admin should be a mixin of page, or it should inherit? This has nothing to do with requires / includes. Commented Jul 11, 2014 at 15:52

1 Answer 1

1

It sounds like either Page needs to inherit from Admin, or vice versa (if "Admin" is-a "Page"), possibly as a mixin. Unless the properties of Admin need to be static, but this does not sound like what you want. This has nothing to do with requires or including files, just vanilla Javascript inheritance.

Sign up to request clarification or add additional context in comments.

3 Comments

I am not sure how I can do the inheritance howevr and I don't know what a mixin is.
@SamanthaJ then research those things? I'm just saying file "including" is not the issue.
@SamanthaJ by research I mean start by googling "mixin" or "javascript mixin." I'm fully aware you don't know what one is given your question, but it's such an easy-to-google term I don't really need to write up more about it. There's plenty of guides on inheritance in javascript, so you don't need someone to write a brand new explanation of that either.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.