<div id='messagesDiv'></div>
I want to test that this div
element is empty.
var messagesDiv = element(by.id('messagesDiv'));
expect(messagesDiv).to...
How would I achieve that?
<div id='messagesDiv'></div>
I want to test that this div
element is empty.
var messagesDiv = element(by.id('messagesDiv'));
expect(messagesDiv).to...
How would I achieve that?
Share Improve this question edited Nov 18, 2016 at 17:56 jeerbl 7,8675 gold badges26 silver badges39 bronze badges asked Oct 11, 2015 at 20:12 YorkshiremanYorkshireman 2,3432 gold badges23 silver badges38 bronze badges 4-
2
Check for
.getInnerHtml()
should do the trick – Michael Radionov Commented Oct 11, 2015 at 20:32 - Please confirm what test framework you are using Jasmine, Mocha etc.. as the syntax might be different dependent on the framework. – markyph Commented Oct 11, 2015 at 20:41
- test framework is Jasmine – Yorkshireman Commented Oct 12, 2015 at 17:37
- Any answer actually answered your question? – jeerbl Commented Aug 17, 2016 at 8:29
3 Answers
Reset to default 6I think this:
expect(messagesDiv.getText()).toBe('');
should do the trick. More information here.
Try
expect (messagesDiv.text).toBe('')
expect(messagesDiv.getText()).toMatch(/^\s*$/);
will handle spaces, tabs, line breaks, etc. that HTML treats as empty but really might not be in the raw HTML.