jeudi 25 juin 2015

Auto Generate fields values for testing a form using Protractor

I want to test a simple user registration form using Protractor.

Here's my test:

describe('User Registration Page Tests', function() {
    beforeEach(function() {
        browser.get('/#/register');
    });

    it('user registration success', function(){
        element(by.model('user.organizationName')).sendKeys('someOrg');
        element(by.model('user.firstName')).sendKeys('some');
        element(by.model('user.lastName')).sendKeys('user');
        element(by.model('user.email')).sendKeys('some@user.com');
        element(by.model('user.password')).sendKeys('123456');
        element(by.model('confirmPassword')).sendKeys('123456');

        element(by.id('submitBtn')).click();

        browser.getCurrentUrl().then(function(url) {
            expect(url).toEqual('http://localhost:9001/#/success');     
        });
    });
});

For the first time, the test will pass. But for the next times it will fail because this user is already exist.

Is there a way to auto generate new fields values to solve this issue?

Couldn't find anything in Google about it...

Aucun commentaire:

Enregistrer un commentaire