Question

i have a test for a registration form (name, email, pw), and i'd like to have it so that it uses a randomly generated email address each time so i don't have to do any cleanup or editing of the test. do i need helper files for this or can i do it within the test?

my snippet looks like this --

casper.then(function() {
this.echo('signing up with the follow credentials:', 'COMMENT');
this.fill('.sign_up', {
    'name': 'mariah carey',
    'email': 'mariahcarey@dododoodo.com',
    'password': 'testtest123'
}, true);
Was it helpful?

Solution

Inside your test script you can create javascript functions in order to generate randomly the email address.

casper.then(function() {

  this.echo('signing up with the follow credentials:', 'COMMENT');
  this.fill('.sign_up', {
      'name': 'mariah carey',
      'email': generatePassword(),
      'password': 'testtest123'
  }, true);
}

...

function generatePassword(){
   var email;
   // Here code for generate email
   return email;
}

You can do the same for name and password.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top