0

So I'm setting up page objects with my Protractor e2e tests, and straight away having an issue calling into those objects. I believe this should be simple, however I seem to be struggling.

Firstly, as soon as I start my test I am seeing the Chrome browser launch with the URL I have specified - for example, from a win 7 cmd prompt:

> protractor conf.js

However, after the browser launches I see this error in my cmd console:

Failures:
1) Launching the SAT Application Should display the correct browser title
  Message:
     Failed: indexPage.getTitle is not a function
  Stack:
     TypeError: indexPage.getTitle is not a function

Here are the implementation details:

* index.page.js *

module.exports = function () {
    this.get = function () {

        browser.get("http://localhost:64174/SAT.html");
        
    };
            
    this.getTitle = function () {
        return browser.getTitle();
    };
    
};
  • sat.index.spec.js *

var IndexPage = require('./pageObjects/dataCard.page.js');
var DataCardPage = require('./pageObjects/index.page.js');

describe('Launching SAT Application', function () {
    var indexPage = new IndexPage();
    var dataCardpage = new DataCardPage();
    
    beforeEach(function () {
        //indexPage.get;  // not working...
        
        browser.get("http://localhost:64174/sat.html");   // launch successful
    });

    
    it('Should display the correct browser title', function () {        
       expect(indexPage.getTitle()).toBe('My awesome applicatoin'); // not found error in cmd console
    });
 
});
  • conf.js *

exports.config = {
    directConnect: true,

    capabilities: {
        'browserName': 'chrome'
    },
    framework: 'jasmine',

    specs: ['sat.index.spec.js'],

    suites: {

    },
    
    jasmineNodeOpts: {
        defaultTimeoutInterval: 30000
    }
};

I realize this should be a simple page object implementation using Protractor, but I must be missing something.

Advice greatly appreciated again...

Bob

bob.mazzo
  • 5,183
  • 23
  • 80
  • 149
  • Wait, I think I see the error now that I posted this. My require() statements are switched in advertently. IndexPage and DataCardPage are pulling in the opposite files of each other. Oh boy. – bob.mazzo Sep 23 '16 at 15:52

1 Answers1

1

I am not sure if you have spotted this, you have got the imports wrongly mapped

var IndexPage = require('./pageObjects/dataCard.page.js');
var DataCardPage = require('./pageObjects/index.page.js');
AdityaReddy
  • 3,625
  • 12
  • 25
  • Yup. I just literally spotted it. But since you spotted it 30 secs ahead of me, I think it's fair that I choose your answer. I so much appreciate your response. – bob.mazzo Sep 23 '16 at 15:53