我在登录页面上为验证凭据而编写的代码是:
describe('Login',function() {
var loginURL;
var email=element(by.id("email"));
var password=element(by.id("password"));
var LoginButton=element(by.buttonText("Sign in"));
});
it('should redirect to login page',function() {
browser.get('https://pacific-meadow-5124-dev-test.herokuapp.com');
loginURL = browser.getCurrentUrl();``
expect(browser.getCurrentUrl()).toEqual(loginURL);
});
it('should warn on wrong/missing values',function(){
email.clear();
password.clear();
password.sendkeys('test');
loginButton.click();
expect(error.getText()).toMatch('missing email');
email.sendkeys('test');
loginButton.click();
expect(error.gettext()).toMatch('invalid email');
email.sendkeys('pavanpesse11@gmail.com');
password.clear();
loginButton.click();
expect(error.getText()).toMatch('missing password');
});
it('should accept a valid email address and password', function() {
email.clear();
password.clear();
email.sendKeys('pavanpesse11@gmail.com');
password.sendKeys('goalsr123');
loginButton.click();
expect(browser.getCurrentUrl()).not.toEqual(loginURL);
});
我无法执行上述代码,收到错误消息jasmine.suite() required
如下图所示:
Message:
Error: jasmine.Suite() required
Stacktrace:
Error: jasmine.Suite() required
at new jasmine.Spec (C:\Users\GOALSR3\AppData\Roaming\npm\node_modules\protr
actor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:2326:11)
at jasmine.Env.it (C:\Users\GOALSR3\AppData\Roaming\npm\node_modules\protrac
tor\node_modules\minijasminenode\lib\jasmine-1.3.`enter code here`1.js:966:14)
at jasmine.Env.(anonymous function) [as it] (C:\Users\GOALSR3\AppData\Roamin
g\npm\node_modules\protractor\node_modules\minijasminenode\lib\async-callback.js
:26:50)
at global.it (C:\Users\GOALSR3\AppData\Roaming\npm\node_modules\protractor\n
ode_modules\minijasminenode\lib\index.js:15:29)
at C:\Users\GOALSR3\AppData\Roaming\npm\node_modules\protractor\node_modules
\jasminewd\index.js:119:11
at Object.<anonymous> (C:\Users\GOALSR3\AppData\Roaming\npm\node_modules\pro
tractor\example\Log_spec.js:9:1)
Finished in 0.018 seconds
1 test, 1 assertion, 1 failure
我尝试验证登录但无法使用量角器进行验证。
答案 0 :(得分:12)
将it
- 块放在describe
- 阻止内。
答案 1 :(得分:3)
你必须首先使用jasmine函数描述并将所有测试包含在内:
describe('my test suite', function() {
// Here all your it tests
})