我正在试验量角器 e2e 测试角度应用程序,还没有想出如何检测一个元素是否有一个特定的类。
在我的示例中,测试单击提交按钮,现在我想知道 form [ name = “ getoffer”]是否具有 class。肮脏。解决方案可能是什么?
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
});
});