Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object #<Object> has no method 'getInstance' when trying to run Protractor tests

When I am attempting to run my Protractor tests from the command line all of my tests fail because whenever I try to access the protractor object it does not have the methods I need. The exact error is:

TypeError: Object # has no method 'getInstance'

So this seems to have been a reported and fixed issue, yet I cannot seem to resolve my particular situation. It also seems to be semi-related to this question, but because it arose for me after updating my node_modules I feel like my underlying issue is different. Up until updating my Protractor everything worked just fine.

I installed it globally and used npm link protractor to link my local instance to my global instance (located at /usr/local/lib/node_modules/protractor), but I still for the life of me cannot figure out what is wrong.

The exact code where I'm calling protractor is a page object file that looks like:

module.exports = function() {

    var ptor = protractor.getInstance();

    this.get = function() {
        browser.get('http://localhost');
        this.title = ptor.getTitle();
    };

};

The code instantiating the page object is as follows:

var Login = require('./pageObjects/Login.po.js');
...
var LoginPage = new Login();
like image 335
Aaron Avatar asked Dec 29 '14 14:12

Aaron


People also ask

What do you mean of object?

1 : something material that may be perceived by the senses. 2 : something mental or physical toward which thought, feeling, or action is directed. object. noun. ob·​ject | \ ˈäb-jikt \

What is object and example?

An object is a noun (or pronoun) that is acted upon by a verb or a preposition. There are three kinds of object: Direct Object (e.g., I know him.) Indirect Object (e.g., Give her the prize.) Object of a Preposition (e.g., Sit with them.)

What is a subject vs object?

As a basic rule, the subject is the person or thing doing something. The object is having something done to it.

What are objects give five examples?

Objects are identifiable entities that have a set of attributes, behaviour and state. Five examples of objects are car, pen, mobile, email, bank account.


1 Answers

You don't need to call protractor.getInstance() anymore, use globally-available browser object:

this.title = browser.getTitle();

And, yes, this was a breaking change in 1.5.0, see:

  • Breaking Changes
like image 179
alecxe Avatar answered Nov 14 '22 21:11

alecxe