Tryout with Prior, how to catch an Md-button?

Asked

Viewed 191 times

0

I am using Protractor to test a system made in Angularjs and Material, I am having problems with the Locator when I want to take a specific Md-button in a form and run the click(). The button hmtl is this:

<md-card-actions layout="column" layout-align="center center" layout-wrap layout-sm="column">
            <md-button 
                ng-disabled="!loginForm.$valid || Login.inProgress"
                class="md-raised lightBlue buttonLogin" 
                type="submit"
                aria-label="{{'login.enter' | translate}}"
                ng-click="Login.login(authForm)">
                    <span translate="login.enter"></span>
                    <md-progress-linear 
                        md-mode="indeterminate"
                        ng-show="Login.inProgress">
                    </md-progress-linear>
            </md-button>

            <md-button ng-click="Login.fbLogin()" aria-label="{{'login.loginFacebookLink' | translate}}" class="md-raised md-primary lightBlue">
                <md-icon md-svg-src="icons/facebook_.svg"></md-icon>
                <span translate="login.loginFacebookLink"> </span>
            </md-button>

            <md-button class="md-raised md-warn md-hue-2" aria-label="{{'login.forgotPasswordLink' | translate}}" ng-click="Login.buttonCallForgotPassword();">
                <span translate="login.forgotPasswordLink"> </span>
            </md-button>
        </md-card-actions>

Excerpt from the test code:

var button = element.all(by.css('button.lightBlue')).first();

button.click();

I put the first() just to get the first button, but I don’t know if the first button it lists is the login button.

I need to pick up the first button, sometimes an alert saying that there is more than one button and that ran on the first one, however, as I will have to test the three buttons I need to know which one I am using. How do I pick up a specific button when I use Md-button ?

1 answer

1

Try to use this way:

element(by.css('md-button[ng-click="Login.login(authForm)"]')).click()

Browser other questions tagged

You are not signed in. Login or sign up in order to post.