Reputation: 43
I'm working in Angular2.
I would like to get an element that has a custom directive with protractor.
I have this element:
<span *ngIf="mobilePhoneControl.errors"
[msg-src-key]="mobilePhoneControl.errors.loctoolKeys[0]"
class="alert alert-warning"
role="alert">
Invalid Phone number.
</span>
I would like to get the element by searching the msg-src-key directive.
But I don't know how should I do that.
Thanks.
EDIT : Image
Upvotes: 1
Views: 417
Reputation: 473873
You can use a CSS selector:
$('[\\[msg-src-key\\]*=loctoolKeys]');
Here we need to use \\
to escape square brackets since they have a special meaning in CSS selector syntax, *=
means "contains".
$("selector")
is a shorthand for element(by.css("selector"))
.
Upvotes: 1