Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ';失败:未定义不是函数';量角器_Javascript_Angularjs_Protractor_End To End - Fatal编程技术网

Javascript ';失败:未定义不是函数';量角器

Javascript ';失败:未定义不是函数';量角器,javascript,angularjs,protractor,end-to-end,Javascript,Angularjs,Protractor,End To End,我已经浏览了很多帖子,但找不到解决办法 HTML: progrator.conf.js: exports.config = { allScriptsTimeout: 11000, specs: [ 'specs/*.js' ], capabilities: { 'browserName': 'chrome' }, baseUrl: 'http://localhost:8000', framework: 'jasmine2', jasmin

我已经浏览了很多帖子,但找不到解决办法

HTML:

progrator.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
  }
};
这是来自终端的日志:

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.<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! 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
angular-seed@0.0.0预处理器/var/www/angularjs-seed
npm运行更新webdriver
棱角的-seed@0.0.0预更新webdriver/var/www/angularjs-seed
npm安装
棱角的-seed@0.0.0postinstall/var/www/angularjs seed
凉亭安装
棱角的-seed@0.0.0更新webdriver/var/www/angularjs-seed
webdriver管理器更新
selenium standalone是最新的。
chromedriver是最新的。
棱角的-seed@0.0.0量角器/var/www/angularjs-seed
量角器测试/e2e测试/dragotor.conf.js
正在启动selenium独立服务器。。。
[launcher]正在运行1个WebDriver实例
Selenium独立服务器在启动http://192.168.1.185:38493/wd/hub
起动
F
失败:
1) 单页Blogger E2E测试应该重定向到#/posts/1/sample-title1
信息:
失败:未定义不是函数
堆栈:
TypeError:undefined不是函数
反对。(/var/www/angularjs seed/test/e2e tests/specs/scenarios.js:21:19)
在runMicrotasksCallback上(node.js:337:7)
在进程中调用(node.js:355:11)
From:Task:在控制流中运行它(“应该重定向到#/posts/1/sample-title1”)
在attemptAsync(/var/www/angularjs seed/node_modules/jasmine core/lib/jasmine core/jasmine.js:1819:24)
在QueueRunner.run(/var/www/angularjs seed/node_modules/jasmine core/lib/jasmine core/jasmine.js:1774:9)
在/var/www/angularjs seed/node_modules/jasmine core/lib/jasmine core/jasmine.js:1801:16
在/var/www/angularjs seed/node_modules/jasmine core/lib/jasmine core/jasmine.js:1745:9
at Array.forEach(本机)
从异步测试:
错误
在套房。(/var/www/angularjs seed/test/e2e tests/specs/scenarios.js:18:3)
在addSpecsToSuite(/var/www/angularjs seed/node_modules/jasmine core/lib/jasmine core/jasmine.js:743:25)
在Env.descripe(/var/www/angularjs seed/node_modules/jasmine core/lib/jasmine core/jasmine.js:713:7)
在jasmineInterface.description(/var/www/angularjs seed/node_modules/jasmine core/lib/jasmine core/jasmine.js:3219:18)
反对。(/var/www/angularjs seed/test/e2e tests/specs/scenarios.js:5:1)
2个规格,1个故障
以1.679秒完成
正在关闭selenium独立服务器。
[launcher]0个WebDriver实例仍在运行
[launcher]chrome#1测试失败1次
[启动器]总体:1个失败的规范
[launcher]进程已退出,错误代码为1
npm错误!Linux 3.13.0-62-generic
npm错误!argv“node”“/usr/local/bin/npm”“运行”“量角器”
npm错误!节点v0.12.7
npm错误!npm v2.13.4
npm错误!代码失效循环
npm错误!棱角的-seed@0.0.0量角器:`量角器测试/e2e测试/dragotor.conf.js`
npm错误!退出状态1
npm错误!
npm错误!在角度上失败了-seed@0.0.0量角器脚本“量角器测试/e2e测试/dragrator.conf.js”。
npm错误!这很可能是角度种子包的问题,
npm错误!与npm本身无关。
npm错误!告诉作者此操作在您的系统上失败:
npm错误!量角器测试/e2e测试/dragotor.conf.js
npm错误!您可以通过以下方式获取他们的信息:
npm错误!角形种子
npm错误!上面可能还有其他日志输出。
npm错误!请在任何支持请求中包括以下文件:
npm错误/var/www/angularjs seed/npm-debug.log
第22:19行指向
posts.first()中的然后,然后(function(postElem){})


我不理解代码中的错误是什么,因为我在其中一篇堆栈溢出文章中进行了检查,并且通过量角器api指南,我们可以先链接
(),然后发生了突破性的更改。没有

改用:

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

令人惊叹的!!这确实奏效了。这个例子来自AngularJS:新手到忍者。
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.<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! 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
posts.first().element(by.tagName('a')).click();
expect(browser.getCurrentUrl()).toMatch('/posts/1/simple-title1');