量角器 - 如何引用具有无值属性的webelement?

问题描述 投票:2回答:1

给定具有此类标记的属性:

<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

angularjs protractor qa
1个回答
1
投票

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

label[r4e-toggle]

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

© www.soinside.com 2019 - 2024. All rights reserved.