Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Currently having an issue trying to figure out why the following element is throwing the error "TypeError: Cannot call method 'click' of undefined" when it is trying to be clicked.

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();
});

The elements being looked at are below (There are multiple which is why I am calling ".get(0)" to just look at the first radio button in the set of them):

<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>
like image 463
parchambeau Avatar asked Mar 07 '26 16:03

parchambeau


1 Answers

Changed the snippet to be:

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

And it seems to be working fine now.

like image 158
parchambeau Avatar answered Mar 10 '26 14:03

parchambeau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!