简体   繁体   中英

How can we generate Dynamic email field and username for postman

I need to generate a dynamic email address, username for API automation testing in postman. can you help me with this please.

I see two options on how you can get what you need.

  1. Using already defined dynamic variables, such as timestamp: For example where you need a new email address, just use this:

     user_{{$timestamp}}@example.com

    The request will be sent with something like: user_1497475549@example.com

  2. Define an variable in the pre-request script:

     var randomEmail = 'DO YOUR PREFERRED RANDOMIZATION HERE'; pm.setEnvironmentVariable("email", randomEmail);

    and use that variable like {{email}} when sending the request.

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