量角器-如何引用具有无值属性的网络元素?

时间:2018-09-12 17:55:59

标签: angularjs protractor qa

给出具有这种标记类型的属性:

<label r4e-toggle="" class="sm ng-scope ng-isolate-scope r4e-toggle" 
       ng-attr-disabled="{{audit.profileOptedOut || undefined}}" 
       tooltip="Opted In" 
       ng-if="audit.source.listing.correctable &amp;&amp; audit.hasListingCorrecting">
    <input type="checkbox" ng-model="audit.optedOut" ng-true-value="false"
           ng-false-value="true" ng-click="location.optOutAudit($index, audit)" 
           ng-disabled="location.optOutDisabled" 
           class="ng-pristine ng-untouched ng-valid">
       <span class="slider"></span>
</label>

如何通过空白的“ r4e-toggle”引用它?

在Google Dev工具中显示: element markup in dev tools

1 个答案:

答案 0 :(得分:1)

以相同的方式访问属性,无论是否存在值。可以提供更具体的值,但您只需在方括号中使用属性选择器即可。

label[r4e-toggle]

https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors