这是我的conf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['C:\\Users\\meiyer\\Desktop\\Protractor_Tests\\specs\\specs.js'],
baseUrl: 'https://devcp.us.sunpowermonitor.com/#/dashboard',
// Framework to use. Jasmine is recommended.
framework: 'jasmine',
//Options to be passed to Jasmine-node.
jasmineNodeOpts: {
onComplete: null,
isVerbose: true,
showColors: true,
includeStackTrace: true
}
};
这是我的specs.js
var elhLoginpage = {
nameInput : element(by.model('user.UserName')),
passInput : element(by.model('model')),
submitButton :element(by.buttonText('sign in')),
setEmail: function(email) {
this.nameInput.sendKeys(email);
},
setPass: function(password) {
this.passInput.sendKeys(password);
},
clickSubmit:function(){
this.submitButton.click();
}
};
var elhHomepage = {
greetingText : element(by.css('.greeting-des')),
getgreetingText: function() {
this.greetingText.text();
}
};
describe('elhLoginpage login test', function() {
it('should land on homepage when valid username and password is entered',
function(){
elhLoginpage.setEmail('lease_id@test.com');
elhLoginpage.setPass('sun');
elhLoginpage.clickSubmit();
expect(elhHomepage.getgreetingText().toEqual('Hello lease');
});
});
我正在node.js命令提示符上执行测试,因为 - >量角器conf.js.我正在低于堆栈跟踪。从下面的信息 - 我无法调试任何.js文件上的哪个行号发生了问题。有没有办法在stacktrace上激活这些信息?
Stacktrace -
C:\Users\meiyer\Desktop\Protractor_Tests>protractor conf.js
[15:40:56] I/hosted - Using the selenium server at
http://localhost:4444/wd/hub
[15:40:56] I/launcher - Running 1 instances of WebDriver
[15:40:58] E/launcher - Error: SyntaxError: missing ) after argument list
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at
C:\Users\meiyer\AppData\Roaming\npm\node_modules\protractor\node_modules\
jasmine\lib\jasmine.js:71:5
at Array.forEach (native)
at Jasmine.loadSpecs
C:\Users\meiyer\AppData\Roaming\npm\node_modules\protr
actor\node_modules\jasmine\lib\jasmine.js:70:18)
[15:40:58] E/launcher - Process exited with error code 100
答案 0 :(得分:3)
不幸的是,对于语法问题,这可能是量角器中的常见错误。在没有代码缩进的情况下很难判断,但错误是缺少)
,并且在最后expect
语句中看起来很快就会丢失一个。
你有:
expect(elhHomepage.getgreetingText().toEqual('Hello lease');
应该是:
expect(elhHomepage.getgreetingText()).toEqual('Hello lease');
您可以使用像ES Lint这样的短语来快速查找这样的语法错误。