Monday, August 19, 2019

API Automation using Newman - Part II

HTML Report via Newman

In previous post we have seen how to setup Newman and execute the collections via Newman in command line.

Newman also supports reporting. Let's see how html report can be generated post collection execution.

HTML reporter is an external reporter which needs to be installed first. Here is the command to install HTML reporter.

npm install -g newman-reporter-html

Usage

newman run {path-to-collection} -r cli,html

This way you will be able to generate html reports post collection execution.

API Automation using Newman - Part I

API Automation using Newman

In last posts, we have learnt about How to setup Postman and how to use and store variables in Postman.

There is a command line tool available to execute the Postman collections with some awesome features like reporting etc. This tool is called as Newman.

What is Newman?

We can run collection in Postman similarly to run the collection via command line Newman is used. Newman allow you to run and test a collection via command line seamlessly and with minimal efforts. It also gets easily integrated with CI servers and build systems.

Installation

Easiest way to install Newman is using npm. Pre-condition is to have NPM installed.

$ npm install -g newman

-g - is used to install Newman gobally. You can just remove -g if you wish to install it locally.

The above command will install Newman and you'll be able to access it from anywhere.

Executing Collections via Newman

In order to execute a collection in Newman, we need to use the following command:

$ newman run {....}

One way to run the collection, is to have your collection exported into a json file and execute it via Newman.

$ newman run {path-to-jsonfile}

Another way is to execute via collection link. Postman allows to create a link of the collection which can be used to execute the same via Newman.

$ newman run {collection-link}

Newman also have ability to generate awesome reports post execution. In the next post we'll see how to generate reports via Newman.

Monday, August 5, 2019

How to Retrieve Response Data and store it in variables?

How to Retrieve Response Data and store it in variables?

While working with Postman, sometimes we come across some situations where we need to use the Response data of say Request 1 as an input to Request 2 and so on. This process of reusing the data in other requests is called as Chaining.

To get started with Chaining. first thing to know is how to store the re-usable response data in variables.

Have a look at the screenshot below:

In the above screenshot, I have used a dummy API request for testing purpose. Here while hitting "/posts" we will get all the posts data as a response for the request we have made.

Now, suppose we have an another API where we need to pass a particular posts "id" as an input to get the details of the same. Let's see how to achieve this.



Here, we have written some tests in "Test Scripts" tab. Let's see what these lines of code is doing:

pm.environment.clear() - This clears all the environment variables of the specific environment say we are using "QA" environment, so this line of code will clear all the variables from the "QA" environment.

var response = JSON.parse(responseBody) - Here, we are declaring a variable name "response" and we're storing the response of the API in this variable.

pm.environment.set("id", response[0].id) - This line of code is setting an environment variable with name i.e variable key as "id" and as the response is in the form of array, we're getting the post id from the "0th" index and storing in the id variable here.

Sunday, August 4, 2019

When to STOP testing?

When to STOP testing?

This is a common question which hits every tester's mind. At the initial iterations of the development we are interested to find defects in the product but later on after two, three iterations on the same, testing the same stuff, a question arises on our mind, "When to STOP testing?".

Ideally, as we all know that although it's possible to find all the defects in the software but this will take a lifetime and the process of getting bugs and fixing will go on forever. So there are certain factors to be taken into considerations while testing to fulfil the intent of testing. Testing is a process which is involved so that the current and expected behaviour is matched. Here are some of the conditions when testing can be stopped:
  • Allocated Budget for testing is consumed.
  • When all the planned test cases are executed and passed
  • When timelines for the released are reached.
  • Major Areas are working as per expectations
  • Test coverage is fulfilled as per plan.
 
There can be more such conditions when we testing can be stopped. Let me know your thoughts in comments on "by when do you think testing can be stopped?".

Thursday, August 1, 2019

API Testing via Postman

API Testing via Postman

Introduction

In my previous post, we have seen some few things to know before starting API testing. It's recommended to go though my previous post before proceeding with this article. Here is the link for your quick reference. https://bit.ly/2KjFqYN

Postman is a popular API Development and testing tool. It is available for Windows, Mac OS , Linux. Postman can be downloaded as a chrome plugin (which is deprecated now) hence its recommended to switch to the Native Postman App. You can download the native app from Postman Website.


