I've searched through multiple posts but haven't been able to find a solution.
HTML:
<div class="col-xs-3" ng-repeat="post in posts track by $index">
<div class="well">
<h3 class="postTitle">
<a ui-sref="singlePost({id:post.id,permalink:post.permalink})">
{{post.title}}
</a>
</h3>
<h5>By: {{post.author}} | {{post.datePublished}}</h5>
</div>
</div>
scenario.js:
'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');
});
});
});
});
protractor.conf.js:
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
}
};
This terminal log provides an overview of the process:
<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="07666960726b66752a74626263473729372937">[email protected]</a> preprotractor /var/www/angularjs-seed npm run update-webdriver <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="76171811031a17045b05131312364658465846">[email protected]</a> preupdate-webdriver /var/www/angularjs-seed npm install <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7f1e11180a131e0d520c1a1a1b3f4f514f514f">[email protected]</a> postinstall /var/www/angularjs-seed bower install <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fa9b949d8f969b88d7899f9f9ebacad4cad4ca">[email protected]</a> update-webdriver /var/www/angularjs-seed webdriver-manager update selenium standalone is up to date. chromedriver is up to date. <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="52333c35273e33207f2137373612627c627c62">[email protected]</a> 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.<anonymous> (/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.<anonymous> (/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.<anonymous> (/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! <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="aecfc0c9dbc2cfdc83ddcbcbcaee9e809e809e">[email protected]</a> protractor: `protractor test/e2e-tests/protractor.conf.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fa9b94... <p>Line 22:19 points to <strong>then</strong> in <code>posts.first().then(function(postElem) {});
.The issue seems to be related to the chaining of functions with
then
. I followed guidance from Stack Overflow and the Protractor API guide that indicate it should work, but encountering this error nonetheless. Any help or insight would be appreciated!