<?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 Nitish Man Shrestha on Medium]]></title>
        <description><![CDATA[Stories by Nitish Man Shrestha on Medium]]></description>
        <link>https://medium.com/@nitishmaan567?source=rss-186f47402ac2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JLPvJDluXSMQwSdgnar72A.jpeg</url>
            <title>Stories by Nitish Man Shrestha on Medium</title>
            <link>https://medium.com/@nitishmaan567?source=rss-186f47402ac2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 04:20:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nitishmaan567/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[Utilizing if-else to validate JSON schema]]></title>
            <link>https://medium.com/@nitishmaan567/utilizing-if-else-to-validate-json-schema-14d1636d80b6?source=rss-186f47402ac2------2</link>
            <guid isPermaLink="false">https://medium.com/p/14d1636d80b6</guid>
            <category><![CDATA[qa-testing]]></category>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[json]]></category>
            <dc:creator><![CDATA[Nitish Man Shrestha]]></dc:creator>
            <pubDate>Wed, 07 Aug 2024 12:30:00 GMT</pubDate>
            <atom:updated>2024-08-07T12:30:00.433Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NhiV7e-jPQoA_d6tHRP3kA.png" /></figure><p>When I started creating test automation for the APIs, it didn’t take me long to realize that Schema validation is a cornerstone of robust API automation. It ensures data consistency, integrity, and security by defining the expected structure and format of request and response payloads. Although this way of data validation might seem uptight and rigid at first if you put ample time into research on this, you’ll realize the customizability of schema validation.</p><h4>A PRACTICAL EXAMPLE</h4><p>Imagine an e-commerce API with an endpoint for retrieving product details. The endpoint might accept different request payloads based on specific criteria. For instance, if the request includes a <strong><em>courseId</em></strong><em> </em>parameter, the response should contain detailed product information. However, if the request comprises a <strong><em>courseDetails </em></strong>parameter, the response might return a list of courses within that category.</p><p>To handle such conditional responses, we can leverage schema validation to define multiple schemas, each representing a different request and response structure.</p><h4>SAMPLE ENDPOINT</h4><pre>/qa-courses</pre><h4>SAMPLE PAYLOADS</h4><p>Request Payload that gives details of a specific product based on the ID provided</p><pre>{ <br> &quot;courseId&quot;: 11 <br>}</pre><p>Request Payload that gives product list:</p><pre>{ <br> &quot;courseDetails&quot;: &quot;QA courses&quot; <br>}</pre><h4>SAMPLE RESPONSE</h4><p>Assuming the hypothetic request payloads yield us JSON response structures that look something like this:</p><p><em>Course-specific details when course ID is passed as a payload</em></p><pre>{<br>    &quot;data&quot;: [<br>        {<br>            &quot;courseId&quot;: 11,<br>            &quot;courseName&quot;: &quot;API schema validation crash course&quot;,<br>            &quot;summary&quot;: &quot;This is a crash course on how to automate your test like a pro. Hurry up before the seats get full&quot;<br>        }<br>    ],<br>    &quot;query&quot;: &quot;courseId&quot;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e8W0v1oTloDLvx5oMUCLzA.png" /></figure><p>Details of all courses when <em>courseDetails </em>are passed in the payload</p><pre>{<br>    &quot;data&quot;: [<br>        {<br>            &quot;courseId&quot;: 11,<br>            &quot;courseName&quot;: &quot;API schema validation crash course&quot;,<br>        },<br>        {<br>            &quot;courseId&quot;: 12,<br>            &quot;courseName&quot;: &quot;The best JMeter + Selenium webdriver sampler 101 you&#39;ll ever find&quot;,<br>        },<br>        {<br>          &quot;courseId&quot;: 13,<br>          &quot;courseName&quot;: &quot;Set up &#39;Extended Email Notification - Jenkins&#39; like a pro&quot;,<br>        }<br>    ],<br>    &quot;query&quot;: &quot;courseDetails&quot;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yI_8AAPots9xAP44_o1KHA.png" /></figure><h4>DIGGING A LOGIC</h4><p>The provided JSON schema defines a structure for a data object with two required properties: query and data. The query property can have two values: courseId or courseDetails. Based on the value of query, the structure of the data property changes.</p><h4>HAMMERING A LOGIC</h4><p><strong>Root Level</strong></p><ul><li><strong>type&quot;: &quot;object&quot;</strong>: Specifies that the data should be an object.</li><li><strong>additionalProperties&quot;: false</strong>: Prevents unexpected properties from being added to the object.</li><li><strong>properties</strong>: Defines the allowed properties of the object.</li><li><strong>query</strong>: A string property that is required.</li><li><strong>data</strong>: An array property that is required.</li><li><strong>required</strong>: Ensures that both query and data properties are present.</li></ul><p><strong>Conditional Logic with </strong><strong>if, </strong><strong>then, and </strong><strong>else</strong></p><ul><li><strong>if</strong>: Defines a condition: the query property must have a constant value of &quot;courseId&quot;.</li><li><strong>then</strong>: If the if condition is true, the data property must be an array of objects with specific properties (courseId, courseName, summary).</li><li><strong>else</strong>: If the if condition is false, the data property must be an array of objects with different properties (courseId, courseName).</li></ul><p><strong>Key Points</strong></p><ul><li>The schema uses conditional logic to validate the data structure based on the query value.</li><li>The required keyword is used to enforce the presence of essential properties.</li><li>The additionalProperties keyword prevents unexpected properties within the objects.</li></ul><pre>{<br>    &quot;type&quot;: &quot;object&quot;,<br>    &quot;additionalProperties&quot;: false,<br>    &quot;properties&quot;: {<br>        &quot;query&quot;: {<br>            &quot;type&quot;: &quot;string&quot;<br>        },<br>        &quot;data&quot;: {<br>            &quot;type&quot;: &quot;array&quot;<br>        }<br>    },<br>    &quot;required&quot;: [<br>        &quot;query&quot;,<br>        &quot;data&quot;<br>    ],<br>    &quot;if&quot;: {<br>        &quot;properties&quot;:{<br>            &quot;query&quot;: {<br>                &quot;const&quot;: &quot;courseId&quot;<br>            } <br>        }<br>    },<br>    &quot;then&quot;: {<br>        &quot;data&quot;: {<br>            &quot;item&quot; :{<br>                &quot;type&quot;: &quot;object&quot;,<br>                &quot;additionalProperties&quot;: false,<br>                &quot;properties&quot;: {<br>                    &quot;courseId&quot;: {<br>                        &quot;type&quot;: &quot;integer&quot;<br>                    },<br>                    &quot;courseName&quot;: {<br>                        &quot;type&quot;: &quot;string&quot;<br>                    },<br>                    &quot;summary&quot;:{<br>                        &quot;type&quot;: &quot;string&quot;<br>                    }<br>                },<br>                &quot;required&quot;: [<br>                    &quot;courseId&quot;,<br>                    &quot;courseName&quot;,<br>                    &quot;summary&quot;<br>               ]<br>            }<br>        }<br>    },<br>    &quot;else&quot;: {<br>        &quot;if&quot;: {<br>        &quot;properties&quot;:{<br>            &quot;query&quot;: {<br>                &quot;const&quot;: &quot;courseId&quot;<br>            } <br>        },<br>            &quot;then&quot;: {<br>                &quot;data&quot;:{<br>                &quot;items&quot;: {<br>                    &quot;type&quot;: &quot;object&quot;,<br>                    &quot;additionalProperties&quot;: false,<br>                    &quot;properties&quot;:{<br>                        &quot;courseId&quot;: {<br>                            &quot;type&quot;: &quot;integer&quot;<br>                        },<br>                        &quot;courseName&quot;: {<br>                            &quot;type&quot;: &quot;string&quot;<br>                        }<br>                    },<br>                    &quot;required&quot;: [<br>                        &quot;courseId&quot;,<br>                        &quot;courseName&quot;<br>                    ]<br>                    }<br>                }<br>            }    <br>        }<br>    }<br>}</pre><p>There you go, you have a guide on how to use if-else statement for schema validation. In real world, the scenario might not be as straight forward as this, but the fundamental shall still remain the same. Hope it helps you to facilitate your schema with greater efficiency.</p><p>If you have any additional information regarding the topic or any feedbacks then feel free to leave it down below, or you can directly send me a mail at <strong><em>nitishmaan567@gmail.com, </em></strong>or we can connect on <a href="https://www.linkedin.com/in/nitish-man-shrestha/">LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14d1636d80b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to authenticate a user before attacking | Security Testing | ZAP]]></title>
            <link>https://medium.com/@nitishmaan567/how-to-authenticate-a-user-before-attacking-security-testing-zap-6cfad04ea390?source=rss-186f47402ac2------2</link>
            <guid isPermaLink="false">https://medium.com/p/6cfad04ea390</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[qa]]></category>
            <dc:creator><![CDATA[Nitish Man Shrestha]]></dc:creator>
            <pubDate>Sun, 31 Mar 2024 14:14:26 GMT</pubDate>
            <atom:updated>2024-03-31T14:30:21.535Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*s-XDkM89kh0SviCf54puRA.png" /></figure><p>Installation and getting started with almost every tool, language, and package, almost anything is easy. You can find multiple YouTube videos that walk you through the setup process way easier than blogs but things that are missed out and learnt based on pure research deserves to be documented, hence this one is to all those who have found themselves in a situation like I did where I didn’t know how to pass credentials and setup the configurations. Honestly speaking, ZAP seems to have a slightly denser learning curve compared to all the other testing tools that I have used previously.</p><p>The product that I was testing had a handful of pages that were accessible without the user logging into the application. However, to have more coverage, I had to log into the application.</p><p>When you try scanning an application without authenticating a user even when some sort of authentication is required. You shall receive a 4XX response code and the error message will read as:</p><blockquote>Failed to attack the URL received 401 response code expected 200.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UY8ExDVRDlb51fbhEmBVvw.png" /></figure><p>This is an expected case when you try to access internal pages and endpoints without authenticating.</p><p>This is where we utilize the ZAP Context,</p><h3>Steps</h3><ol><li>Navigate to the ZAP context and double-click on the default context or you may create a new one. Context is important when it comes to authentication cause this is where we set the required configuration for any sort of authentication</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5r58FKB3xq3JhbNifsKddw.png" /></figure><p>Within the context menu, you would wanna navigate to the Include in Context sub-tab.</p><p>2. Click on the Add button on the top right side of the dialogue box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*80aB_XnnZJxF7yJC6AqWAQ.png" /></figure><p>3. You need to add the Base URL and an asterisk (.*) at the end of the URL. It is suggested to add an asterisk (*) at the end of the URL pattern to ensure that ZAP includes all subdirectories and resources under the specified URL in the context.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*AdFOfcKaJV-aNzy9zinyzA.png" /></figure><p>4. Set up the Authentication:</p><ul><li>Select the authentication method as HTTP Authentication.</li><li>Hostname: the base URL</li><li>Port: 443 (if you are gonna be making an HTTPS request)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*6GUuRRU8oL15M8NCUtYDOw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*SB9PZAaHMVCBvAl9Dvcdrg.png" /></figure><p>5. User: Add a user variable that contains the details about the user</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UujGX6H9bS2WHVdm0JcX2A.png" /></figure><p>6. Session Management: Select the session management option as HTTP Authentication Session management</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VWKXoYzAH_AmcdWV2ThUXw.png" /></figure><p>7. Add spider functionality to get all the URLs that the program can find.</p><ul><li>Context &gt; “your_context_name” &gt; Spider</li><li>Click on the dropdown of the User variable and select the appropriate variable</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*2EldRhP0RvB8yB8cEqV6kg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*P_C7tAGuSzLgWdqNxMI5mw.png" /></figure><p>8. Active Scan: Now double-click on the Context that you have been making changes in and select the active scan option. Under the Scope tab. select the User dropdown and you shall see the variable that you created before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*YLx3VONDWbLSA2avRqHP5Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k_sH78Z-ORu4Hvn4GQ6UsQ.png" /></figure><p>After all this ruckus, finally, you shall be able to access the internal pages of the application that were only accessible if a valid user had logged in to the system. Hence, the test will not fail and now you can scan your system for all the major security-related vulnerabilities identified by OWASP that you are exposed to or may be prone to.</p><p>If in case you found it difficult to follow through here is a link to a visual reference that you can follow all along to make it easier for you.</p><p>Visual Reference: <a href="https://www.youtube.com/watch?v=fikw_pNzxIk">OWASP ZAP with Basic Authentication</a></p><p><strong>BONUS TIP:</strong></p><h3>GENERATING REPORT</h3><p>Generating a report is easy, but generating a report that conveys the details lucratively and isn’t merely just a bunch of numbers, tags, idioms, charts and graphs is difficult. Having the data is half the work, representing it is the other half of the job. ZAP offers a variety of report formats, but I chose the one that is most easily understandable.</p><p>Before generating a report, ensure that you have completed the security scan of your web application using ZAP. This includes configuring the scan settings, initiating the scan, and allowing ZAP to complete its analysis of the target application.</p><p>Review Detected Alerts, you will see a list of security vulnerabilities and issues detected during the scan under the alert tab. Review these alerts to understand the types of vulnerabilities identified, their severity levels, affected URLs, and additional details provided by ZAP.</p><ol><li><strong>Generate the Report</strong>: To generate a report based on the detected alerts, follow these steps:</li></ol><ul><li>Click on the “Report” button or select the “Report” option from the menu.</li><li>Choose the format for the report. ZAP supports various report formats, including HTML, XML, JSON, and others. Select the <strong>Risk and Confidence HTML</strong> format. (Why? because it is so damn simple and easy to understand)</li><li>Specify the location where you want to save the report file on your computer.</li><li>Optionally, you can customize the report settings, such as including additional information or adjusting the report layout. These options may vary depending on the chosen report format.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*gJDxD-rZaVmjE4w7VmwbVw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*bZfCTov0tQ_kh2BAXGO3vg.png" /></figure><p><strong>2. Save the Report</strong>: After configuring the report settings, click on the “Save” or “Generate” button to generate the report. ZAP will generate the report file based on the selected format and save it to the specified location on your computer.</p><p><strong>3. Review and Share the Report</strong>: Once the report is generated, you can open it using a compatible viewer or editor to review the findings. Share the report with relevant stakeholders, such as developers, security teams, or management, to communicate the results of the security scan and prioritize remediation efforts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6cfad04ea390" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Set up “Extended Email Notification — Jenkins” like a pro]]></title>
            <link>https://medium.com/@nitishmaan567/set-up-extended-email-notification-jenkins-like-a-pro-0d1ce1684710?source=rss-186f47402ac2------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d1ce1684710</guid>
            <category><![CDATA[email]]></category>
            <category><![CDATA[setup]]></category>
            <category><![CDATA[jenkins]]></category>
            <dc:creator><![CDATA[Nitish Man Shrestha]]></dc:creator>
            <pubDate>Mon, 26 Feb 2024 16:36:12 GMT</pubDate>
            <atom:updated>2024-02-27T05:23:50.684Z</atom:updated>
            <content:encoded><![CDATA[<h3>Set up “Extended Email Notification — Jenkins” like a pro</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*iz4T9PTXNDZSFnASkZbDcQ.png" /></figure><p>So you’ve successfully set up a couple of pipelines in Jenkins, and now you want to know the status and outcomes of the job that you triggered/ scheduled. Not just the outcome but a brief yet relative status of the build, if the build was successful, or if it is unstable, what is the number of build and similar stuff. A simple and straightforward way of doing that is automating email notifications that shall be triggered after the completion of the Jenkins job. Which can briefly give you details about the build and also provide the email recipients with a link to the build in Jenkins.</p><p>Jenkins has two most widely used email notification features. One is the vanilla email notification with a lot less to play around with. It provides basic email functionality and is suitable for simple notification needs. Another one is the Extended Email Notification which is the one that we are going to discuss in this post not just because we don’t wanna stick with the basic stuff, but because Extended Email notification is an extended and more feature-rich version of the email notification system. It offers more advanced features and customization options compared to the basic email notification. With Extended Email Notification, you can customize the email content using HTML or text templates.</p><p>Okay now let’s install the bad boy first.</p><p>Log in to Jenkins and navigate to the Manage Jenkins tab within the dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BdznTWhZZ9Bqg0fOpBrqkA.jpeg" /></figure><p>Now, click the ‘Manage Jenkins’ menu option located on the right side of the screen. This action will redirect you to the ‘Manage Jenkins’ page. From there, select the ‘Manage Plugin’ option.</p><p>Navigate to the ‘Available’ tab located at the top of the ‘Manage Plugin’ page.</p><p>In the ‘Filter’ field situated at the top-right side of the ‘Manage Plugin’ page, type ‘Extended ’. Subsequently, check the checkboxes next to the ‘Email Extension Template plugin’ option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KICT9UH_Zz1CrzPl1y5sMg.png" /><figcaption>Mine was already installed so looked it up on the installed tab :D</figcaption></figure><p>Finally, click the ‘Install without restart’ button to initiate the installation process.</p><p>After the installation is done, navigate to the Jenkins home page and select the ‘Manage Jenkins’ menu option. From there, choose the ‘Configure System’ option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sDJYazu8zjEX37-ya0X2Kg.png" /></figure><p>Under ‘ Extended Email Notification’, input the SMTP server name as ‘smtp.gmail.com’. Click on the ‘Advanced’ button and ensure to tick the checkbox beside ‘Use SMTP Authentication’. Proceed to fill in the required fields as follows:</p><ul><li>SMTP server name: smtp.gmail.com</li><li>User name: user_email_id@gmail.com</li><li>Password: 123456</li><li>Use SSL: Checked</li><li>SMTP Port: 465</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OqENifwJ6wNILampxZgAgg.jpeg" /></figure><p>After you hit “Save”. Navigate to the dashboard, and open the configurations of the Jenkins job that you want to customize the Editable email notification. Select the post-build Actions tab, under which you will see a dropdown named “Add post-build action”. Click on the dropdown and you should see the “Editable Email Notification”. Select the option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W02PzpTajSixbe_wcv_UPg.png" /></figure><p>After the Editable Email Notification plugin is added. It should look something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d1InfxC9Sfc7XqZ7e265uw.png" /></figure><ul><li>Project Recipient List: here you can enter the email IDs that you want to send the post-build mail about the status of the job. Note: if you want to trigger this mail to multiple email IDs then use comma as a separator. and the list of emails should look like this:</li><li><strong>email_id1@gmail.com, email_id2@gmail.com, email_id3@gmail.com</strong></li></ul><p>Now navigate to the very bottom of the form and you should see the advanced settings dropdown. Click the ‘Add Trigger’ drop-down, and select the ‘Always’ option and Click the ‘Save’ button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DcQbdr9dyaPpBlTHraH99Q.jpeg" /></figure><p>Now you need to adjust the default subject and the default content as per your project’s need. Here is something I generally go with:</p><blockquote><strong>Default Subject:</strong> API Test Report as of ${BUILD_TIMESTAMP} — JOB_NAME</blockquote><blockquote><strong>Default Content: </strong>The automated test report for JOB_NAME executed via Jenkins has finished its latest run.</blockquote><blockquote>- Job Name: ${JOB_NAME}<br>- Job Status: ${BUILD_STATUS}<br>- Job Number: ${BUILD_NUMBER}<br>- Job URL: ${BUILD_URL}</blockquote><blockquote>Please refer to the build information above for additional details.</blockquote><blockquote>This email is generated automatically by the system.</blockquote><blockquote>Thanks</blockquote><p>Hit save and you’re done!</p><p><strong>PRO TIP</strong>: if you want a customized ${BUILD_TIMESTAMP} then all you gotta do is navigate to Dashboard&gt; Manage Jenkins &gt; Configure System and configure the pattern as per your need.</p><p>The pattern that I prefer is:</p><blockquote>MMMM dd, yyy | hh:mm:ss aaa | z</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JIuORdPugHUH-d1estdgiA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d1ce1684710" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The best JMeter + Selenium Webdriver sampler 101 you’ll ever find]]></title>
            <link>https://medium.com/@nitishmaan567/the-best-jmeter-selenium-webdriver-sampler-guide-youll-find-560a7f9fabf9?source=rss-186f47402ac2------2</link>
            <guid isPermaLink="false">https://medium.com/p/560a7f9fabf9</guid>
            <category><![CDATA[qa]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[jmeter]]></category>
            <category><![CDATA[selenium]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Nitish Man Shrestha]]></dc:creator>
            <pubDate>Sat, 22 Jul 2023 18:06:34 GMT</pubDate>
            <atom:updated>2023-07-27T15:59:29.047Z</atom:updated>
            <content:encoded><![CDATA[<p>You know what they say “Modern problems require modern solutions” and believe me when I say that the problem that I was stuck in only had non-upgraded-historic solutions to it, henceforth, in the interest of saving time of fellow QAs who are just getting their feet wet in the field of performance testing or for those who do use Jmeter but don’t really know how to bridge it with Selenium, here I present to you “how to integrate Selenium with Jmeter” and make it work like a charm!</p><h4>Where it began (Problem statement)</h4><p>Last week, my clients asked me to do performance testing on all of their platforms, I had my preferences on tools that I could go with, but they suggested we use the most popular, reliable and ancient tool there is that performs performance testing (See what I did there :D). For most of the platforms, it was a straightforward process. I created a new project in Jmeter, added a test plan to it, popped a Thread Group within that Test Plan and configured the Number of users and think time, and inside of the Thread Group included HTTP Samplers to fill up the respective details of the endpoint to test and then finally incorporated listeners. I used CSV Data Set Config to pass user credentials and called those variables to log in to the system. Pretty simple. Right?</p><p>I repeated the same routine for a couple of our platforms, and it worked on them. Valid but dummy user accounts that were logging into the system were giving providing approx expected results and the reports were evident, however, in one of the platforms, the same drill entirely didn’t turn out as I expected it to. Even when provided with valid credentials, well-configured headers, and the right endpoints, I was getting redirected back to the login page. Turns out we happen to use a third-party software solution for identity and access management (IAM), meaning a third-party software was already integrated with the system that took care of the user authentication and authorization, tasks such as generating a unique token/JWT, X-TRACE-ID, Session ID and then caching and validating them was taken care by the IAM itself, which then was only being triggered after a browser session ID was generated, and you guessed it right for a browser session ID to be initiated the action had to take place in a browser and based on that ID rest of the flow was to go on, so even when the configurations, variables and process were exemplary, the endpoint would redirect us to login page.</p><p>And after spending some good hours on research, this is the solution that I found:</p><h4>Weapons that you’re going to need(Pre-requisites)</h4><ol><li>First things first, let&#39;s get over the things that we need in our system, assuming we already have Jmeter installed and running in our system, we’d also want the Jmeter Plugin manager installed. For that just go to the <a href="https://jmeter-plugins.org/wiki/PluginsManager/">link</a> and hit on the link text called JAR File which is highlighted in the screenshot down below</li></ol><figure><img alt="Getting the plugin manager’s JAR file" src="https://cdn-images-1.medium.com/max/1024/1*jBkcN71xMLcfvFSNWRK0Ag.png" /></figure><p>After the file has been downloaded move the file inside of the folder named “ext” in JMeter’s “lib” folder, for me the folder path looked like this</p><blockquote>C:\automation-tools\Performnace-test-tools\apache-jmeter-5.5\lib\ext</blockquote><p>Yours might be different based on how you’ve set up your folder structure.</p><p>To verify if the plugin manager is installed, navigate to the options menu tab and there you should be able to see the plugin manager as a list within the tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t_FqvtMFIJZn2RzfZfK4mg.png" /></figure><p>On selecting the plugin manager you should see a new JMeter dialog box titled Jmeter Plugin Manager.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nINNCY1zwSdtynfCTe31kg.png" /></figure><p>2. Now download a driver.exe file, the ChromeDriver.exe file and access its location path. To download the `chromedriver.exe` file, you need to follow these steps:</p><ul><li>Check Chrome Version: Before downloading `chromedriver.exe`, ensure you have the latest version of Google Chrome installed on your computer. You can find the version of Chrome by navigating to &quot;Settings&quot; &gt; &quot;About Chrome&quot; in the Chrome browser.</li><li>Find Compatible Chromedriver Version: Visit the official Chromedriver download <a href="https://sites.google.com/chromium.org/driver/downloads">page</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W53guVKS3FRvlP37sPwaeQ.png" /></figure><ul><li>Download Chromedriver: On the download page, you&#39;ll find a list of available versions of Chromedriver. Download the version that matches your installed Chrome browser&#39;s version. It&#39;s essential to select the correct version, as different Chrome versions require specific Chromedriver versions for compatibility.</li><li>Extract Chromedriver: After downloading `chromedriver.exe`, extract the executable file from the downloaded zip archive. Make sure to place the `chromedriver.exe` file in a location accessible by your testing framework or automation tool.</li></ul><p>3. Katalon Recorder: Add the Katalon recorder to your browser by following the <a href="https://chrome.google.com/webstore/detail/katalon-recorder-selenium/ljdobmomdgdljniojadhoplhkpialdid">link</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b15-O1gIGPuy1HE37GC4BQ.png" /></figure><p>This should add the Katalon recorder extension to your browser.</p><h3>The tackling (Steps to Follow):</h3><ol><li>Add the Selenium Web Driver Plugin: Now we gotta add the Selenium Webdriver plugin to our JMeter using the plugin manager. Click on the plugin manager, navigate to the new dailog box that opens</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fls4MrO_bYpaPwAzwMC0VA.png" /></figure><p>In the available plugins, search for Selenium/WebDriver Support and install it.</p><p>2. Test Plan and Thread group: Create a brand new test plan and add a Thread group to it with the configurations of your choice and requirements.</p><p>3. Config Element and Sampler:</p><ul><li>Right-click on the thread group</li><li>Click add&gt; Conflig element&gt; jp@gc — Chrome Driver Config</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hf3t-H2-2KwdYGqCQgPISA.png" /></figure><ul><li>Adding Web Driver Sampler: The most pivotal part begins, now instead of adding the HTTP Sampler, you gotta add the web driver sampler to the thread group for you to configure your web UI-based request. If you take a look at the sampler you’ll see that the script language is set to groovy, leave it be.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kTlozlaLQUw35Pb8japW1w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wkCVcgnjVhuG92bp4hxY2A.png" /></figure><p>4. Chrome Webdriver Setup: Remember the Chrome web driver that we downloaded previously, now copy its location path and set it within the Chrome driver config. Mind you that we have to provide the path along with the driver being listed in the path itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UuTCLBu7nG_NSMMImz6hjg.png" /></figure><p>5. Adding scripts: Click on the Katalon recorder in your browser. This should open the Katalon Recorder</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vlU1p3mMsrEW5dmrVRcM6g.png" /></figure><p>Add a test suite and a test case, now you could see the record button within the test cases, click on it and perform the actions that you need to perform (in my case it was hitting the URL of the platform, providing credentials and hitting the login button) after you’re done with the task that you want to perform hit the tiny stop recording button that appears on the bottom of the screen and you should have the test cases prepared.</p><p>Hit the export button to export your tests cases and see the magic</p><figure><img alt="Ignore the failed cases :D" src="https://cdn-images-1.medium.com/max/1024/1*T6NUazimj8AmI7L_r_IYtg.png" /></figure><p>As you hit Export the test cases would be transformed into scripts and now you’d end up seeing the automated test steps as so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eJUP1b1QIuNWlZ4Avw7_1Q.png" /></figure><p>In the “Select a Framework” dropdown, you’ll see a bunch of languages and the available test framework, you may choose whichever you know the best, for me it was Webdriver with JUnit.</p><p>Now, Copy all the code that is under the @test decorator and paste it into your Webdriver sampler</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9-h20rscMH2OSlQQGv3tFQ.png" /></figure><p>Now change the driver in the code with</p><blockquote>WDS. broswer</blockquote><p>And every time you access an element using CSS selector or Xpath add</p><blockquote>org.openqa.selenium.</blockquote><p>before the By.</p><p>After making the adjustments your code should look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oGjMGhpVlOdQDGMc3Gavpg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X6S_4x23HJMJIqbGx2JByQ.png" /></figure><p>Now you can add desired listeners and check the responses, add the HTTP samplers and make requests that shall depend upon the Response Body of the Web sampler to keep the session alive.</p><p>Unlocking the secret to flawless performance testing lies in how well you use the tool to utilize it best. Imagine a world where applications handle any user load, breeze through stress, and leave competitors in awe. JMeter’s prowess in simulating real-life scenarios reveals hidden bottlenecks and propels your app to the peak of efficiency.</p><p>Hope it helps.</p><p>Find me on <a href="https://www.linkedin.com/in/nitish-man-shrestha/">LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=560a7f9fabf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>