<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Samsul Islam</title>
    <description>The latest articles on Forem by Samsul Islam (@ranafge).</description>
    <link>https://forem.com/ranafge</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F450756%2F046c9799-abc9-4082-97d9-ead2fc7c55c6.jpeg</url>
      <title>Forem: Samsul Islam</title>
      <link>https://forem.com/ranafge</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ranafge"/>
    <language>en</language>
    <item>
      <title>Integrating Newman with Jenkins</title>
      <dc:creator>Samsul Islam</dc:creator>
      <pubDate>Fri, 27 Jan 2023 11:14:09 +0000</pubDate>
      <link>https://forem.com/ranafge/integrating-newman-with-jenkins-1368</link>
      <guid>https://forem.com/ranafge/integrating-newman-with-jenkins-1368</guid>
      <description>&lt;p&gt;I assumed that you all are familiar with postman and Jenkins. &lt;/p&gt;

&lt;p&gt;Newman is a command-line tool used to run collection of postman outside of postman. &lt;/p&gt;

&lt;p&gt;It enables to run and test a postman collection directly from the command line interface. It helps us to integrate with continuous integration (CI) servers and generate a nice looking report. &lt;/p&gt;

&lt;p&gt;Let's follow the steps to generate  postman collection report using Jenkins: &lt;/p&gt;

&lt;p&gt;Getting started &lt;/p&gt;

&lt;p&gt;To get started, First we have to install Node.js to run Newman on Jenkins. &lt;/p&gt;

&lt;p&gt;Install Node.js on Jenkins: &lt;/p&gt;

&lt;p&gt;Here I will show you how to install nodejs in Jenkins.  &lt;/p&gt;

&lt;p&gt;Before beginning here are prerequisites. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;Jenkins installed&lt;/code&gt; first.&lt;/p&gt;

&lt;p&gt;You have to installed Jenkins and login before preceding. &lt;/p&gt;

&lt;p&gt;Steps to follow &lt;/p&gt;

&lt;p&gt;After login in jenkins  click on new item or create a new Job. &lt;/p&gt;

&lt;p&gt;Enter an item name &lt;code&gt;Newman Report Gerantion&lt;/code&gt; and select &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Freestyle project &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnaj6847wwu6xa2w8xcqo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnaj6847wwu6xa2w8xcqo.png" alt="Image description" width="800" height="229"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter an item name in the input box ,select Freestyle project and then click on ok button. Here Freestyle project, You can run any type of build. &lt;/p&gt;

&lt;p&gt;Now we are going to Install nodejs to running Newman,&lt;/p&gt;

&lt;p&gt;From the dashboard  or follow the link &lt;a href="http://localhost:8080/" rel="noopener noreferrer"&gt;http://localhost:8080/&lt;/a&gt; &lt;br&gt;
` &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click on the project name or click on &lt;a href="http://localhost:8080/job/newman-project/configure" rel="noopener noreferrer"&gt;http://localhost:8080/job/newman-project/configure&lt;/a&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;2.In Build Environment check on the Provide Node &amp;amp; npm bin/ folder to PATH `&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fard6scw9ntnsu2rrbryn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fard6scw9ntnsu2rrbryn.png" alt="Image description" width="800" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;After that in build steps(next step) click on &lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Execute Windows batch command,&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk2pp6kop3d4mw3t5u7hn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk2pp6kop3d4mw3t5u7hn.png" alt="Image description" width="800" height="625"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After clicking on &lt;em&gt;Execute Windows batch command&lt;/em&gt; in the command box just put your command  like &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fko4qkpzjnfcray2uxdcy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fko4qkpzjnfcray2uxdcy.png" alt="Image description" width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;newman run &lt;a href="https://api.postman.com/collections/5543304-dfc8ba22-22b5-47a0-91d4-2c5d141167c0?access_key=PMAT-01GQRWA7GKRZ99KD5Y3TGZ7WMJ" rel="noopener noreferrer"&gt;https://api.postman.com/collections/5543304-dfc8ba22-22b5-47a0-91d4-2c5d141167c0?access_key=PMAT-01GQRWA7GKRZ99KD5Y3TGZ7WMJ&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;To get the postman api link please collect it from postman collection, see the image below &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ag98fgj6ojk8rucumzo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ag98fgj6ojk8rucumzo.png" alt="Image description" width="800" height="347"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the final step just click apply and save button. &lt;/p&gt;

&lt;p&gt;Now it's time to checking our newman project, it's work or not &lt;/p&gt;

