gpt4 book ai didi

javascript - Protractor - 从 Bootstrap 下拉列表中选择

转载 作者:行者123 更新时间:2023-11-29 18:05:13 25 4
gpt4 key购买 nike

我有一个 Bootstrap single-button dropdown我想使用 Protractor 单击下拉列表中出现的选项之一。我该如何实现?

               <div class="btn-group" ng-if="!persist.edit" dropdown>
<button type="button"
class="btn btn-default"
dropdown-toggle>
<span translate="GENERAL.ACTIONS"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">

<!-- Check In -->
<li role="presentation">
<a ng-click="checkIn()"
role="menuitem"
tabindex="-1"
translate="ITEMS.LIST.BUTTON_CHECK_ITEM_IN">
</a>
</li>


<!-- Check Out -->
<li role="presentation"">
<a ng-click="checkOut()"
role="menuitem"
tabindex="-1"
translate="ITEMS.LIST.BUTTON_CHECK_ITEM_OUT"
translate-value-length="1">
</a>
</li>
</ul>
</div>

我试过了(调用了下拉菜单,但点击失败):

it('Should click Actions button and show dropdown', function(){
element(by.buttonText("Actions")).click();
browser.sleep(1000);
});
it('Should click the Check Item Out dropdown option and change status to checked out', function(){
element(by.css('[value="ITEMS.LIST.BUTTON_CHECK_ITEM_OUT"]')).click();
});

最佳答案

首先,单击“下拉切换”按钮打开下拉菜单。然后,选择一个选项:

var dropDown = element(by.css("div[dropdown]"));
dropDown.element(by.css("button[dropdown-toggle]")).click();
dropDown.element(by.css("a[ng-click*=checkIn]")).click(); // Check In

工作代码:

    element(by.buttonText("Actions")).click(); 
element(by.css('[ng-click="]checkIn()"]')).click(); // Check In

关于javascript - Protractor - 从 Bootstrap 下拉列表中选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31843503/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com