Javascript 量角器中的动态属性值元素定位器

Javascript 量角器中的动态属性值元素定位器,javascript,function,attributes,protractor,Javascript,Function,Attributes,Protractor,当我添加一个带有某个值的新按钮时,它会被动态地添加到DOM中。此按钮的非角度HTML元素为: <li class="ui-state-default droppable ui-sortable-handle" id="element_98" data-value="2519"> 25.19 EUR <button type="button" class="btn btn-default removeParent"> <span class="glyphico

当我添加一个带有某个值的新按钮时,它会被动态地添加到DOM中。此按钮的非角度HTML元素为:

<li class="ui-state-default droppable ui-sortable-handle" id="element_98" data-value="2519">
    25.19 EUR
<button type="button" class="btn btn-default removeParent">
<span class="glyphicon glyphicon-remove" aria-hidden="true">
</span>
</button>
</li>
在spec文件中,我调用此函数,如下所示:

var twentyEurosButtonAttributeValue = '2000';

describe("....
    it ("...
        expect(predefined.newValueButtonIsNotPresent(twentyEurosButtonAttributeValue)).toBeTruthy();

我知道这是不正确的,但我如何才能实现这样的目标,或者还有其他方法吗?

愚蠢的我,我找到了一个简单的解决方案。而是动态定位一个元素,我在列表中定位第一个元素,它始终是新添加的元素,然后检查它的文本是否不匹配:

页面对象文件:

this.newValueButtonIsNotPresent = function() {
        newValueButton = browser.element(by.id("containerQUICK_ADD_POINTS")).all(by.tagName('li')).first();
        return newValueButton.getText();
    };
等级库文件:

// verify element 20.00 EUR is not present
predefined.newValueButtonIsNotPresent().then(function(value) {
    expect(value).not.toEqual(twentyEurosText);
});
// verify element 20.00 EUR is not present
predefined.newValueButtonIsNotPresent().then(function(value) {
    expect(value).not.toEqual(twentyEurosText);
});