Dynamic Rest request creation for an update payload
I have a requirement to test an update request which can update more than 1 phone number.
I am using a data driven framework, and was passing the values from excel with 1 to 1 request element mapping.
however in this case, I have to test cases where there can be one number/2 numbers to update/ so and so forth.
This is not possible with my current framework, hence i need some help in a way to create this request dynamically.
I am thinking of a way in which if the data excel data sheet has a column with number of phones to update as 3, my request should be created with 3 phonenumbers. The phone number array has multiple elements:
{
phoneNumber1
PhoneType1
extension1
contactPreference1
etc
}
{
phoneNumber2
PhoneType2
extension2
contactPreference2
etc
}
{
phoneNumber3
PhoneType3
extension3
contactPreference3
etc
}
I am very new to Groovy and any help would be greatly appreciated. Using Groovy, if we can create a requst, I would also need help in passing that to my actual request step in the framework.
Please help.
What you can do is pass phone number with "," separated like 1111111,2222222,333333,444444
and then split your number with comma in groovy and create dynamic request with number size.
//Get phone Number with , seperated from Excel sheet def phoneNumber = excelsheet(phone__number); //Split phone number with , int phoneNumberSplit = phoneNumber.split(",") //loop the number of phone number for(int i = 0 ; i < phoneNumberSplit.size() ; i++){ //generate dynamic request // Create your dynamic request with phoneNumberSplit[i] }
Let me know if you need more help on this.