<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Harshi Wickramaarachchi on Medium]]></title>
        <description><![CDATA[Stories by Harshi Wickramaarachchi on Medium]]></description>
        <link>https://medium.com/@wwharshi?source=rss-3a1bafcf5a1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*wBqiBQZG7c7YCdMq.</url>
            <title>Stories by Harshi Wickramaarachchi on Medium</title>
            <link>https://medium.com/@wwharshi?source=rss-3a1bafcf5a1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 17:40:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wwharshi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Rest API Automation With Postman — Part II]]></title>
            <link>https://medium.com/@wwharshi/rest-api-automation-with-postman-part-ii-83a41e9d546d?source=rss-3a1bafcf5a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/83a41e9d546d</guid>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[newman]]></category>
            <category><![CDATA[report-generation]]></category>
            <category><![CDATA[rest-api-automation]]></category>
            <dc:creator><![CDATA[Harshi Wickramaarachchi]]></dc:creator>
            <pubDate>Fri, 11 Mar 2022 19:41:14 GMT</pubDate>
            <atom:updated>2022-08-31T08:48:59.523Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*OipPODVzUf9zZe827jHfhQ.png" /></figure><h3><a href="https://medium.com/@wwharshi/rest-api-automation-with-postman-phase-1-e4f75d0f3b04?source=your_stories_page----------------------------------------">Rest API Automation With Postman — Part </a>II</h3><p>In <a href="https://medium.com/@wwharshi/rest-api-automation-with-postman-phase-1-e4f75d0f3b04?source=your_stories_page">Rest API Automation With Postman — PartI</a> we discussed postman variables, how to automate a REST API with the postman.</p><p>In this article, we will be discussing</p><p>How to do schema validation <br>How to run postman collection through Newman<br>Report generation<br>How to set up a Jenkins job to execute the automation script</p><h3>Schema validation</h3><p>There are many tools that we can use for schema validation, but if we have a simple response we can do the validation manually</p><p>This is my demo URL — <a href="https://reqres.in/">https://reqres.in/</a><a href="https://reqres.in/api/users?page=2">api/users</a></p><p>Below is the response for above GET request</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eec694277bbdcb5fef159656faddf8b2/href">https://medium.com/media/eec694277bbdcb5fef159656faddf8b2/href</a></iframe><p>As the first step, we can write the response validation, then assign it to a variable and validate it with the response;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9GN4TXIb5ZjQ9o2UVvw4Pw.gif" /><figcaption>Add schema validation</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90c34ba1452b107f9fe82cda0b3d1060/href">https://medium.com/media/90c34ba1452b107f9fe82cda0b3d1060/href</a></iframe><p>Some response fields can contain null values, we should add that also into the schema validation part, Let’s say above example users&#39; email can be null in the response then we should have something like this</p><pre>“email”:{“type”:[“string”, “null”]}</pre><h3>Test execution with Newman</h3><p>As the first step, we should export our collection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XQ1HlU2hsbjZubCS1WH0wQ.gif" /><figcaption>Export the collection</figcaption></figure><p>Newman is built on Node.js. To run Newman, make sure you have <a href="https://nodejs.org/en/download/current/">Node.js</a> installed</p><p>Let’s open our folder from VS code, as the next step we need to create the package.json file, we can do it with the below command</p><pre>npm init</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iF3QxtAv7ukLjtmQyN3Adw.gif" /><figcaption>Project set up</figcaption></figure><p>Then we need to install Newman using the below command, with this Newman will be added to the package.json file as a dependency</p><pre>npm install newman</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r3pT44tChzb_o5vSb2TtAg.gif" /><figcaption>Install Newman</figcaption></figure><p>Finally, we can execute our script using Newman, As an example, my file name is TestUserCollection.json, then the command for that is</p><pre>newman run TestUserCollection.json</pre><p>We can add this command to the package.json file scripts and execute the automation script using that specific command.</p><p>package.json file script section →</p><pre>“scripts”: {<br>      “execute”: “newman run TestUserCollection.json”<br>}</pre><p>command to run this →</p><pre>npm run execute</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KAS41_d2uAOpopxqmz46FA.gif" /><figcaption>Run script with Newman</figcaption></figure><h3>Report generation</h3><p>For this, we will be using <a href="https://www.npmjs.com/package/newman-reporter-htmlextra">htmlextra</a>. To use htmlextra node version should be greater than 14</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VHxO-2vvnsIv-eyW9PphZw.gif" /><figcaption>Install htmlextra</figcaption></figure><p>Command to install htmlextra, this will add a dependency to the package.json file</p><pre>npm install newman-reporter-htmlextra</pre><p>In order to generate the reports we need to change the test execution command to</p><pre>“scripts”: {<br>   “execute”: “newman run TestUserCollection.json -r htmlextra”<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mNT7515UGVmMXH9pLrQZAw.gif" /><figcaption>HTML report generation</figcaption></figure><h3>Jenkins integration</h3><ul><li>Click on the new item</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*my6zItBLERJlawloumNRDA.png" /><figcaption>Click on new item</figcaption></figure><ul><li>Input job name and click on ‘Freestyle project’</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xVRBuYlsdgdzSgzWdw5fEg.png" /><figcaption>Add job name and select freestyle project</figcaption></figure><ul><li>Set number of builds to keep and number of days</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nlvs4csarb7THNC1cc3dJQ.png" /><figcaption>What to do with old builds</figcaption></figure><ul><li>Add relevant repository settings</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BJfu37hF8MbNidxKwLWoHA.png" /><figcaption>Repository settings</figcaption></figure><ul><li>Add build triggers → <a href="https://www.ibm.com/docs/en/db2oc?topic=task-unix-cron-format">https://www.ibm.com/docs/en/db2oc?topic=task-unix-cron-format</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nKpsQhJTIGYBwEz6Sju-lg.png" /><figcaption>Add build triggers</figcaption></figure><ul><li>Add windows batch command to execute the script</li></ul><p>Click on the ‘ADD BUILD STEP’ and then select ‘Execute Windows batch command’</p><p>If it is a Linux server we can use ‘Execute shell’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*3tnwjhTIsnscOPJ4d7BXAg.png" /><figcaption>Select ‘Execute Windows batch command’</figcaption></figure><p>Add script execution command in the windows command section (command which we used to execute automation script through Newman)</p><pre>npm run execute</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rU7DsjoyXcYhhZQFv1KgYQ.png" /><figcaption>Add command</figcaption></figure><ul><li>Report generation</li></ul><p>Click on the ‘ADD POST-BUILD ACTION’ and then select ‘Publish HTML reports’ option</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*w160mkbEazXrF36DPjVSMQ.png" /><figcaption>Select ‘Publish HTML reports’</figcaption></figure><p>Then we need to provide the location where the HTML reports are generated</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jAiPG3BBp33vpSS8tz_pxg.png" /><figcaption>Add HTML reports location</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83a41e9d546d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Selenium with VS Code]]></title>
            <link>https://medium.com/@wwharshi/selenium-with-vs-code-ee47aaa443d5?source=rss-3a1bafcf5a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee47aaa443d5</guid>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[selenium-webdriver]]></category>
            <category><![CDATA[visual-studio-code]]></category>
            <category><![CDATA[selenium-c-sharp]]></category>
            <category><![CDATA[selenium-test-automation]]></category>
            <dc:creator><![CDATA[Harshi Wickramaarachchi]]></dc:creator>
            <pubDate>Wed, 24 Nov 2021 18:28:36 GMT</pubDate>
            <atom:updated>2021-11-25T15:53:51.689Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*x21ScvM6GAvCJ3jxSrEwqw.png" /></figure><p>This article will describe how to set up a selenium project with VS Code. First, we will be discussing VS code setup. Then we will learn about selenium locators and automate a simple login scenario.</p><p>We can use NUnit and execute our tests. Then we can separate driver initialization and have a separate class. As the last thing, we will apply Page Object Module(POM).</p><p>How to set up VS Code for selenium automation; We need to add the below extensions to VS Code.</p><ol><li>Create a folder and open it from VS Code</li><li>Go to extensions from vS Code and search for c# and install</li><li>Search NuGet package manager and install</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gXlopp-2Un1SyZEI5W5d-A.gif" /><figcaption>Add necessary extensions</figcaption></figure><p>Now let’s add other necessary files</p><ol><li>Go to terminal and run ‘dotnet new console’ to add necessary files</li><li>Again run ‘dotnet new sln’ on the terminal to add the solution file</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*woyYk2_Ba9HyN4NDE9UimA.gif" /><figcaption>Add other files</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ycfUhRUFvqLCUJSJ5ms8Sg.gif" /><figcaption>Add solution file</figcaption></figure><p>Now let’s add Selenium Web Driver and Chrome Driver</p><p>To add selenium web driver:</p><ol><li>Go to command pallet</li><li>Search NuGet package manager and add it</li><li>Type selenium and select selenium.webdriver</li><li>Then select the relevant dotnet SDK version (You can get the dotnet version by executing ‘dotnet –info‘ command in a separate console)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0PrQGJPe_Z9zEUQNw0pNIg.gif" /><figcaption>Add selenium web driver</figcaption></figure><p>To add chrome driver:</p><ol><li>Go to command pallet</li><li>Search NuGet package manager and add it</li><li>Type chromedriver and select Selenium.WebDriver.ChromeDriver</li><li>Then select the relevant version</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EcGTax8QSJchEkVYfZKtOg.gif" /><figcaption>Add chrome driver</figcaption></figure><p>— — — — — — — — —— — — or — — — — — — — — — — — — —</p><p>Download chrome driver, extract it, and add to project location</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0ETHYC6eZlRs1-djObiQYA.gif" /><figcaption>Download chrome driver</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*806f0VJkXliZJE-Gqw3iLg.png" /><figcaption>Extract the zip folder and add it to the project location</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*yVDfXRnGAZF7sYQVg1VcTQ.png" /><figcaption>Solution after adding chrome driver</figcaption></figure><p>Now let’s write our first piece of code</p><ol><li>Initialize the driver within the main method and navigate to the given URL (test URL — <a href="https://www.saucedemo.com/">https://www.saucedemo.com</a>)</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d56d043e873573b5e9caa44c2cc2ca0a/href">https://medium.com/media/d56d043e873573b5e9caa44c2cc2ca0a/href</a></iframe><p>2. To execute the test type ‘dotnet run’ on the terminal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aSsuMq2_Gpjf6pqyp4dfew.gif" /><figcaption>First code — Initialize the web driver and navigate to the given URL</figcaption></figure><p>3. To maximize the browser window we can use</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/94d95a9fce9f471507cbf4bff3e13605/href">https://medium.com/media/94d95a9fce9f471507cbf4bff3e13605/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A9E9pYzUcBny9t3Pk7Thtw.gif" /><figcaption>Maximize browser window</figcaption></figure><p>Now let’s automate the login scenario</p><p>First, we need to locate the elements. Basic selenium locators that we can use are → ID, Name, ClassName, LinkText, TagName, CssSelector, XPath</p><p>To find element locators we can use developer tools or some kind of a simple browser extension.</p><p>Simple code snippet to find user name text box, clear it, and input user name</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c176531c37f9547946c6a92c75fd00d5/href">https://medium.com/media/c176531c37f9547946c6a92c75fd00d5/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*twyvItu8jHvgPHsW78pAwg.gif" /><figcaption>Login scenario automation</figcaption></figure><p>Now let’s remove the main method and execute the tests using NUnit</p><p>To add NUnit:</p><ol><li>Go to command pallet</li><li>Search NuGet package manager and add it</li><li>Then type Nunit and add Nunit</li></ol><p>To add NUnit test adaptor:</p><ol><li>Go to command pallet</li><li>Search NuGet package manager add it</li><li>Search NUnit</li><li>Add Nunit test adaptor</li></ol><p>To add Microsoft.TestPlatform.TestHost</p><ol><li>Go to command pallet</li><li>Search NuGet package manager add it</li><li>Search test platform</li><li>Add Microsoft.TestPlatform.TestHost</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y4z3MYdNXS4xqZiBxEsFbw.gif" /><figcaption>Add NUnit</figcaption></figure><p>Now we can add annotations; Let’s define driver outside from the main method, driver initialize part in the ‘[SetUp]’, test execution part in the ‘[Test]’ and post-execution part in the ‘[TearDown]’</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25afa50b1e480a29f20e5f946e37d14c/href">https://medium.com/media/25afa50b1e480a29f20e5f946e37d14c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MQrtmtflKbkH6_7fo0f1DQ.gif" /><figcaption>Add annotations</figcaption></figure><p>Now we can remove the main method and execute the test;</p><p>let&#39;s add ‘[TestFixture]’ and remove the main method and execute the test. We can use ‘Run All Tests’ to execute all the tests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4TGPSahE-UAQ3zvaKtDBEg.gif" /><figcaption>Remove the main method</figcaption></figure><p>Let’s use a static driver; We can create a separate class for the driver initialization and use that driver in the test script class and other classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jp2UBW9zKw2yiudSGXHkKA.gif" /><figcaption>Add static driver class</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vJ4hJR3JgQXj2RAJzJEKwA.gif" /><figcaption>Static driver usage in test script class</figcaption></figure><p>Now let’s see how we can use Page Object Module (POM); we can have login elements in a separate class and those elements related functionalities in a separate class. (Here elements and the related functionalities are in the same class)Our test script class will have only the test steps and assertions</p><p>Let’s create a separate class for Login</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BZNY7Dn0ZEd4l12-JtOFHQ.gif" /><figcaption>Apply POM — Create Login Page</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kGBnjblea8-XoovYcDT_HQ.gif" /><figcaption>Apply POM — Using Login Page in test script page</figcaption></figure><p>This is the basic project setup. We can follow below steps after this;</p><p>Create a <em>pageObjects</em> folder → Create separate classes for page elements and have them inside this folder</p><p>Create a <em>scripts</em> folder → Create separate classes for functionalities related to objects and keep them inside this folder</p><p>Create <em>testScripts</em> folder and have all the test scripts in that</p><p>Create a <em>utility</em> folder → Create separate classes for common methods and have them inside this folder</p><p>Keep data inputs in separate JSON/resource files and use them in the code</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee47aaa443d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rest API Automation With Postman - Part 1]]></title>
            <link>https://medium.com/@wwharshi/rest-api-automation-with-postman-phase-1-e4f75d0f3b04?source=rss-3a1bafcf5a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4f75d0f3b04</guid>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[rest-api-automation]]></category>
            <category><![CDATA[automation-testing]]></category>
            <dc:creator><![CDATA[Harshi Wickramaarachchi]]></dc:creator>
            <pubDate>Sun, 31 Oct 2021 14:29:15 GMT</pubDate>
            <atom:updated>2021-11-25T15:58:26.416Z</atom:updated>
            <content:encoded><![CDATA[<p>Before we start with API automation let’s have a look at variable types available in postman, they are;</p><p>Global variables - available throughout a workspace, so can access between collections and environments.</p><p>Environment variables - you can create multiple environments and save variables in them, EX:-test, production. Whenever you want to access specific environment data you should select the relevant environment.</p><p>Collection variables - available throughout the requests within a collection and they do not change based on the selected environment.</p><p>Local variables - You can define variables within the request.</p><p>Data - you can import data from external .csv and JSON files when your executing tests via Newman or collection runner (will discuss later)</p><h4>Create workspace</h4><p>Now let’s have a look at basic API request automation.</p><p>As the first step we need to create a workspace, You can click on the ‘workspaces’ and then click on the ‘Create Workspace’ button.</p><p>Next, you can add a name wok the workspace and then give the access permissions, and create the workspace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*89Sun3ozU2hA56zhfFLprA.gif" /><figcaption>Create a workspace</figcaption></figure><h4>Create a collection and add a request</h4><p>Next need to create a collection where we’ll have requests. Click on the ‘collections’ tab that is available on the left menu and then click on the ‘create collection’ button. Then you can add the collection name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5yON3vly-wiWa2vsCzTopA.gif" /><figcaption>Create a collection</figcaption></figure><p>You can add folders inside the collection if you want to group the requests or you can directly add the requests to the collection. Then you can add a request by clicking on the ‘Add a request’ link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hJpHTs6Wg2QPGkxDSQ_b2A.gif" /><figcaption>Add a request</figcaption></figure><p>Then you can add an appropriate name to the request and then add the method and URL. Here I am using a GET API to get the user so I will name the request as ‘get_users’. The method is GET. I am using a demo URL — <a href="https://reqres.in/">https://reqres.in/</a><a href="https://reqres.in/api/users?page=2">api/users</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LXl2vxq7e4G5OJNBq0UZ5A.gif" /><figcaption>Adding request name, method, and URL</figcaption></figure><p>Now you can execute the request and get the response.</p><h4>Adding global variables</h4><p>Now let’s have a look at adding variables. You can add variables by clicking on the eye icon that is available on the right side.</p><p>There you get two sections, environment variables, and global variables. Click on the ‘Add’ button of the global section. Then you can add the relevant variable and input the value. Here I am using the same variable (base_url) in global, environment, and collection levels for demo purposes. But you should define in just one level, mostly environment or collection level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w01r1LwD3wlGm_HrYHoF1A.gif" /><figcaption>Add global variables</figcaption></figure><h4>Adding environments and variables</h4><p>To create environment variables first you should create the environment. As I mentioned earlier, we can create test, staging, or productions environments. First, click on the ‘Environment’ that is available in the left menu. Then click on the ‘Create Environment’ button. Then you can add a name to the environment.</p><p>You also can add an environment by clicking on the eye icon that is available on the right side and then by clicking on the ‘Add’ button related to the environment section.</p><p>After adding an environment you should be able to see it in the environments drop down which is next to the eye icon. You should be able to select the added environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rQM4PFK-JRDUhMh92hpj6w.gif" /><figcaption>Add environment variables</figcaption></figure><h4>Adding collection variables</h4><p>To add collection variables, you need to click on the ‘more’ icon that is available in the created collection. Then in the dropdown, you have an edit option. Click on that.</p><p>Now you should click on the ‘variables’ tab. Now you can add collections variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zpkbvl-PYqybHOqou3IpfA.gif" /><figcaption>Add collection variables</figcaption></figure><p>Now we know how to add global variables, environment variables, and collection variables. Now let’s see how to use them. Since we have parameterized the base URL we have to use the variable in the URL section. There we can add {{base_url}} and the rest of the URL that is related to the specific request.</p><p>Here you can see when I type I get suggestions from global variables, environment variables, and collection variables. We normally have to use only one level. Either collection, environment, or global. I have added the same variable to all the levels just for demo purposes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g9el8t9WnHrXG_3CwcZh1Q.gif" /><figcaption>Adding {{base_url}}</figcaption></figure><h4>Response Validation</h4><p>Executing order of postman scripts are,</p><p>Pre-request scripts → request → response →test</p><p>You have to write all the things that need to do before executing the request need to be written in pre-request script Ex:- assigning variable values.</p><p>Test response code</p><p>You have to do all the validations in the test — Ex:- test response code, test response time, test error codes, schema validation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8QNlpObbl-7kFtjWU-kXeg.gif" /><figcaption>Response status validation</figcaption></figure><p>Code to test response status</p><pre>pm.<strong>test</strong>(‘Response Validation’,()<strong>=&gt;</strong>{</pre><pre>pm.response.to.have.status(200);</pre><pre>pm.response.to.have.status(‘OK’);</pre><pre>})</pre><p>Test response time</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nsup4EzAq3qKn6sNzKgA0Q.gif" /></figure><p>Here the test related to response time failed because response time is above 500ms.</p><pre>Code to test response time</pre><pre>pm.<strong>test</strong>(“Response time”, ()<strong>=&gt;</strong>{</pre><pre>pm.expect(pm.response.responseTime).to.be.below(500);</pre><pre>});</pre><p>The next part will be schema validation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4f75d0f3b04" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>