title: 'Failed: undefined is not a function' in protractor
body: <p>I have been through various posts but unable to find a solution.  </p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div class="col-xs-3" ng-repeat="post in posts track by $index"&gt;
      &lt;div class="well"&gt;
          &lt;h3 class="postTitle"&gt;
              &lt;a ui-sref="singlePost({id:post.id,permalink:post.permalink})"&gt;
                  {{post.title}}
              &lt;/a&gt;
          &lt;/h3&gt;
          &lt;h5&gt;By: {{post.author}} | {{post.datePublished}}&lt;/h5&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>scenario.js:</p>
  
  <pre><code>'use strict';
  
  /* https://github.com/angular/protractor/blob/master/docs/toc.md */
  
  describe('The Single Page Blogger E2E Test', function() {
    var ptor = browser; // browser === protractor.getInstance();
    // ptor.get('/'); //go to http://localhost:8000
  
    beforeEach(function() {
      ptor.get('app');
    });
  
   it('Should have 4 posts', function() {
     var posts = element.all(by.repeater('post in posts'));
     expect(posts.count()).toBe(4); // we have 4 hard coded posts
   });
  
  it('Should redirect to #/posts/1/sample-title1', function() {
    var posts = element.all(by.repeater('post in posts'));
  
    posts.first().then(function(postElem) {
      postElem.findElement(by.tagName('a')).then(function(a) {
        a.click(); //click the title link of 1st post
        expect(ptor.getCurrentUrl()).toMatch('/posts/1/simple-title1');
      });
    });
   });
  });
  </code></pre>
  
  <p>protractor.conf.js:</p>
  
  <pre><code>exports.config = {
    allScriptsTimeout: 11000,
  
    specs: [
      'specs/*.js'
    ],
  
    capabilities: {
      'browserName': 'chrome'
    },
  
    baseUrl: 'http://localhost:8000',
  
    framework: 'jasmine2',
  
    jasmineNodeOpts: {
      onComplete: null,
      isVerbose: true,
      showColors: true,
      includeStackTrace: true,
      defaultTimeoutInterval: 30000
    }
  };
  </code></pre>
  
  <p>This is the log from the terminal:</p>
  
  <pre><code>angular-seed@0.0.0 preprotractor /var/www/angularjs-seed
  npm run update-webdriver
  
  
  angular-seed@0.0.0 preupdate-webdriver /var/www/angularjs-seed
  npm install
  
  
  angular-seed@0.0.0 postinstall /var/www/angularjs-seed
  bower install
  
  
  angular-seed@0.0.0 update-webdriver /var/www/angularjs-seed
  webdriver-manager update
  
  selenium standalone is up to date.
  chromedriver is up to date.
  
  angular-seed@0.0.0 protractor /var/www/angularjs-seed
  protractor test/e2e-tests/protractor.conf.js
  
  Starting selenium standalone server...
  [launcher] Running 1 instances of WebDriver
  Selenium standalone server started at http://192.168.1.185:38493/wd/hub
  Started
  .F
  
  Failures:
  1) The Single Page Blogger E2E Test Should redirect to #/posts/1/sample-title1
  Message:
    Failed: undefined is not a function
  Stack:
  TypeError: undefined is not a function
      at Object.&lt;anonymous&gt; (/var/www/angularjs-seed/test/e2e-tests/specs/scenarios.js:21:19)
      at runMicrotasksCallback (node.js:337:7)
      at process._tickCallback (node.js:355:11)
  From: Task: Run it("Should redirect to #/posts/1/sample-title1") in control flow
      at attemptAsync (/var/www/angularjs-seed/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1819:24)
      at QueueRunner.run (/var/www/angularjs-seed/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1774:9)
      at /var/www/angularjs-seed/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1801:16
      at /var/www/angularjs-seed/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1745:9
      at Array.forEach (native)
  From asynchronous test: 
  Error
      at Suite.&lt;anonymous&gt; (/var/www/angularjs-seed/test/e2e-tests/specs/scenarios.js:18:3)
      at addSpecsToSuite (/var/www/angularjs-seed/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:743:25)
      at Env.describe (/var/www/angularjs-seed/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:713:7)
      at jasmineInterface.describe (/var/www/angularjs-seed/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:3219:18)
      at Object.&lt;anonymous&gt; (/var/www/angularjs-seed/test/e2e-tests/specs/scenarios.js:5:1)
  
  2 specs, 1 failure
  Finished in 1.679 seconds
  Shutting down selenium standalone server.
  [launcher] 0 instance(s) of WebDriver still running
  [launcher] chrome #1 failed 1 test(s)
  [launcher] overall: 1 failed spec(s)
  [launcher] Process exited with error code 1
  
  npm ERR! Linux 3.13.0-62-generic
  npm ERR! argv "node" "/usr/local/bin/npm" "run" "protractor"
  npm ERR! node v0.12.7
  npm ERR! npm  v2.13.4
  npm ERR! code ELIFECYCLE
  npm ERR! angular-seed@0.0.0 protractor: `protractor test/e2e-tests/protractor.conf.js`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the angular-seed@0.0.0 protractor script 'protractor test/e2e-tests/protractor.conf.js'.
  npm ERR! This is most likely a problem with the angular-seed package,
  npm ERR! not with npm itself.
  npm ERR! Tell the author that this fails on your system:
  npm ERR!     protractor test/e2e-tests/protractor.conf.js
  npm ERR! You can get their info via:
  npm ERR!     npm owner ls angular-seed
  npm ERR! There is likely additional logging output above.
  
  npm ERR! Please include the following file with any support request:
  npm ERR!     /var/www/angularjs-seed/npm-debug.log
  </code></pre>
  
  <p>Line 22:19 points to <strong>then</strong> in <code>posts.first().then(function(postElem) {});</code>.</p>
  
  <p>I am not understanding what's the mistake in the code as I have checked in one of the stack overflow posts and also through the protractor api guide that we can chain <code>first().then</code> &lt;-- like this. Can anyone please help me with this?</p>