我正在使用来自 https://github.com/isteven/angular-multi-select 的 Angular 多选下拉列表.现在我想在 Protractor 中编写测试用例。
<div ng-show="!attribute.isMultivalued && page != 'view'"
class="select-group"
multi-select
input-model="typesDataDup"
output-model="attribute.types"
button-label="typeName"
item-label="typeName"
tick-property="ticked"
selection-mode="single"
helper-elements="filter"
is-disabled = "page == 'view'">
</div>
我无法使用模型发送数据,因为这里我们没有提到 ng-model。
谁能帮我写个测试用例?
最佳答案
您可以依赖其他属性并使用 by.css
找到元素。例如:
element(by.css('div.select-group'))
或
element(by.css('div[multi-select]'))
据我所见 angular-multi-select
source code ,选择选项用按钮元素表示。使用 element.all()
找到里面的所有按钮,然后点击所需的按钮,例如 Select All
:
element.all(by.css('div[multi-select] button')).then(function(options) {
options.forEach(function(option) {
option.getText().then(function(text) {
if (text.indexOf("Select All") != -1) {
option.click();
}
});
});
});
关于javascript - 如何使用 Protractor 测试 Angular 多选下拉列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27520961/