Skip to main content

Posts

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

Tips and tricks for automation using Postman/Newman

   1. How do we run multiple newman/postman collections sequentially (back to back) at one run ? Batch running multiple newman/postman test collections : Create a batch file like this and run: call newman run Collection1.postman_collection.json -e qa1.postman_environment.json -r htmlextra --reporters cli,junit,htmlextra --reporter-htmlextra-export TestReport1.html -d TestData1.csv call newman run Collection2.postman_collection1.json -e qa2.postman_environment1.json -r htmlextra --reporters cli,junit,htmlextra --reporter-htmlextra-export TestReport2.html -d TestData2.csv   Side note : Give a shot to https://medium.com/@mnu/run-multiple-postman-collection-in-parallel-stress-ee20801922ed in case you would like to run it in parallel (P.S. haven’t tried this yet)   2. How can we set environment variable based on another environment variable value ? Like for QA1, we need accountNo say "123" but for QA2, we need accountNo say "345", etc.   pm.test(&q

Best practices for API automation using Postman

1. Always use Collections and organize tests into folders for testing : Even Though the collection is the top-level of organization, we should have folders that can group together related to requests or demonstrate a detailed workflow. As our API grows in number and complexity, it will become important to organize our tests so they make sense and can be found easily. Therefore, we suggest using folders/sub-folders to group requests by resource, module type, test suite, and workflows. P.S. If require, we can run specific folder(s) inside a collection using “ –folde r ” argument. 2) Use global/environment/collection variables :  Postman also allows us to store data from previous tests into global/collection variables. These variables can be used exactly like environment variables. For example, there is an API that requires data received from another API ( chaining/correlation ). We can store the response attribute (or part of the response) and use that as part of a request head

Azure DevOps Postman/Newman HTML Report

 In Azure DevOps, if you don't want JUnit Test results and like to have a HTML Report (htmlextra) that newman provides which is very neat and comprehensive, go for this FREE extension: https://marketplace.visualstudio.com/items?itemName=MaciejMaciejewski.postman-report   This lets you create a task for publishing newman HTML Reports in your pipeline into Azure Storage(like shown below in Image 1). And then, embedded reports can be viewed as a tab in Build and Release result page (like shown below in Image 2). Plus, there is an option to download the reports from the same tab.

TestProject smart and powerful recorder

  TestProject already had a smart recorder that was capable of doing fantastic stuff we look for in any record and playback. It can easily generate source code from recorded tests, suggest useful add-ons, allow us to choose from various locator strategies, and view all available properties of any UI components, etc. But have you checked their new versatile and much powerful recorder? You should check it when you get the time and share your feedback. Here are the few enhancements I noticed: 1) Added support for iFrames. I am sure this will be helpful in testing apps that play with so many iFrames. 2) Self-healing feature for the stability of the locators: I have used other tools/frameworks like Canopy(F# library built on top of Selenium) and it wasn't that effective in terms of Self-healing feature but I must say that it works very effectively when I tried using TestProject recorder to record, edit and playback. Also, if a Self-Healing mechanism was used to recover from an error, it

What all attributes should be there in your automation solution to be called a good solution?

Your automation project should have all of these to be called a good solution : Well drafted Project Design Clear Project Structure and Documentation Defined Page Objects (For UI project) Independent Automated Unit Tests Automated End to End Tests  (Loosely coupled) Reliable Locators (For UI project) Highly effective strategies for managing test data Comprehensive Dependency Management Precise and concise logging and Reporting

Jenkins: Purge Job History Plugin

Download and install: https://github.com/jenkinsci/purge-job-history-plugin This plugin provides the ability to purge all the build records of a job either via a CLI command or via the UI. When this plugin is installed it adds a new action to all Jobs with builds. You can either use UI as shown here (https://github.com/jenkinsci/purge-job-history-plugin) to purge any/all of the following:  Job Pipeline MultiBranch Job (Recursive Flag is Needed) Jobs under a Folder (Recursive Flag is Needed) All Job under Jenkins Instance (Recursive Flag is Needed) Or you can do it via Command line using this command: java -jar jenkins-cli.jar -s http://localhost:8080/jenkins purge-job-history <JobName> -r JobName : Name of the Job whose history you would like to purge r : To reset the next build number to 1 Note* you need super access to perform it.