简体   繁体   中英

Protractor: how to test load bar

I am testing a login page that has a load bar. My scenario should test if a load bar displayed when a user clicks on "Login" button. I created the following function for the test-flow but it fails always with the error of timed out.

 isLoadBarDisplayed: function () {
    var thePage = this.page;      
    thePage.userNameField.sendKeys(randVal);
    thePage.passwordField.sendKeys(randVal);

    browser.ignoreSynchronization = true;
    thePage.LoginBtn.submit()

    var EC = protractor.ExpectedConditions;
    browser.wait(EC.visibilityOf(thePage.loadBar), 5000, false);

    browser.ignoreSynchronization = false;
},

The another code yields false always:

    .......
    browser.ignoreSynchronization = true;
    return thePage.LoginBtn.click().then(function(){
       return thePage.loadBar.isDisplayed()
    })

    browser.ignoreSynchronization = false;
}

Any ideas are very welcome! Thanks in advance

In order to know another way to solve the issue, see the comments above. In my case the following part of code works correct:

    var result

    thePage.userNameField.sendKeys(randVal);

    return thePage.passwordField.sendKeys(randVal).then(function () { 
        browser.ignoreSynchronization = true;
    }).then(function () { 
        thePage.LoginBtn.submit()
        thePage.loadBar.isDisplayed().then(function (answer) {
            result = answer;
        });

    }).then(function () {
        browser.ignoreSynchronization = false;
        return result;
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM