我在注销功能上编写测试用例。当代码执行时,show element在点处不可点击。
element.all(by.css('.dropdown-user a')).then(function(items) {
items[0].click();
ptor.sleep(500);
});
view.html
<li class="dropdown dropdown-user">
<a href="#" class="dropdown-toggle" id="logout" data-toggle="dropdown" data-hover="dropdown" data-close-others="true">
<img alt="" class="img-circle" src="../../assets/admin/layout/img/avatar3_small.jpg"/>
<span class="username username-hide-on-mobile">
</span>
<i class="fa fa-angle-down"></i>
</a>
<ul class="dropdown-menu">
<li>
<a href=""><i class="icon-user"></i> My Profile </a>
</li>
<li>
<a href=""><i class="icon-calendar"></i> My Calendar </a>
</li>
<li>
<a href=""><i class="icon-envelope-open"></i> My Inbox <span class="badge badge-danger">3 </span></a>
</li>
<li>
<a href=""><i class="icon-rocket"></i> My Tasks <span class="badge badge-success">7 </span></a>
</li>
<li class="divider">
</li>
<li>
<a href=""><i class="icon-lock"></i> Lock Screen </a>
</li>
<li ng-click="logout()">
<a href=""><i class="icon-key"></i> Log Out </a>
</li>
</ul>
</li>
有没有办法操作这个下拉列表?能告诉我如何编写代码进行测试吗?
答案 0 :(得分:0)
您可以尝试使用xpath方式 // li [contains(@class,&#39; dropdown&#39;)] / ul [contains(@class,&#39; dropdown&#39;)]。
我不确定这是否是您正在寻找的