问题 I'm dealing with below element and having trouble with getting the error message text in to a variable. <mat-error _ngcontent-c16="" class="mat-error ng-star-inserted" id="error-email-required" role="alert" style=""> Email is a required field </mat-error> Catching the element is straight forward. var emailReqiredLabel = element(by.id('error-email-required')); I tried below options but all printing as >> visible error message is : [object Object] var errormsg = emailReqiredLabel.getText()