title: How to test if an element has class using Protractor?
body: <p>I'm trying out Protractor to e2e test Angular app and haven't figured out how to detect if an element has a specific class or not.</p>
  
  <p>In my case, the test clicks on submit button and now I want to know if form[name="getoffer"] has class .ngDirty. What may be the solutions?</p>
  
  <pre><code>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'); // &lt;-- This line
      });
  });
  </code></pre>