量角器 - 如何选择重度嵌套的下拉元素? [英] Protractor - how to select heavily nested dropdown element?
本文介绍了量角器 - 如何选择重度嵌套的下拉元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在测试的网站有一个下拉菜单,其中包含以下代码:
The site I am testing has a dropdown menu with the following code:
<ul class="nav navbar-nav navbar-right" data-ng-show="authentication.user">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span data-ng-bind="authentication.user.displayName" class="ng-binding">Testy McTesterson</span> <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li>
<a href="/#!/userprofile">View Profile</a>
</li>
<li>
<a href="/#!/settings/profile">Edit Profile</a>
</li>
<li id="h_manage_social_accounts">
<a href="/#!/settings/accounts">Manage Social Accounts</a>
</li>
<li data-ng-show="authentication.user.provider === 'local'" class="">
<a href="/#!/settings/password">Change Password</a>
</li>
<li class="divider"></li>
<li>
<a href="/auth/signout">Signout</a>
</li>
</ul>
</li>
</ul>
如何让量角器点击下拉菜单中的Signout等链接?
How can I get protractor to click the links like "Signout" within the dropdown menu?
推荐答案
首先,您需要点击切换按钮,然后从下拉列表中选择元素:
First, you need to click the toggle button, then choose the element from the dropdown:
element(by.css('li.dropdown > a.dropdown-toggle')).click();
element(by.linkText('Signout')).click();
这篇关于量角器 - 如何选择重度嵌套的下拉元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文