Protractor: TypeError: Cannot call method 'click' of undefined

Protractor: TypeError: Cannot call method 'click' of undefined

目前在尝试找出尝试单击以下元素时抛出错误 "TypeError: Cannot call method 'click' of undefined" 的原因时遇到问题。

browser.driver.sleep(2000);

// Undefined, figure out why it cant get a hold of this
expect(element.all(by.css('[ng-value="account.id"]')).get(0).isPresent()).toBe(true);

element.all(by.css('[ng-value="account.id"]')).get(0).then(function (elm) {
    browser.driver.sleep(1000);
    elm[0].click();
});

正在查看的元素如下(有多个元素,这就是为什么我调用“.get(0)”只查看它们集合中的第一个单选按钮):

<div class="row row-center" style="height: 85%;">
       <div class="col">
         <div class="list card" ng-if="accounts != null">
            <div class-="list">
                <label class="item item-radio"
                       ng-repeat="account in accounts" ng-if="account.clippable && account.fundable">
                    <input type="radio"
                           ng-model="accountConnection.id"
                           ng-value="account.id" >
                    <div class="item-content">
                        {{ account.meta.name }} ({{ account.meta.number }})
                        <p>${{ account.balance.current }}</p>

                    </div>
                    <i class="radio-icon ion-checkmark"></i>
                </label>
            </div>
        </div>
    </div>
</div>

将代码段更改为:

element.all(by.css('[ng-repeat="account in accounts"]')).then(function (elm) {
    elm[0].click();
});

现在似乎工作正常。