【发布时间】:2014-01-25 14:35:06
【问题描述】:
使用Protractor as a library
无法要求引用 Jasmine。引用expect 方法返回输出Cannot call method 'expect' of null。
更新代码以反映 cmets:
var protractor = require('protractor');
require('protractor/node_modules/minijasminenode');
require('protractor/jasminewd'); // output: jasmine is undefined (this error can only be seen if the above line is commented out)
//expect(true).toBe(true); // output: Cannot call method 'expect' of null
var driver = new protractor.Builder()
.usingServer('http://localhost:4444/wd/hub')
.withCapabilities(protractor.Capabilities
.chrome()).build();
var ptor = protractor.wrapDriver(driver);
ptor.get('http://www.angularjs.org').then(function(){
ptor.element(protractor.By.model('yourName')).sendKeys('test')
.then(console.log('success')); // output: success
ptor.getCurrentUrl().then(function(url){
console.log(url); // output: http://www.angularjs.org
expect(url).toContain('angular'); // output: Cannot call method 'expect' of null
});
});
【问题讨论】:
标签: node.js angularjs jasmine protractor jasmine-node