量角器-当子元素也是页面中其他位置的主要元素时,如何在元素内查找元素 [英] Protractor - How to find an element inside an element when sub element is also a main element somewhere else in a page

查看:65
本文介绍了量角器-当子元素也是页面中其他位置的主要元素时,如何在元素内查找元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

这篇关于量角器-当子元素也是页面中其他位置的主要元素时,如何在元素内查找元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