Reputation: 847
I am writing protractor tests for my form validation.
I want to test that an chrome validation popup appears when a required filed is not set in the form.
When a filed is not set i get "Please fill out this field" from chrome.
I want to do something like this :
submitBtn = element(by.id('submitBtn'));
submitBtn.click();
validationMessage = ???
expect((validationMessage ).getText()).toBe('Please fill out this field');
How to get it ?
Upvotes: 3
Views: 645
Reputation: 6940
You don't need to test the internal implementations of Chrome. The Chrome developers would have had tests to cover the hiding and showing of popups.
You test that your form is written correctly by finding the element that the required
attribute should be set on, and asserting that it is indeed set.
myInput = element(by.id('myInput'));
expect(myInput.getAttribute('required')).toBeDefined();
Upvotes: 1