mercredi 8 mars 2017

Protractor "signing in" || "login" test

I have a problem with Protractor. This is my first steps, that is why I can make a really stupid mistake.

So I have conf file:

exports.config = {
    framework:       'jasmine',
    seleniumAddress: 'http://localhost:4444/wd/hub',
    specs:           ['src/test/webapp/validator/*spec.js'],
    baseUrl: 'http://localhost:3000',
}

and my test:

describe('Protractor first sign in test', function() {

    beforeEach(function() {
        browser.driver.get('http://localhost:3000/#/login');
        browser.waitForAngular();
        //expect(browser.getCurrentUrl()).toEqual(browser.baseUrl + '#/login');
    }, 30000);

    it(function () {
        var user = browser.driver.findElement(by.id('username'));
        var password = browser.driver.findElement(by.id('password'));
        //var button = browser.driver.findElement(by.css('[ng-click="login()"]'));
        var button = element(by.css('[ng-click="login()"]'));

        user.sendKeys('first');
        password.sendKeys('nope');

        expect(user.getAttribute('value')).toEqual('first');
        expect(password.getAttribute('value')).toEqual('nope');

        button.click().then(function (){
            browser.waitForAngular();
            expect(browser.driver.get('http://localhost:3000/#/panel'));
            //expect(authenticationError.toBe(true));
        }, 10000);
    });
});

So the browser can load exact adress, and all the elements shows up, but then suddenly test ends with failure without proceeding with sending keys. All the actions is finished in about 1.10sec.

Of course Selenium webdriver-manager is already up.

Maybe someone of you see what is going on, and can give me advice in this matter?

Aucun commentaire:

Enregistrer un commentaire