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.
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
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.
Related
I am now trying to use Jmeter.
I have created a http request to receive multiple Ids from one response and used Json extractor to store the Ids.
The stored Ids are like:
id_1:1234
id_2:2234
id_3:3234
id_ALL:1234,2234,3234
Now, I would like to use those Ids in another response, but I don't want to configure the variable every time because there are numbers of id_{ascending number}.
example:
url: http://localhost/{id_1}
method: GET
url: http://localhost/{id_2}
method: GET
url: http://localhost/{id_3}
method: GET
I have tried to use User defined variable like: ${id_${counter}}, but it didn't work. How do I get this operation successfully?
Thanks very much.
The easiest is using ForEach Controller configured like:
once done in the ForEach Controller's child(ren) you will be able to refer the "current" id as ${id}
If you want to use the current iteration counter you need to wrap everything into __V() function like:
String representation just in case:
${__V(id_${__intSum(${__jm__Loop Controller__idx},1,)},)}
More information: Here’s What to Do to Combine Multiple JMeter Variables
Is it possible to send input parameters to the chatbot from test cases, both with and without user input? What I have in mind is that I should be able to do this in the test cases:
Test case 1
#me
Hello
INPUT_PARAMETER sttConfidence : 0.58
INPUT_PARAMETER callerCountry : GB
#bot
Hi human! I see that you sent some input parameters. Thank you!
...
...
The input parameters need to be appended to the endpoint, so the URL would look like this:
https://MyChatBotsEndpoint.com/?userinput={{msg.messageText}}&sttConfidence=0.58& callerCountry=GB
The values that we send need to be of type string.
Is this possible to achieve in Botium? And if yes, are there any native tools in Botium that can achieve this, or do we need to develop our own function?
Edit:
This is what happens when I added the piece of code:
Example of how input parameter merges with input message
Ideally I would like it to look like this:
This is what it looks like if I manually send &countryCaller=GB to our endpoint
There is nothing like that included, but with the right combination of a logic hook and the HTTP/JSON request hook it is possible.
The UPDATE_CUSTOM logic hook will copy the parameters from the convo file to the internal Botium message object:
Test case 1
#me
Hello
UPDATE_CUSTOM QUERY_PARAM|sttConfidence|0.58
UPDATE_CUSTOM QUERY_PARAM|callerCountry|GB
#bot
Hi human! I see that you sent some input parameters. Thank you!
...
The SIMPLEREST_REQUEST_HOOK capability will then use the parameters to adapt the request url accordingly with a little Javascript code:
...
"SIMPLEREST_REQUEST_HOOK": "if (msg.QUERY_PARAM) requestOptions.uri = requestOptions.uri + '&' + Object.keys(msg.QUERY_PARAM).map(key => key + '=' + msg.QUERY_PARAM[key]).join('&')",
...
Alternative Approach
If you don't like the SIMPLEREST_REQUEST_HOOK Javascript code, you could also use Mustache templates to add the query parameters to the URL:
...
"SIMPLEREST_URL": "https://MyChatBotsEndpoint.com/?userinput={{msg.messageText}}&sttConfidence={{msg.QUERY_PARAM.sttConfidence}}&callerCountry={{msg.QUERY_PARAM.callerCountry}}"
...
(you will have empty parameters, but you can tune this mustache template as you want to exclude empty parameters).
Scenario : I need to verify the logs response on server on the basis of Tracking-Id.
I had passed the tracking-id using 'header.js' file, here i define metod which get the unique UUID for every request and passed in header.
Now I need that header value to passed in some method to get logs only for specific Tracking-Id
Is there any way to achieve this in karate?
Yes, you can use karate.set('someVarName', uuidValue) in JS and then back in the feature you will be able to: * print someVarName.
EDIT: please see this commit for an example: link
I'm trying to call a http endpoint. For that I need to specify a url that uses a query string to filter data.
Sample URL: http://example.com?date=2017-10-04T22:18.007Z
I need to use the current system time as a value for date query string.
I created a script and assigned the generated url with the current datetime to a variable. However, when I assigned that variable for the url field in the source HTTP definition, it did not resolve the variable.
Is there a way to solve this issue?
I do this all the time. As long as your script is running properly (you can test that with the test feature on the script), you are writing the URL value to a global variable (something like $URL), and you are writing that global variable out in your target (something like [URL]), it should work.
If you want to show your script (just where you are creating the URL), and your target URL field that could help narrow down the problem.
I am trying to display a custom message in the e-mail that is sent after the job is built. I would like to include the svn url and another variable BranchId from where the code was checked out into the email body.
I tried SVN_URL_1 as given in the quick help on fields in the jenkins job-configure page, but it is displayed as it is in the email i.e. I get the actual string $SVN_URL_1 and not the value.
I tried adding a environment variable as shown below
Output is same, I get the string as is $BranchId.
Any ideas how to define such variables and use them later in email message?
I was trying to display the variable as $name, but the correct syntax of displaying any env variable/ parameter passed to the job/ env variable set as above is
${ENV,var="name"}
e.g.
${ENV,var="PATH"}
${ENV,var="BranchId"}