Skip to main content

Posts

Encode/Decode the variable/response using Postman itself

We get a lot of use cases where we may have to implement Base64 encoding and/or decoding while building our APIs. And, if you are wondering if it is possible to encode/decode the variable/response using Postman itself or how to encode/decode the token or password in postman and save it in a variable? To Base64 encode/decode, the quickest way is to use JavaScript methods btoa, atob: atob - It turns base64-encoded ASCII data back to binary. btoa - It turns binary data to base64-encoded ASCII. Sample code : var responseBody = pm.response.json(); var parsedPwd = JSON.parse(atob(responseBody.password)); // presuming password is in the payload pm.collectionVariables.set("password", parsedPwd);

Best place to add code for taking Screenshots with Selenium and Java

  If your UI automation code takes screenshot on failure in test method or page method, then it’s not good. We should handle that using a listener Or have a base class containing AfterMethod annotation that captures screenshots on failure. Use lateral approach (i.e. base class with afterMethod) if you aren’t using listeners in your framework. Go through this well explained article by Alex Siminiuc for more details: https://levelup.gitconnected.com/the-good-the-bad-and-the-ugly-of-taking-screenshots-with-selenium-and-java-c9da23e09842

Making SOAP Requests with Postman

  Even after following what is mentioned here: https://learning.postman.com/docs/sending-requests/supported-api-frameworks/making-soap-requests/ i.e., set Content-Type = text/xml in the Headers and setting POST as a call, at times we get 500 internal server error or bad request with the message like " error message: The message with Action '' cannot be processed at the receiver... " So, what are we missing here? Setting SOAPAction in Headers is worth giving a try... How do we get that? 1. Open your WSDL in a browser with the service URL appended by “?WSDL" and find soapAction for which you want to execute your SOAP call. Like for the "Add" method in http://www.dneonline.com/calculator.asmx?WSDL , soapAction should be set to http://tempuri.org/Add 2. Copy the value of soapAction attribute of your SOAP method. Add a new key, provide Key as “SOAPAction” and the value that you copied in the above step i.e., http://tempuri.org/Add 3. Set “Content-Type” hea...

AWS Signature with RestAssured

  AWS Signature authentication support is not something that is available in RestAssured as out-of-box feature. At least I wasn't able to find any good documentation for the same. So, how we can implement AWS Signature Headers with Rest Assured? Signing AWS requests with Signature Version 4... This explains step by step how to create a signature and add it to an HTTP request to AWS: https://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html Below given source code (AWSV4Auth.java) helps to calculate signature based on given data and return the headers. Once you get headers suing aWSV4Auth.getHeaders(), you just need to add these headers in your Rest API call (Sample for the same is given below: RATest.java) AWSV4Auth.java: public class AWSV4Auth {     private AWSV4Auth() {     }     public static class Builder {         private String accessKeyID;         private String secretAccessKey;      ...

Pickles- Living doc generator of your Gherkin feature files

  You have a set of BDD feature files written in the Gherkin language but your stakeholders doesn’t really like the text-only format? Plus they don’t want to open each feature file by one by one to go through it? Start using Pickles, it generates a document containing all features in a single documentation in just one step and it’s an opensource too. Pickles has a lot of other ways and parameters, do checkout more details here:  http://docs.picklesdoc.com/en/latest/,   https://github.com/picklesdoc/pickles  and  https://www.picklesdoc.com/# P.S. It can generate your documentation in a variety of formats like JSON, Excel, Word, etc. and not only HTML. #pickles #gherkin #bddAutomation

Monitor your APIs in postman

If you are not using any CI/CD tool like Jenkins, Azure DevOps, etc. but still want to schedule your postman automation collection suite to check the health and performance of your APIs; then you can use Monitor option provided by Postman.   You can also enable email notifications for failures and can configure the available integrations to receive alerts in tools like Slack, PagerDuty, etc. Check here for more details: https://learning.postman.com/docs/designing-and-developing-your-api/monitoring-your-api/setting-up-monitor and https://www.postman.com/pricing/   Note* With the FREE plan, we get only 1000 hits/requests per month as of writing this post.   You can monitor the performance on your account web dashboard as shown below.

Steps to execute postman collection through newman

  Here is what you need to do to start executing the postman collection through newman on your system: 1. Install NodeJS – https://nodejs.org/en/download . Click on the 32-bit or 64-bit Windows Installer package, depending on your machine configuration. Skip this if NodeJS/npm is already installed on your system. 2. Open a command prompt, and type “node -v” and "npm -v". These commands should work and provide version number if nodeJS installation is successful. 3. Run this command to install newman:   npm install -g newman 4. Install npm package newman-reporter-htmlextra for creating reports.   npm install -g newman-reporter-htmlextra 5. Pull/Export the collection, environment json (if any), test data csv (if any) files from the Postman UI or code repo (git) to your local and run this command through the folder on your local where you have these files: Command where you have collection json and environment json file : newman run "<<your_collectio...