0

I am creating a .yml load scripting file for artillery tool and I am using the payload section which extracts the information from CSV files which is the data to log in to the system. But the problem is it doesn't take the provided information from csv.

I have used 'beforeRequest: "setJSONBody" ' and 'afterResponse: "logHeaders"' to track the information before request and after request , but request header is not showing the username and password taken from the csv.

Please refer below code which I have used to login to the system using credentials which are stored in the CSV file

=============================================================

config:   
    payload:
      # path is relative to the location of the test script
        path: "login_file.csv"
        field:
            - "username"
            - "password"
    target: '<<website name>>'
    plugins:
        expect: {}   
    phases:
        - duration: 1
          arrivalRate: 1
scenarios:
  - name : open url and login
    flow:
        - get:
            url: "/login"
        - post:
            url: "/login"    
            json:
                username: "{{username}}"
                password: "{{password}}"     
                beforeRequest: "setJSONBody"    
                afterResponse: "logHeaders"
            expect:
            - statusCode: 200
            - contentType: json               

==============================================================

I am expecting the output which shows me the credentials taken and 100 % scenarios run.

plese refer the attached image which is the result I get in which request header section is not showing the credentials taken form the csv

DEV QC
  • 21
  • 4

1 Answers1

0

You are missing an "s" on the end of fields value where you have selected what you want to extract from the payload file. (Should be fields instead of field)

dtoll
  • 1
  • 1