Protractor: Find Element by Attribute

天涯浪子 提交于 2019-12-30 08:00:28

问题


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');

回答1:


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"]'));


来源:https://stackoverflow.com/questions/32826579/protractor-find-element-by-attribute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!