Test Step Move Properties on SoapUI with http post request - http

I created a Soap-UI Test-Suite with a Test-case.
This Test-case has a http request as Test-Step.
The method of the http request is post.
The http request has the Parameter P_FILNR=1111&P_HDLNR=123456.
How can I set/modify these Parameters with the Test-Step?

as Mentioned by #A Joly above here is the code which can help you. I have used the custom property and a groovy script
First of all you can mention the property name under the value like ${#TestCase#address} <-- This means a test case property with the name address.
You can now add a groovy step with the below code
def values=["India", "Russia","USA"]
for(int i=0; i < 3 ; i++)
{
testRunner.testCase.setPropertyValue("address",values[i])
testRunner.runTestStepByName("Request 1")
}
So what happens here is the test step which we have to run has the step name as "Request 1". We are setting the value of Address dynamically and running the step via Groovy.
Also you can disable the request 1 step so that it does not run when you run the suite because groovy will run the request 3 times for 3 values

Related

Paw - Get last request made using specific environment

I am trying to use a dynamic field from parsed response. The parsed response must be for the last request made using a specific environment. Is this possible?
Here's the scenario:
1. Make Request 1 using Environment A
Receive Response A1
2. Make Request 1 using Environment B
Receive Response B1
3. Make Request 2 using environment A, with field from parsed response A1
Receive Response A2
4. Make Request 2 using environment B, with field from parsed response B1
Receive Response B2
How do I orchestrate steps 3 and 4?
We are planning to implement it properly by using tabs on MacOS Sierra. With each tab operation as dedicated session and you will pin environment selection to a tab.
This is not properly implemented in Paw yet, but you can write a custom Dynamic value for this or use a hacky workaround:
Choose a partitioning variable in your environments
Set a X-paw-env header in Request 1 the partitioning environment variable. This way you get the current value of the partitioning variable depending on the environment
In Request 2 in the field where you are using the Response Parsed Body insert a Custom dynamic value instead. Inside there get the latest exchange for Request 1 where the request header matches the value of your partitioning variable for the current environment. Then extract the value you need from the response body using RegExp Match
function evaluate(context){
var variableValue = context.getEnvironmentVariableByName("myPartitioningVariable").getCurrentValue()
var exchanges = context.getRequestByName("Request1").getAllExchanges();
for (var i = 0; i < exchanges.length; i++) {
console.log(i, exchanges[i].requestHeaders["X-paw-env"]);
if (variableValue === exchanges[i].requestHeaders["X-paw-env"]) {
var dv = new DynamicValue("com.luckymarmot.RegExMatch", { re: '"user":\\s*"([^"]*)', input: exchanges[i].responseBody });
console.log(exchanges[i].responseBody)
console.log(i, "returning")
return dv.getEvaluatedString();
}
}
};

AWS API Gateway - change to 404 if query returns nothing

I have a Dynamodb table with a few fields - my_id is the PrimaryKey. In the API gateway I set up a response with a method that takes in a parameter {my_id}.
Then I have an Integration Request mapping template that takes the passed in parameter and queries the table to return all the fields that match.
Then I have an Integration response mapping template that cleans up the returned items the way I want.
This all works perfect.
The thing I can't figure out how to do is if the parameter that is passed in doesn't match anything in the table, how do I get it to change from a 200 status into a 404?
From what I can tell when the passed in parameter doesn't match anything it doesn't cause an error, it just doesn't return anything.
It seems like I need to change the mapping template on the Integration response to first check if the params are empty and then somehow tell it to change the response status.
I can find info about this type of thing with people using Lambda, but I am not using Lambda - just the Dynamodb table and the API Gateway.
You can use Mapping Template to convert the response that you get from DDB and overrride the response code. You can get more details in the link https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-override-request-response-parameters.html
If you are using cloud formation, you can do this by using below snippet
IntegrationResponses:
- StatusCode: "200"
ResponseTemplates:
application/json: |
{
"payload" : {
}
},
}
IntegrationResponses:
- StatusCode: "200"
ResponseTemplates:
application/json: |
#set($inputRoot = $input.path('$'))
#if($inputRoot.toString().contains("Item"))
$input.json("$")
#set($context.responseOverride.status = 200)
#else
#set($context.responseOverride.status = 404)
#end
Api gateway currently supports mapping the status code using the status code of the integration response (Here dynamodb response code). The only workaround is to use a lambda function which outputs different error messages that can be mapped using a error regex http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-method-settings-execution-console.html.

capture all the browser URL in Webdriver

I want to print all the browser url navigated during a test in webdriver.
For eg. :- the reference site is m.rechargeitnow.com and i made a transaction failure. Now the task is to capture all the browser url navigated during a complete transaction.
You'd need to build a list as you perform each step. Something like:
urls = []
urls.append(driver.current_url) /starting URL
/do step one
urls.append(driver.current_url) /URL following step 1
/do step two
urls.append(driver.current_url) /URL following step 2
/do all steps
print(urls)
If you only want to see that list of urls in the case of a test-fail or test-error, use a try block.

Benchmarking Solr indexing with Jmeter

I want to use Jmeter to update a document on solr using http post.
I want it to take a different file to update in every iteration, create a proper http post request and monitor the responses from the server.
Can someone guide me of how this can be done:
Taking a different file every time.
Creating a http post from it.
Your use case can be split into 2 parts:
Get list of files to send
Send them to server
In regards to point 1, I would suggest to obtain file list via scripting.
Assuming following Test Plan Structure:
Add a Thread Group (all defaults)
Add a JSR223 Sampler as a child of Thread Group
Select "beanshell" as language
In "Script" area add following code:
File folder = new File("PATH TO FOLDER WITH YOUR FILES");
File [] files2send = folder.listFiles();
int counter = 1;
for (File file : files2send)
{
vars.put("FILE_" + counter, file.getPath());
counter++;
}
This will save files, you will be sending as JMeter Variables like:
FILE_1=d:\2solr\sometxtfile.txt
FILE_2=d:\2solr\somewordfile.docx
FILE_3=d:\2solr\someexcelfile.xlsx
After that you can use For Each Controller to iterate through files and add them to your request
Add For Each Controller as a child of Thread Group (same level as JSR223 Sampler)
Make sure that For Each Controller has following configuration:
Input variable prefix: FILE
Output variable name: CURRENTFILE
Add _ before number is checked
Add HTTP Request as a child of For Each Controller
Access file you want to send as ${CURRENTFILE} in "Send Files With The Request" stanza of the HTTP Request
It's just one of the approaches, if you are not very comfortable with JSR233 or Beanshell you may wish to use CSV Data Set Config instead.

Is Angular http request call when a variable scope change?

I have to use a http get request in my angular script where I have to send some variables to the server.
My question is if the sending variable is changed somehow, then will the request call again automatically?, or do I have to call the request again??
Thanks
updated:
code in my controller:
$scope.startDate = "";
$http.get('/Controller/Action', {startDate: $scope.startDate}).success(data){
alert(data)
}
if somehow the value of the startDate is changed will the http request be called again or I have to place it into a watch.
While the question is unclear, I believe what you are referring to is a $watch setup on a scope property. If you make a normal request, such as this:
$scope.myResource = 'path/to/resource'; //could be used use without $scope for this example
$http.get($scope.myResource) //etc
the call is just made once, because that's all it is told to do. If you want it to update when the path "myResource" changes, then do this:
$scope.$watch('myResource', function(newPath) { //watching $scope.myResource for changes
$http.get(newPath) //etc
})
Now, when the value of $scope.myResource changes, the $http call will be again, this time requesting the new path.

Resources