量角器中的“失败:未定义不是函数”

rash.tay

我经历过各种职位,但找不到解决方案。

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>

censing.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
  }
};

这是来自终端的日志:

[email protected] preprotractor /var/www/angularjs-seed
npm run update-webdriver


[email protected] preupdate-webdriver /var/www/angularjs-seed
npm install


[email protected] postinstall /var/www/angularjs-seed
bower install


[email protected] update-webdriver /var/www/angularjs-seed
webdriver-manager update

selenium standalone is up to date.
chromedriver is up to date.

[email protected] 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! [email protected] protractor: `protractor test/e2e-tests/protractor.conf.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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

22:19线点,然后posts.first().then(function(postElem) {});

我不了解代码中的错误,因为我已经在堆栈溢出帖子之一中以及通过量角器api指南进行了检查,这样我们就可以链接first().then<-了。谁能帮我这个忙吗?

ec

发生了重大变化。element.then()从2.0.0开始没有

改用:

posts.first().element(by.tagName('a')).click();
expect(browser.getCurrentUrl()).toMatch('/posts/1/simple-title1');

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

量角器-TypeError:未定义不是函数

量角器 - 失败:道具未定义

使用量角器“ TypeError:未定义不是函数”

量角器图函数返回未定义

量角器中的ExpectedConditions未定义

量角器中的返回值未定义

量角器-描述未定义

量角器:未定义:Stacktrace

以下函数量角器打字稿的返回值未定义

在 onPrepare 中未定义量角器浏览器

量角器元素(..)从单独的文件返回未定义

量角器-无法读取未定义的属性'$$ testability'

量角器2.5.1 ReferenceError:未定义testFn

量角器:未定义的 ExpectedConditions.elementToBeClickable

为什么在我的量角器测试用例中未定义webdriver?

量角器中API响应后的JS变量未定义错误

如何断言在量角器中未定义绑定的值?

在量角器Jasmine中获得“预期未定义为假”

量角器:失败:row.findElement不是函数

无法使用 Typescript 在量角器中解决“失败:每个键必须是多个字符串;未定义”

即使从console.log()打印正确的值,从黄瓜stepdefinition调用时,javascript量角器函数仍返回未定义的

对Liferay中存储的角度应用程序执行量角器测试时出现“未定义角度”错误

量角器和appium-无法读取未定义的属性

量角器将变量值显示为“未定义”

量角器:httpGet 未定义;需要来自超链接的响应代码

量角器:TypeError:无法调用未定义的方法“ click”

等待量角器与页面同步时出错:“ window.angular未定义

无法遍历比较文本值的数组,使用量角器未定义结果

量角器-未知错误:使用by.model时未定义角度