我正在尝试使用Protractor进行端到端测试Angular应用程序,但还没有弄清楚如何检测元素是否具有特定的类。
在我的情况下,测试会单击提交按钮,现在我想知道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
});
});