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();
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 \
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.)
As a basic rule, the subject is the person or thing doing something. The object is having something done to it.
Objects are identifiable entities that have a set of attributes, behaviour and state. Five examples of objects are car, pen, mobile, email, bank account.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With