如何测试输入字段是否与量角器不聚焦?我正在这样做:
it('should focus email field', function(){
expect(element(by.model('login.email')).getAttribute('id')).toEqual(browser.driver.switchTo().activeElement().getAttribute('id'));
});
这似乎适用于 chrome,但该测试在 Firefox 中失败。有任何想法吗?
这是失败消息:
[firefox #1] 2) Login page should focus email field
[firefox #1] Message:
[firefox #1] Expected 'login' to equal ''.
[firefox #1] Stacktrace:
[firefox #1] Error: Failed expectation
[firefox #1] at [object Object].<anonymous> (/Users/Jason/Desktop/app/test/e2e/login-spec.js:38:69)
[firefox #1]
这是我的测试脚本:
describe('Login page', function() {
var loginURL = 'http://localhost:8090/app/#/login';
var loginEmailField = 'login-email';
beforeEach(function() {
browser.get(loginURL);
});
it('should focus email field', function(){
expect(element(by.id(loginEmailField)).getAttribute('id')).toEqual(browser.driver.switchTo().activeElement().getAttribute('id'));
});
});