Initial Steps
  • Download latest version of Postman native app and Launch the application.
  • Once you Launch the application, you'll see a window having an option to login / signup.



  • Or if you are thinking to skip this signup step, then at the bottom of the page you'll see an option "Skip signing in and take me straight to the app", by choosing this option you can continue using the app without creating an account with Postman.
  • But, it's good to create an account / sign in initially so that all your work progress can be synced to your account and you'll not loose anything.
  • Once you sign in you'll taken straight to the application. 

  • Here you'll see many options and you can de-select the checkbox at the bottom left corner (shown in the image above) so that this window will not appear again when you launch the Postman app.

Making our First Request

Once you close the pop-up you'll see a screen similar to a one you see below.


In the above image, there are some areas marked with numbers. The area which is marked as "1." there we can give a "Name to the request". "2." is where we need to enter the "Request URL" and "3." is the "Send" button which will help to build the request.

For testing purpose, we have used https://httpbin.org/ to make request.



Here we have made a GET request and after clicking on Send the request has been built and we got the response back from the server i.e the user-agnet in this particular case.

In next article we'll learn about more HTTP requests and related information.

Friday, July 26, 2019

Setting up Selenium WebDriver with Eclipse IDE in Linux

How to set up Selenium WebDriver in Eclispe IDE on Linux?

Pre-requisites:

  • Eclipse is installed
  • Java is installed and Environment path is correctly set.

Steps to be followed:

  1. Launch Eclipse
  2. Create a Java Project
  3. Create a Package under "src" folder.
  4. Create a class inside the package

How to verify Java is installed and check the version?

  • Open terminal or press Ctrl + Alt + t on your keyboard.
  • Type - javac -version and hit enter.
  • If java is installed, the output will be something like - 
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.18.04.1-b03)
OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)


Launching Eclipse

  • After installing eclipse, one folder with name "eclipse" will get created. 
  • Go to that folder and look for executable file named "eclipse" and double click on it to launch eclipse.



  • When this screen comes, it allows you to create a workspace and to choose a path for your workspace. Once you're ready click "Launch".
  • Once you clicked on launch, Eclipse will starts launching with the workspace selected in the above step.

  • You would see this window once your workspace is loaded completely. Here you can see quick links on left side under "Project Explorer" tab. 



Create a Project

  • Now click on "Create a project" quick link. A "New Project" window will open up which lets you select the type of project which you wish to create.
                                    
  • Click on "Java Project" and click on "Next".

  • On clicking "Next" another windows gets open which lets you give a name to the Project and once you're ready click "Finish".
  • OR You can also simply go to File > New > click on Java Project. Which opens up the window shown below.

  • Once you click on "Finish", the project with the given name will display on left pane.


Create a Package

Right click on "MyFirstProject" and New > Package. On clicking on Package a window will appear to give name for the Package. Once you're ready click on "Finish".


Once you click on "Finish" button, your package will get created and will display under your project.


Create a Class

To create a class, right click on package or project, New > Class. On clicking Class a window will appear to give name for the Class. You can select a "main" method to include in the Class (shown by a red arrow in the image below) or if you don't select it, then you can write it manually inside your class. 

Once you're ready click on "Finish".



Once the Finish is clicked, Class will get created and it will start displaying under the package name "org.app.v1".


Configuring Selenium

  • Right click on project "MyFirstProject" > Buid Path > Configure Build Path.
  • A window will get open and now go to "Libraries".
  • Click on "Add external JARs" to add selenium jar files.


  • Once you're done adding the selenium jar files in the libraries, click on "Apply and Close".


You have successfully configured Eclipse with Selenium WebDriver now. 

Thursday, July 25, 2019

Usability Testing

Usability


To understand the word "Usability" it can be broken in to "User" + "ability". User's ability to use anything, it may be a website, or driving a vehicle or a chair to sit on.

Usability is a part of user experience which speaks about the ease of access or using any functionality or a product. Let's move on to see "What is Usability Testing".

What is Usability Testing?

Usability testing is a type of testing which tries to see a product or a website from the users' end. And tries test or explore as a real user to see how easy or intuitive the experience provided by the product or a website. Now, the question arises is "When to perform usability testing?".

When to perform usability testing?

Usability testing should be performed at the early stages of SDLC (Software Development Life Cycle) so that the the UX perspective can be taken into consideration and which could help to uncover user expectations. 

Advantages of Usability Testing

Gives an output which is more user-friendly
Gives users' an ability to access and use the product easily.
Unleashes usability gaps before the product is ready for use.
Increased user satisfaction
Makes product more intuitive  
Helps to get a direct feedback from the users who use the system.
Helps in Customer retention
Helps business to grow

Featured Post

API Automation using Newman - Part II

HTML Report via Newman In previous post we have seen how to setup Newman and execute the collections via Newman in command line. Ne...