Posts

Showing posts from October, 2016

How To Automate Rest API in Postman

Image
How To Automate Rest API  in Postman  1.  Let us take an example in which we need to create shipment  Step 1 : login via username /password and then getting the access token in response . [ Login API ] Step 2 : Creating the shipment each time with unique AWB no . [ automating AWB no in request ] and passing the access token in header generated via Step 1.   login API POST Request http://XXX/oauth/token?grant_type=password&client_id=my-trusted-client&username=user1&password=pass1 Header Content-Type : Application/json Response {   "access_token": "eyJhbGciOiJIUzI1NiJ9.eyJleHBpcmF0aW9uIjoxNDc3MzE1NjMyMjc1LCJpc3N1ZWRBdCI6MTQ3NzMwNTYzMjI3NSwiaXNzdWVyIjoiT2xwQXV0aCIsInR5cGUiOiJhY2Nlc3NfdG9rZW4iLCJpc3N1ZWRGb3IiOiJha3NoYXkuYWdhcndhbEB1bmljb21tZXJjZS5jb20iLCJvdGhlckNsYWltcyI6e319.EmWoYEOXRjlloZlfM9ggHftxmnlowzPxFI9gPOAOnBk",   "token_type": "bearer",   "refresh_token": "eyJhbGciOiJIUzI1NiJ9.eyJleHBpc

Stimulate 2G, 3G , 4G network speed on Jmeter

How To stimulate different networks (2G, 3G ,4G, wifi , ethernet ) on Jmeter Jmeter gives you the option to stimulate different network speeds (2G, 3G ,4G ,wifi , Ethernet) based on your requirement . 1. Open bin folder of jmeter and search for user.properties file 2. Add the below code to your user.properties file    #Default    httpclient.socket.http.cps=0    httpclient.socket.https.cps=0    #2G network     httpclient.socket.http.cps=21888    httpclient.socket.https.cps=21888    #EDGE network     httpclient.socket.http.cps=  49152    httpclient.socket.https.cps=  49152    #3G network     httpclient.socket.http.cps=  256000    httpclient.socket.https.cps=  256000    #4G network     httpclient.socket.http.cps=21888    httpclient.socket.https.cps=21888      3.  Restart  jmeter By default its value is set to zero which means it can allow maximum traffic and with no limitation. Here’s the formula of calculating “cps”:

ADD EMPTY HEADER IN JMETER SAMPLE REQUEST

Image
ADD EMPTY HEADER IN J-METER SAMPLE REQUEST            In Jmeter Test Plan if you have multiple Request Sampler with globally defined HTTP Request Header and in one Request Tester does not want to use globally defined HTTP Request Header and want to edit/delete the Header with new header value.       Solution : - Add Bean Shell Preprocessor to that request and write the following code . import org.apache.jmeter.protocol.http.control.Header; sampler.getHeaderManager().remove(1); In Below Test Plan HTTP Request Header cointains 2 headers values -> Content-Type – Application/json Authorization – ${access_token} In Request OauthToken1,  I want to use header value as Content-type – text/xml and want to remove Authorization value . Add Bean shell preprocessor to OauthToken 1 . with above-defined code . Result :- In OauthToken1 Request , header values is passed as Content-type – text/xml with no authorization .