Tuesday, 6 January 2015

angularJS Protractor e2e Testing TypeError: Object [object Object] has no method 'input' --- A breaking change of protractor 1.5.0



http://stackoverflow.com/questions/27690814/object-object-has-no-method-getinstance-when-trying-to-run-protractor-tests


After you update protractor to 1.5.0 you will have this issue

1
2
3
4
5
6
7
8
9
10
11
Failures: 1) Application page title should be xxx Message: TypeError: Object #<Object> has no method 'getInstance' Stacktrace: TypeError: Object #<Object> has no method 'getInstance' at [object Object].<anonymous> (/Users/peterwang/Documents/dev/code/xxx/test/e2e/app.js:6:22) ==== async task ==== Asynchronous test function: beforeEach() Error at [object Object].<anonymous> (/Users/peterwang/Documents/dev/code/xxx/test/e2e/app.js:5:2) at Object.<anonymous> (/Users/peterwang/Documents/dev/code/xxx/test/e2e/app.js:1:63)





This is a breaking change of protractor 1.5.0

You project may also risked by this updating if you use this in your package.json file


1
2
3
4
5
6
7
8
9
10
11
"devDependencies": { "chai": "^1.9.2", "chai-as-promised": "^4.1.1", "cucumber": "^0.4.4", "grunt-karma": "^0.9.0", "grunt-protractor-runner": "^1.1.4", "karma": "^0.12.17", "karma-chrome-launcher": "^0.1.4", "karma-jasmine": "^0.1.5", "karma-junit-reporter": "^0.2.2", "karma-mocha": "^0.1.6", "karma-phantomjs-launcher": "^0.1.4", "protractor": "^1.3.1", "protractor-cucumber": "^0.1.2", "sinon": "^1.11.0" },



According to :   https://docs.npmjs.com/misc/semver   or you can also get some clue by "http://stackoverflow.com/questions/22343224/difference-between-tilde-and-caret-in-package-json" posts here are not very right, but you can get the idea about "˜" and "ˆ".


You project will have no problem if you have done "npm install", but you will have issue if you delete node_modules/.  that means your codeship and heroku project should have no problem.

If you compile your project on a new env you will definitely have this issue.




Solutions:


Solution 1.  use "var ptor = browser;" to replace "var ptor = protractor.getInstance();"


Solution 2. change your package.json file to:

  "devDependencies": {
    "chai": "^1.9.2",
    "chai-as-promised": "^4.1.1",
    "cucumber": "^0.4.4",
    "grunt-karma": "^0.9.0",
    "grunt-protractor-runner": "^1.1.4",
    "karma": "^0.12.17",
    "karma-chrome-launcher": "^0.1.4",
    "karma-jasmine": "^0.1.5",
    "karma-junit-reporter": "^0.2.2",
    "karma-mocha": "^0.1.6",
    "karma-phantomjs-launcher": "^0.1.4",
    "protractor": "<1.5.0",
    "protractor-cucumber": "^0.1.2",
    "sinon": "^1.11.0"
  },











































No comments:

Post a comment