由于某些原因,即使在禁用的html锚标记上,elmFinder.isEnabled()也会解析为true.
我已经设置了test site to prove this.
当IMHO不应该进行以下量角器测试失败
describe('isEnabled() should resolve to true on any html element', function() {
var checkElm = element(by.model('checked'));
var btnElm = element(by.model('button'));
var linkElm = element(by.model('link'));
it('open test page', function() {
browser.get('http://run.plnkr.co/plunks/oExtzK/');
});
it('should be enabled by default: button & link', function() {
expect(btnElm.isEnabled()).toBeTruthy();
expect(linkElm.isEnabled()).toBeTruthy();
});
it('clicks the checkBox to switch enabled/disabled status', function() {
checkElm.click();
});
it('button should Now be disabled', function() {
expect(btnElm.isEnabled()).toBeFalsy();
});
// This fails
it('link should Now be disabled', function() {
expect(linkElm.isEnabled()).toBeFalsy();
});
});
输出:
Describe: isEnabled() should resolve to true on any html element
001 - open test page ✔
002 - should be enabled by default: button & link ✔
003 - clicks the checkBox to switch enabled/disabled status ✔
004 - button should Now be disabled ✔
005 - link should Now be disabled Failed!
Message: Expected true to be falsy.
Stacktrace: Error: Failed expectation
解决方法:
will generally return true for everything but disabled input elements.
所以我想想,解决方法是使用否定elm.getAttribute(‘disabled’)代替elm.isEnabled()
it('link should Now be disabled', function() {
expect(linkElm.getAttribute('disabled')).toBeTruthy();
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。