我正在尝试使用 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
});
});