&lt;p&gt;From dashboard, click on the &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;project name &amp;gt; click on Build Now&lt;br&gt;
. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;From the build number go to the console output , You will see the result  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe5e8n08s016ye7lsjs4l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe5e8n08s016ye7lsjs4l.png" alt="Image description" width="800" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Result(partial)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F136wkhu94qxm00fshus6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F136wkhu94qxm00fshus6.png" alt="Image description" width="800" height="461"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for your interest.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Cypress automation login with csrftoken</title>
      <dc:creator>Samsul Islam</dc:creator>
      <pubDate>Wed, 21 Dec 2022 14:30:12 +0000</pubDate>
      <link>https://forem.com/ranafge/cypress-automatin-login-with-csrftoken-h21</link>
      <guid>https://forem.com/ranafge/cypress-automatin-login-with-csrftoken-h21</guid>
      <description>&lt;p&gt;Here in this article, I am going to show you how to extract csrftoken from html body and use it in login form as payload.&lt;br&gt;
I assume you have installed &lt;a href="https://dev.tonodejs"&gt;https://nodejs.org/en/&lt;/a&gt; and create a cypress project &lt;a href="https://dev.tourl"&gt;https://www.cypress.io/&lt;/a&gt;.&lt;br&gt;
Open cypress project with this command.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;npx cypress open&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It will open a cypress window then click &lt;em&gt;E2E Testing&lt;/em&gt; button. After that click on the &lt;em&gt;Start E2E Testing&lt;/em&gt; with you browser and create &lt;em&gt;New empty spec&lt;/em&gt; file with a name like &lt;em&gt;loginWithCsrfToken.cy.js&lt;/em&gt; &lt;br&gt;
Add the below code in your &lt;em&gt;loginWithCsrfToken.cy.js&lt;/em&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nnWHuwBd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/04cjn2rmjc7bzojjouk3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nnWHuwBd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/04cjn2rmjc7bzojjouk3.png" alt="Image description" width="880" height="996"&gt;&lt;/a&gt;&lt;br&gt;
Let's short brief about my code, here &lt;em&gt;describe&lt;/em&gt; is collection of &lt;em&gt;it&lt;/em&gt; blocks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S7FC5jtt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2zurv69l8ygyjx7bnuuq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S7FC5jtt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2zurv69l8ygyjx7bnuuq.png" alt="Image description" width="880" height="557"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Here i wrote a custom command, you can write it in support folder. custom command takes a name and a parameter like &lt;em&gt;csrfToken&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Cypress.env&lt;/code&gt; read the item from the &lt;em&gt;cypress.config.js&lt;/em&gt; file where i have set env variable as object. like                 &lt;code&gt;env: {&lt;br&gt;
    baseUrl : "http://quotes.toscrape.com",&lt;br&gt;
    username: "ranafge",&lt;br&gt;
    password: "pass1478"&lt;br&gt;
  }&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;cy.request allow us to parse html and send http request.&lt;/p&gt;

&lt;p&gt;Now let's go to the second part the &lt;code&gt;it&lt;/code&gt; block &lt;br&gt;
&lt;code&gt;it('Parse from csrf token from HTML', function() {&lt;br&gt;
        cy.request('http://quotes.toscrape.com/login')&lt;br&gt;
        .its("body")&lt;br&gt;
        .then((body)=&amp;gt;{&lt;br&gt;
            const $html = Cypress.$(body)&lt;br&gt;
            const csrfToken = $html.find('form &amp;gt; input[type=hidden]:nth-child(1)').val();&lt;br&gt;
            console.log(csrfToken)&lt;br&gt;
            cy.loginWithCsrfToken(csrfToken)        .then((res)=&amp;gt;{&lt;br&gt;
                expect(res.status).to.eql(200)&lt;br&gt;
                expect(res.body).to.include('Logout')&lt;br&gt;
                cy.visit(Cypress.env('baseUrl'))&lt;br&gt;
            })          &lt;br&gt;
        })&lt;br&gt;
    })&lt;br&gt;
&lt;/code&gt;`&lt;br&gt;
Here &lt;em&gt;.its&lt;/em&gt; Get a property's value on the previously yielded subject as per documentation.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cypress.$&lt;/em&gt; is a jQuery function tha take a selector. After parsing the csrf token then just call the custom command with the name  _cy.loginWithCsrfToken(csrfToken) _ and pass a parameter csrfToken that extracted.&lt;/p&gt;

&lt;p&gt;This was the first article, I appoloze for my any mistake.&lt;/p&gt;

</description>
      <category>sqa</category>
      <category>cypress</category>
      <category>csrftoken</category>
      <category>javascript</category>
    </item>
    <item>
      <title>I can not go through the next pagination</title>
      <dc:creator>Samsul Islam</dc:creator>
      <pubDate>Sat, 05 Sep 2020 06:03:55 +0000</pubDate>
      <link>https://forem.com/ranafge/i-can-not-go-through-the-next-pagination-3390</link>
      <guid>https://forem.com/ranafge/i-can-not-go-through-the-next-pagination-3390</guid>
      <description>&lt;p&gt;Here today to complete a scrapy project but stack in pagination. I can not go through the next pagination. Please help, Here is my link&lt;/p&gt;

&lt;p&gt;&lt;a href="https://stackoverflow.com/a/63750650/4835122"&gt;https://stackoverflow.com/a/63750650/4835122&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
