Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor: Find Element by Attribute

I have the following element i need to find for testing:

<div class="alert alert-danger" role="alert" ng-show="notValid">Zugangsdaten eingeben</div>

How can i find this element to check visibility (ng-show)?

The ng-show attribute and value are the only attribute and value to identify the element uniquely. The class is used in many elements...

I am searching for something like:

var notValid = element(by.Attribute('ng-show', 'notValid');
like image 799
matthias Avatar asked Sep 28 '15 15:09

matthias


1 Answers

You can find it by.css():

element(by.css('div[ng-show=notValid]'));
$('div[ng-show=notValid]');  // shortcut for the above expression

Or, by.xpath():

element(by.xpath('//div[@ng-show="notValid"]'));
like image 192
alecxe Avatar answered Oct 31 '22 15:10

alecxe