如何获取元素的自定义模型属性

How to get custom model attribute of element

如何在量角器端到端测试中获取该元素的模型selected-model

<div id="abc" 
     ng-dropdown-multiselect="" 
     options="dropdown.result.options"
     selected-model="dropdown.result.model" 
     extra-settings="dropdown.result.settings"
     translation-texts="dropdown.result.texts">
</div>

要获取模型名称 - 定位元素,例如,使用 by.id() 定位器,然后调用 getAttribute():

var elm = element(by.id('abc'));
elm.getAttribute("selected-model").then(function (model) {
    console.log(model);
});

或者,如果你想获取模型值本身,你可以evaluate()它:

elm.evaluate("dropdown.result.model").then(function (modelValue) {
    console.log(modelValue);
});