量角器-当子元素也是页面中其他位置的主要元素时,如何在元素内查找元素

量角器-当子元素也是页面中其他位置的主要元素时,如何在元素内查找元素

问题描述:

<div class="base-view app-loaded" data-ng-class="cssClass.appState">
<div class="ng-scope" data-ng-view="">
<div class="ng-scope" data-ng-include="'partial/navigation/navigation.tpl.html'">
<div class="feedback-ball feedback-ball-show feedback-ball-big" data-ng-class="feedback.cls" data-ng-click="outside($event)" data-feedback-ball="">
<span class="close-button"></span>
<h2 class="ng-binding">Welcome to Garbo</h2>
<div class="ng-scope ng-binding" data-ng-bind-html="feedback.html" data-ng-if="feedback.html">
<p>Here you can play in style in a safe and secure environment.</p>
<p>
<a class="btn" href="/account">My Account</a>
<a class="btn" href="/deposit">Deposit</a>
</p>
</div>
</div>
</div>

我想找到并单击data-ng-bind-html ="feedback.html"内的/account按钮,我可以找到data-ng-bind-html ="feedback.html",但找不到帐户按钮在里面.当我尝试查找帐户按钮时,页面出现多个帐户按钮,这给我带来了错误,因此请更具体.

I want to find and click /account button inside data-ng-bind-html="feedback.html", I can find data-ng-bind-html="feedback.html" but I could not find account button inside it. when I try to find account button, it gives me error that page has multiple account button so be more specific.

我尝试了element.().element(),但是没有用,请帮忙

I tried element.().element() but it didnt work, please help

element calls can be chained to find elements inside other elements, so your element().element() solution should work.

或者,您可以构造一个 xpath表达式以到达相应div内的链接:

Alternatively, you can construct an xpath expression to reach the link inside the appropriate div:

element(by.xpath('//div[@data-ng-bind-html = "feedback.html"]//a[@href = "/account"]'))