Timeout-error when testing login dialog using protractor and angular-strap modal

I have a login dialog using angular-strap modal that gets called:

scope.authModal = $modal({
                template: '/components/login/login.html',
                show: false,
                scope: scope,
                backdrop: 'static'
            });

      

(This code is inside the link function of the login directive.)

Now my protractor code looks like this:

it('should perform login properly', function () {
    browser.manage().deleteAllCookies();
    element(by.model('login.username')).sendKeys('xy123');
    element(by.model('login.password')).sendKeys('abz89');
    element(by.binding("guiText.loginButton")).click();
    browser.waitForAngular();
    expect(element(by.id('login.username')).isPresent()).to.eventually.equal(false);
});

      

Another test above element(by.id('login.username')).isPresent()

proved it to be true when the input dialog is visible.

The problem is what I am getting Error: timeout of 10000ms exceeded

with this test. In the browser, I see that the credentials are correct and the button is clicked. Modal login errors, and then nothing happens, and the browser eventually runs in that timeout after waiting 10 seconds.

+3


source to share


1 answer


I had the same problem and solved it below.

Write this function to your helper file and call this to hit the login button in your code. Try to access the button by id, then pass the id in that function, if not id, then update the function according to your needs.



var clickAndWait= function (btnId) {
    var returnVal = false;
    browser.wait(function () {
        if (!returnVal) {
            element(by.id(btnId)).click().then(function () {
                returnVal = true;
            });
        }
        return returnVal;
    }, 30000);
};

      

+3


source







All Articles