Reputation: 1141
I'm fairly new to Protractor and am having some difficulty in obtaining the text from an error box that displays only when a certain condition is met.
I am sure that it is just a syntax issue. Below is the line I am using to attempt to get the "text" that displays in the box, and compare it to a preset static string.
expect(element(by.css('[ng-switch-default=""]')).getAttribute('value')).toEqual(expected_error_message);
I am receiving the message back:
Message: Expected null to equal 'User with login [email protected]' already exists.'
So basically there is nothing to compare strings against because the value that "getAttribute('value') is supposed to grab is returning null".
The block of HTML that I am referencing is found below:
<div ng-class="config.message" ng-switch="" on="toaster.bodyOutputType" class="toast-message"><div ng-switch-default="" class="ng-binding">User with login '[email protected]' already exists.</div></div>
Upvotes: 2
Views: 9036
Reputation: 752
I have fallen to another hole. I accidentally selected label element, so sendKeys() method works, but getAttribute('value') has not.
Upvotes: 0
Reputation: 6034
It looks like your message is not an attribute, but the text for the div. Try:
expect(element(by.css('[ng-switch-default=""]')).getText()).toEqual(expected_error_message);
Upvotes: 5