Hot answers tagged

5

For example you have the following response: And you need to extract John from it. Add JSON Extractor Post Processor Configure it as follows: Reference Name: anything meaningful, i.e. name JSON Path Expressions: $.name That's it, you now have ${name} JMeter Variable with the value of John If now you want to validate its value you can add a Response ...


5

If you would love to test REST API then I would recommend you to use Rest Assured which is a Java Library. It’s better to create Page Object Model and use Testing Framework like TestNG to write tests. Along with the main library ( REST ASSURED) that you can use for testing REST API. Below is the official guide for the same: rest-assured/rest-assured OR ...


3

Hi you can use multiline argument (docstring) for this: https://cucumber.io/docs/gherkin/reference/#doc-strings Your step definition: Here you pass the json between """ and """ Given a blog post named "Random" with Markdown body """ { "benefitPlanIDs": [ { "benefitPlanID": "011748abc", "benefitPlanPlatform": "abc" } ], "clientId": "abc", "...


3

Unit tests, by the book, are meant to exercise the code you write, isolating it from dependencies (SO calls, external libraries and even language built-in libraries if important for your code) through mocking. What you may need is integration tests, which means checks that will evaluate if two components can communicate. They are different than integrated ...


2

Nothing to do with selenium for log parsing. you need to use java/perl/python which ever language your are using for writing selenium test scripts. But i implemented this kind of funtionality to check application logs. While implementing this you need to check following: 1. whether your application logs are generated with proper delimiters to indicate each ...


2

Not knowing the details of JDBC and JSON response it is hard to provide exact configuration, from the high level perspective it should be something like: Add JSON Extractor and store "interesting" part(s) of the response into JMeter Variable(s) Add JDBC PostProcessor and store values from the DB into JMeter Variable(s). See Debugging JDBC Sampler Results ...


2

Use HTTP Request sampler to perform initial call to the web service endpoint. You may also need to have HTTP Header Manager to send the relevant Content-Type header Use JSON Extractor to extract the above URLs and convert them into JMeter Variables Use JMeter Variables in the following HTTP Request samplers to check the URLs. Response code can be verified ...


2

You need to apply the below areas to your framework: The body for the POST call should be coming from a model file. Use a java serialization/de-serialization library like jackson or Gson to achieve this, although RestAssured has this feature. Creating complex json becomes easier. Create a RequestSpecBuilder to create the POST call, so that you can reuse ...


2

You can do this using JSON Extractor Add JSON Extractor as a child of the request which returns the above JSON Configure it as follows: That's it, now you have all serviceItemId values extracted into the following JMeter Variables: serviceItemId_1=SGR40400002 serviceItemId_2=SGR40400003 serviceItemId_3=SGR40400002 serviceItemId_matchNr=3 You can now ...


2

Karate is a relatively new project that is specialized for testing JSON web-services and it runs on the JVM. Disclaimer: am dev. There are a set of demos and examples that will get you started very easily. One of the highlights of Karate is the "native" support for JSON and being able to perform a "deep equals" on two payloads.


2

I'm assuming you are using Java in your testing framework. You have two ways of achieving it. Option 1: Try using Karate framework. If you use Java and want to do easy API testing. Option 2: Table is an object with fields named accordingly to table header. Basically you need to serialize them to json in a way that is suitable. You can use gson library ...


2

