For Get Dynamic data & USe it into Postman Body parameters
Need to Add script in Pre-request script tab
1. Registration call
window = {};
pm.sendRequest("https://cdnjs.cloudflare.com/ajax/libs/Faker/3.1.0/faker.min.js", (error, response) => {
var text = response.text();
(new Function(text))();
window.faker.locale = "en_IND";
var email = window.faker.internet.email()
console.log(email)
pm.collectionVariables.set("User_Email", email);
var Password = window.faker.internet.password()
console.log(Password)
pm.collectionVariables.set("User_Password", Password);
})
2. Insert Person
window = {};
pm.sendRequest("https://cdnjs.cloudflare.com/ajax/libs/Faker/3.1.0/faker.min.js", (error, response) => {
var text = response.text();
(new Function(text))();
window.faker.locale = "en_IND";
var email = window.faker.internet.email()
console.log(email)
pm.collectionVariables.set("Person_Email", email);
var fname = window.faker.name.firstName('female')
console.log(fname)
pm.collectionVariables.set("Person_FirstName", fname);
var lname = window.faker.name.lastName('female')
console.log(lname)
pm.collectionVariables.set("Person_LastName", lname);
var PhoneNumber = window.faker.phone.phoneNumber('(910) ### ####')
console.log(PhoneNumber)
pm.collectionVariables.set("Person_MobileNumber", PhoneNumber);
var Dial_code = '+91'
console.log(Dial_code)
pm.collectionVariables.set("Person_Dial_Code", Dial_code);
})
3. Insert Vendor
window = {};
pm.sendRequest("https://cdnjs.cloudflare.com/ajax/libs/Faker/3.1.0/faker.min.js", (error, response) => {
var text = response.text();
(new Function(text))();
window.faker.locale = "en_IND";
var Companyname = window.faker.company.bs()
console.log(Companyname);
pm.collectionVariables.set("Vendor_Comapanyname", Companyname);
let category = 1
console.log(category)
pm.collectionVariables.set("vendor_category", category);
let Address = pm.variables.replaceIn('{{$randomStreetAddress}}')
console.log(Address)
pm.collectionVariables.set("Vendor_Address", Address);
let cityname = pm.variables.replaceIn('{{$randomCity}}')
console.log(cityname)
pm.collectionVariables.set("Vendor_City", cityname);
let Statename = 84
console.log(Statename)
pm.collectionVariables.set("Vendor_Statename", Statename);
let CountryName = 2
console.log(CountryName)
pm.collectionVariables.set("Vendor_CountryName", CountryName);
let Rating = 3
console.log(Rating)
pm.collectionVariables.set("vendor_Rating", Rating);
// Insert Person id Data
var email = window.faker.internet.email()
console.log(email)
pm.collectionVariables.set("Person_Email", email);
var fname = window.faker.name.firstName('female')
console.log(fname)
pm.collectionVariables.set("Person_FirstName", fname);
var lname = window.faker.name.lastName('female')
console.log(lname)
pm.collectionVariables.set("Person_LastName", lname);
var PhoneNumber = window.faker.phone.phoneNumber('(910) ### ####')
console.log(PhoneNumber)
pm.collectionVariables.set("Person_MobileNumber", PhoneNumber);
var Dial_code = '+91'
console.log(Dial_code)
pm.collectionVariables.set("Person_Dial_Code", Dial_code);
// Owner id
let ownerId = 2108
console.log(ownerId)
pm.collectionVariables.set("vendor_ownerId", ownerId);
})
Comments
Post a Comment