【发布时间】:2013-12-14 14:37:41
【问题描述】:
我正在尝试使用 Protractor 对 Angular 应用程序进行 e2e 测试,但还没有弄清楚如何检测元素是否具有特定类。
在我的例子中,测试点击了提交按钮,现在我想知道 form[name="getoffer"] 是否有类 .ngDirty。有什么解决办法?
describe('Contact form', function() {
beforeEach(function(){
browser.get('http://localhost:9000');
element(by.linkText('Contact me')).click();
});
it('should fail form validation, all fields pristine', function() {
element(by.css('.form[name="getoffer"] input[type="submit"]')).click();
expect(element(by.name('getoffer'))).toHaveClass('ngDirty'); // <-- This line
});
});
【问题讨论】:
标签: angularjs protractor