Your JSON is not valid: 1 { 2 "User ID": 204120, 3 "name": "New User", 4 "Description": [{ 5 "name": "john", 6 "id": 204110, 7 "type": "robotics" 8 }], 9 "Status": "Post request Successfully" 10 } You need to add a name to the value on lines 5,6,7 Or you need to remove the {} brackets to make it valid "Description": [ "john", ...


2

Your data is not a valid JSON, you can check it yourself using i.e. online JSON formatter and validator You syntax of combination of __eval() and __FileToString() functions is incorrect, you should wrap the __FileToString() function into the __eval() and you're doing the opposite thing: ${__eval(${__FileToString(${Json_request.txt},,)})} More information: ...


2

This is something you can do by marshalling POJO's to JSON. For example with a framework such as Jackson. As described in this tutorial you can use a Jackson ObjectMapper: import com.brunozambiazi.model.User; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.Calendar; import java.util.HashSet; public class SerializationTest { ...


1

1 - Read data from JSON Google has a very good Java library to parse JSON in a structured way: GSON The types you would use the most are JSONObject and JSONElement. 2 - Use the data in a test I would suggest having in your dataprovide only the name of the JSON file. In the test, you can call a factory that would read the JSON file and generate a POJO ...


1

To start with, your expected addition to the template is incorrect and would error out as invalid JSON. Unless the system allows multiple itemLines objects, you really want to be adding a second itemLine to the to the itemLines array. Some basic JSON terminology: An element is in the form "something" - think of this as the string equivalent in other ...


1

Both your JSON entities are invalid therefore I'm afraid no one will be able to help. To give you some direction you can use Json Path to filter out "interesting" parts of the source JSON and JsonBuilder to produce the new one. Add JSR223 PostProcessor as a child of the request which returns the "bigger" JSON Put the following code into "Script" area: def ...


1

ReSharper is just an IDE for C# by JetBrains. This won't help you much unless you want to write everything from scratch. Postman has the ability to generate code snippets for various languages and frameworks, including C# (using RestSharp as REST/HTTP client). Consequently, you should be able to simply "convert" your requests to C#. (Haven't tried this ...


1

The most convenient way would be using a specialised framework for API testing, you can consider RestAssured if you don't have any better alternatives. Extracting response header would be as simple as: Response response = get("/your/url"); String rcAuthToken = response.getHeader("rcAuthToken"); More information: RestAssured: Headers, cookies, status ...


1

To get token values:: u need to pass parameters like username, password, grant_type, client_id n client_secret...which will be shared by respective developer of the API...


1

Add a header manager - try with Content-Type and if it didnt work then try with Accept; remember these for the future - 400 series error - Check the Header file 500 series error - check the data


1

As it has never been added, the answer has been given here: https://stackoverflow.com/questions/43035806/how-do-i-save-jmeter-variables-created-at-runtime-specifically-a-snippet-of-js/43037917#43037917 And see manual on Sample variable


1

I asked the same question in the main Stack Overflow space and got a good answer back from someone there: jmeter-json-extractor-removing-white-space-causes-test-to-fail - Answered


1

As I understood that, your requirement is to test URLs and their status codes. For this, you does not require jmeter. Even if you want to test in jmeter then you need to follow below steps, Create a test plan Add a HTTP Sampler and configure the web service URL Add a Post Processor and collect the required info and save it into variables For checking the ...


1

1 - Your JSON is wrong because you a trying to create a list using a key-value syntax, in the outer-most level. The first level should be a dictionary, with a list as value. { "geos": [ {"u":"geos","p":"1"}, {"u":"ges","p":"2"}, {"u":"geo","p":"1"} ] } Read about JSON format here. A Java JSON reader can be found here. 2 - You must be ...


1

I would probably write something that already knows about changes between the old keyset and the new keyset. I would write a function that uses that information to transform serviceA's response from the old format to the new format. Using the example above, I would replace firstname with name and dob with dateOfBirth. Then I would write something that ...


1

Use awk to search that portion for: open brace, key value pairs close brace That's for just 1 level, you'll need to develop it for more levels such as shown at http://json.org/example.html


1

But why to write this method as the selenium scripts doesn't execute when we navigate to next page and the page isn't loaded completely. Ok I totally get why you feel that piece of code is trivial. Well we all know how good a tool Selenium is and we expect it should be at least wait for page load out. Unfortunately it is not that simple for Selenium, as ...


1

You can figure out that your server returns JSON by i.e. looking into "Content-Type" HTTP Response Header, if it contains application/json - the server is talking JSON. In regards to JMeter and JSON - in 99% of cases it would be REST API load testing, to learn how it could be done using JMeter - check out Testing SOAP/REST Web Services Using JMeter guide.


1

JSON is a lightweight format, while XML is a considered a heavy weight format. So, to transmit the same amount data, you'll need fewer bytes in JSON,which may improve the performance if you are sending lots of data. It is also considered more "human readable" than XML. As for how you know if a server is sending JSON data, it should say so in the mime ...


Only top voted, non community-wiki answers of a minimum length are eligible