POSTMAN BEGINNER TUTORIAL 7 💡 How to set and get VARIABLES through SCRIPTING

  Рет қаралды 276,457

Automation Step by Step

Automation Step by Step

6 жыл бұрын

Free Tutorials - automationstepbystep.com/
Hi, I am Raghav and Today we will learn:
1. How to get variables through scripts
2. How to set variables through scripts
//pm.variables.get();
//pm.variables.set();
//pm.globals.get();
//pm.globals.set();
//pm.environment.get();
//pm.environment.set();
________________________________________________________________
POSTMAN Beginner Tutorials - • POSTMAN BEGINNER TUTOR...
Playlists - / @raghavpal
________________________________________________________________
Do like, share and subscribe
Keep Learning,
Raghav
_______ ONLINE COURSES TO LEARN _______
automationstepbystep.com/
----------- UI TESTING -----------
Selenium Beginners - bit.ly/2MGRS8K
Selenium Java Framework from Scratch - bit.ly/2N9xvR6
Selenium Python - bit.ly/2oyMp5x
Selenium Tips - bit.ly/2owxc50
Selenium Builder - bit.ly/2MKNtlq
Katalon Studio - bit.ly/2wARFdi
Robot Framework - bit.ly/2Px6Ue9
----------- API TESTING -----------
Web Services (API) - bit.ly/2MGafL7
SoapUI - bit.ly/2MGahmd
Postman - bit.ly/2wz8LrW
General - bit.ly/2PYdwmV
----------- MOBILE TESTING -----------
Mobile Playlist - bit.ly/2PxpeUv
----------- CI | CD | DEVOPS -----------
Jenkins Beginner - bit.ly/2MIn8EC
Jenkins Tips & Trick - bit.ly/2LRt6xC
Docker - bit.ly/2MInnzx
----------- VERSION CONTROL SYSTEM -----------
Git & GitHub - bit.ly/2Q1pagY
----------- PERFORMANCE TESTING -----------
JMeter Beginner - bit.ly/2oBbtIU
JMeter Intermediate - bit.ly/2oziNVB
JMeter Advanced - bit.ly/2Q22Y6a
JMeter Tips & Tricks - bit.ly/2NOfWD2
Performance Testing - bit.ly/2wEXbLS
----------- JAVA -----------
Java Beginners - bit.ly/2PVUcXs
Java Tips & Tricks - bit.ly/2CdcDnJ
----------- MAVEN -----------
Maven - bit.ly/2NJdDRS
----------- OTHERS -----------
Redis- bit.ly/2N9jyCG
Misc - bit.ly/2Q2q5xQ
Tools & Tips - bit.ly/2oBfwoR
QnA Friday- bit.ly/2NgwGpw
Sunday Special - bit.ly/2wB23BO
Ask Raghav - bit.ly/2CoJGWf
Interviews - bit.ly/2NIPPxk
All Playlists - bit.ly/2LSiezA
Keep Learning,
Raghav
Website - automationstepbystep.com/
LifeCharger - lifecharger.org/
Udemy Courses - www.udemy.com/user/raghav-pal-3/
Facebook - / automationstepbystep
Twitter - / automationsbs
KZfaq - / automationstepbystep

Пікірлер: 255
@RaghavPal
@RaghavPal 5 жыл бұрын
Online courses - automationstepbystep.com/
@nandinigami7511
@nandinigami7511 Жыл бұрын
I've been watching this playlist from the beginning & i love how easy it is to follow you. thank you! I appreciate it! :)
@RaghavPal
@RaghavPal Жыл бұрын
Thanks Nandini
@faizalahamed3396
@faizalahamed3396 3 жыл бұрын
Thanks Raghav, the way you are creating sessions are really inspiring and helpful... really appreciated and give your best!! always
@RaghavPal
@RaghavPal 3 жыл бұрын
Thanks Faizal
@Cmart6444
@Cmart6444 6 жыл бұрын
Thanks Raghav, your videos are unvaluable for me, I really, really, really appretiate them. God bless you with more health, wisdom and generosity! AMEN!
@RaghavPal
@RaghavPal 6 жыл бұрын
Thanks for watching and letting me know.
@leonardohernandez9804
@leonardohernandez9804 6 жыл бұрын
Your videos are clear and easy to undestand! Gracias !
@JDKnider
@JDKnider 6 жыл бұрын
This is really nice work! Very useful, clear and easy to follow!
@RaghavPal
@RaghavPal 6 жыл бұрын
Thanks for your message JD
@hexatorus5452
@hexatorus5452 8 ай бұрын
Extremely helpful series!
@RaghavPal
@RaghavPal 8 ай бұрын
Glad it was helpful Hexa
@hindustani7566
@hindustani7566 3 ай бұрын
The way he covers basics, tackling Advance level becomes so easy
@RaghavPal
@RaghavPal 3 ай бұрын
Glad to know this is helping
@harisahmed4269
@harisahmed4269 3 жыл бұрын
Thank you Sir! Much appreciated.
@RaghavPal
@RaghavPal 3 жыл бұрын
most welcome Haris
@kiranjape3941
@kiranjape3941 4 жыл бұрын
Thanks for this valuable session.
@RaghavPal
@RaghavPal 4 жыл бұрын
Most welcome Kiran
@TheSnehal23
@TheSnehal23 3 жыл бұрын
Thank You so much sir for making this series
@RaghavPal
@RaghavPal 3 жыл бұрын
Most welcome Snehal
@umairaslam466
@umairaslam466 6 жыл бұрын
awesome chain of lectures (Y)
@RaghavPal
@RaghavPal 6 жыл бұрын
Thanks for watching Umair
@usmansaid4306
@usmansaid4306 2 жыл бұрын
Very Awesome way of Teaching. && Environment, I also spell it in the way you spelled.
@RaghavPal
@RaghavPal 2 жыл бұрын
Thank you Usman
@priyankapandey6098
@priyankapandey6098 4 жыл бұрын
Thanks for the tutorial.
@RaghavPal
@RaghavPal 4 жыл бұрын
You're welcome Priyanka
@md.mahfuzulhuqtalukder6644
@md.mahfuzulhuqtalukder6644 4 жыл бұрын
You are the best.
@RaghavPal
@RaghavPal 4 жыл бұрын
Humbled to see your message Mahfuzul
@pcginfo7270
@pcginfo7270 5 жыл бұрын
Hi Raghav, I am really a fan of your video and love the face that how you go step by step to show ( i.e. how certain actions) just one request if you could please go on a little more slower pace so that its easier to follow along ...thanks a lot for all the effort you put into these videos.
@RaghavPal
@RaghavPal 5 жыл бұрын
Thanks for your message. I will take a note of this.
@washingtonmugo2253
@washingtonmugo2253 2 жыл бұрын
this was such a bliss
@RaghavPal
@RaghavPal 2 жыл бұрын
Thanks
@lts8683
@lts8683 2 жыл бұрын
Thanks Raghav
@RaghavPal
@RaghavPal 2 жыл бұрын
most welcome
@johng5295
@johng5295 4 жыл бұрын
Thanks in a million.
@RaghavPal
@RaghavPal 4 жыл бұрын
You're welcome John
@greatadmire4730
@greatadmire4730 4 жыл бұрын
Hi Raghav, Thank you for your help. I have one question. I have set the Global variable value in the script. In the quick look, it shows the updated variable value. I am facing a "Reference error: variable not defined" error when trying to print in the console log. this is my script pm.globals.set("name1", "tony"); let globalVar= pm.globals.get(name1); console.log("changed value: "+globalVar); Please, can you help me? Thanks
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi, just ensure that you have saved after setting global variable.
@toy2413
@toy2413 4 жыл бұрын
Hi, Raghav One question.. I have multiple GET requests in one folder and some of the GET requests have pre-request scripts and test scripts. Now, the question is, when I run only one GET request and open console at the same time, I see that all the pre-request scripts of all GET requests ran and test scripts of all GET requests as well. How do I run an individual request without other GET requests tagging along?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Yogini, I believe you have added the pre-request scripts and test scripts at the folder level. Add them at the individual request level
@bankuruvasavilatha5092
@bankuruvasavilatha5092 5 жыл бұрын
Voice is clear and good communication 👍😊👍
@RaghavPal
@RaghavPal 5 жыл бұрын
Thanks Bankuru
@bankuruvasavilatha5092
@bankuruvasavilatha5092 5 жыл бұрын
Good explanation
@Forex_trader_in
@Forex_trader_in 6 жыл бұрын
Clear and helpful, please let me know how to split the screen.. Thanks
@RaghavPal
@RaghavPal 6 жыл бұрын
on windows press windows button + right or left arrow, One screen will be split and then in other section you can select the other screen. To undo you can select maximize button
@mohitgupta3201
@mohitgupta3201 2 жыл бұрын
Thanks Raghav for making things easy for us..just a minor correction i noticed Raghav needs to be printed in response you need to use Name in upper case starting letter.
@RaghavPal
@RaghavPal 2 жыл бұрын
I will check Mohit
@aayushnehra9813
@aayushnehra9813 4 жыл бұрын
Hi, when we set vairables where are the variables stored? I tried to look for them in the collection and in the global scope. I was unable to find it.
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Aayush, Variables can be created at the following locations Global Collection Environment Data Local Can find more here - kzfaq.info/get/bejne/a8d9pNyJv7jaqJs.html
@JaNaMSoNi
@JaNaMSoNi 6 жыл бұрын
Whatever. Command you have written are just only for postman ? Or any specific programming language command?
@RaghavPal
@RaghavPal 6 жыл бұрын
these commands starting with pm are for postman.
@fredericklane745
@fredericklane745 4 жыл бұрын
Am enjoying the tutorials thanks. Maybe at the beginning of each one, put the reason why we use these features? e.g Why do we want to test and add "Hello World" in the text editor? For example, if I'm in Salesforce and importing fields from this file, why would I add extra text?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Frederick, sure I will take note of this
@HK-os8tj
@HK-os8tj 5 жыл бұрын
Hi Raghav, thanks for the amazing tutorial. Whats the best way to learn Java script? Do you have tutorial for this? How good we need to be at coding to use Postman effectively?
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi H K, you should be knowing the basics. As of now no, but I will be creating soon. For now you can get online help.
@aravapallimanikanta1378
@aravapallimanikanta1378 6 жыл бұрын
What is the use of pre request scripts & when we are going to use them??? Can you explain with some examples??
@RaghavPal
@RaghavPal 6 жыл бұрын
Hi, Pre-request script, as the name suggest will get executed before running the request or before the request hits the server. So it can by used to provide any dynamic values in the request headers/body etc. And anything you want to do programmatically before running the request.
@aravapallimanikanta1378
@aravapallimanikanta1378 6 жыл бұрын
Do these scripts will affect the API response/performance while we run it (or) It will execute irrespective of the API? -Thanks!!
@RaghavPal
@RaghavPal 6 жыл бұрын
These should not impact the api performance (response time)
@gauravdalvi9288
@gauravdalvi9288 5 жыл бұрын
Thank you for video. can you please specify which language we use in PM scripting ?
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Gaurav, its JavaScript
@shwethabj6539
@shwethabj6539 3 жыл бұрын
Hi Raghav, If I have 2 global verible with same name and same value, which one will script use while executing
@RaghavPal
@RaghavPal 3 жыл бұрын
Hi Shwetha, ideally this should not be allowed, but I know you can create global variables with same name. When you refer the variable created last will be referred. Now logically speaking, if you have the variable with same name & value, when you call or refer the variable, it will anyways not matter which variable is getting called as you will get the same value,
@amityeh
@amityeh 4 жыл бұрын
Hi, Is it possible to set a global variable by a value obtained in the result (the result is inJSON format)?
@RaghavPal
@RaghavPal 4 жыл бұрын
Yes, you can Amit, Check this - kzfaq.info/get/bejne/fq5xhseeqLiVknk.html
@stevenclark1973
@stevenclark1973 4 жыл бұрын
Hi, brilliant videos thankyou. You set name variable using pm.variables.set but name was a global variable? I'm getting errors and wondering if it is because I'm trying to set it at script level when name is not defined at script level. Should it be pm.globals.set in your video? I'm not sure how this worked for you without errors?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Steve, Here is the script for setting variables - Global - pm.globals.set() - pm.globals.get() - Env - pm.environment.set() - pm.environment.get() - Step/Request - pm.variables.set - pm.variables.get
@JiminPark-ld2xx
@JiminPark-ld2xx 3 жыл бұрын
Can you do more videos on this and parameter settings on Postman? Thank You. So far it helped me a lot.
@RaghavPal
@RaghavPal 3 жыл бұрын
Hi Jimin, I will do, Can check more here - automationstepbystep.com/
@JiminPark-ld2xx
@JiminPark-ld2xx 3 жыл бұрын
@@RaghavPal Thanks
@elijahshackelford3746
@elijahshackelford3746 5 жыл бұрын
Hi Raghav- Quick question: How would I take the response to one query to be used as the input of the next API query?
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Elijah, You can check it here for XML - kzfaq.info/get/bejne/oL6SmpiAqpfZqXk.html for JSON - kzfaq.info/get/bejne/b6x4ia6Srtmck4U.html
@kavivenky6216
@kavivenky6216 4 жыл бұрын
@@RaghavPal this says that "the video is private ":(
@DhrumilSoni812
@DhrumilSoni812 4 жыл бұрын
Hi, I'm getting ERROR while printing log for the Global Environment variable. TypeError: Cannot read property 'get' of undefined let a = console.log(pm.gloabls.get("Env")); console.log(a); Can you please help here? I've tried to find it on web but not giving satisfactory answer.
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Dhrumil, Most probably the variables is not getting referenced. Check that you have saved the project and try again. Also check the spelling etc, there should be no trailing spaces. You can also debug as shown here - kzfaq.info/get/bejne/pMthhdaKyM3Pg40.html
@DhrumilSoni812
@DhrumilSoni812 4 жыл бұрын
@@RaghavPal Hi Thanks for replying back. Something Interesting: If you defined Global variable and trying to run with suppose "QA" Environment and trying to print global variable then I'm facing such issue. I'm suspecting Environment issue with defined Global environment variables. But If I'm selecting "No Env" then it works properly. Do you think this is a potential problem/Issue?
@RaghavPal
@RaghavPal 4 жыл бұрын
May be, will need to confirm
@suvromukherjee4198
@suvromukherjee4198 2 жыл бұрын
Hi Raghav, I have set collection variable and user {{url}} in the endpoint but I am getting 'getaddrinfo enotfound' error while sending the request. Could you plz help me on that.
@RaghavPal
@RaghavPal 2 жыл бұрын
HI Suvro, pls check if the {{url}} is getting resolved. You can check this using postman console - kzfaq.info/get/bejne/pMthhdaKyM3Pg40.html Also check this discussion - community.postman.com/t/postman-monitor-error-getaddrinfo-enotfound/3149/12
@rajeshd579
@rajeshd579 4 жыл бұрын
Hi Raghav, Thanks for this video and i don't understand how to run the test after coding what is the command to run the code? Please reply.
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Rajesh, You can run the collection using collection runner
@Eboo
@Eboo 5 жыл бұрын
pm is not defined is the error I am getting. Am i supposed to define it earlier on before attempting to write the code?
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Mutele, by any chance are you using the chrome extension of Postman. Also check this - stackoverflow.com/questions/46243745/postman-scripts-pm-is-not-defined
@gokulrao8984
@gokulrao8984 4 жыл бұрын
Hi Raghav just curious to know if this is beginner tutorial do u have anything like an intermediate and expert video also for postman. Just asking as i already checked jmeter series of videos (Beginner-Intermediate-Expert)
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Gokul, as of now for Postman this is the only series, I will make another soon. You can check all here - automationstepbystep.com/online-courses/
@hemanthgowda5930
@hemanthgowda5930 4 жыл бұрын
Hi ragav, For this test scripting which you used is ? And which one we need to learn for these scripting.. and for automation.kindly let us know. -Does this set property updates the variable value to the collection level?? Or only within the no of test it updates? Thanks in advance
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Hemanth, it is JavaScript. You can get all information on this in this video - kzfaq.info/get/bejne/bLmqjMumu7-ceps.html
@sindiyarajan3440
@sindiyarajan3440 4 жыл бұрын
Hello Raghav. Thank you so much for such great videos. Could you please tell me how and where do we use the local variables 'set' in the script?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Sindiya, Getting & Setting variables through scripts - Global - pm.globals.set() - pm.globals.get() - Env - pm.environment.set() - pm.environment.get() learning.getpostman.com/docs/postman/environments_and_globals/intro_to_environments_and_globals/ pm.variables is for local variables for e.g. pm.variables.set("variable_key", "variable_value"); Local variables are temporary values you set in your request scripts. Also //access a variable at any scope including local pm.variables.get("variable_key"); //access a global variable pm.globals.get("variable_key"); //access a collection variable pm.collectionVariables.get("variable_key"); //access an environment variable pm.environment.get("variable_key");
@praneethgandra9630
@praneethgandra9630 4 жыл бұрын
@@RaghavPal Thanks Raghav
@maheshjakka7371
@maheshjakka7371 2 жыл бұрын
HI Raghav. I am trying to set variable value in collection: pm.variables.set("resource", "maps"); console.log(pm.variables.get("resource")); In Postman console, I am getting maps but i am opening collection then Variables but i am not getting variable with value. please suggest me
@RaghavPal
@RaghavPal 2 жыл бұрын
Hi Mahesh, if you are setting during execution (at runtime) the value will be available duing the runtime session only
@pblintso
@pblintso 4 жыл бұрын
Hello Raghav. In the video, at 1:49, in the console, Hello World... is printed without quotes. However, for me, it printed in the console with quotes, as "Hello World." Am I doing something wrong here? Also, is the code in the Tests tab JSON or JS? Also, in pm.variables.get or set, does pm stand for postman?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Polina, what is your script. Pls show me. Yes pm is for postman
@pblintso
@pblintso 4 жыл бұрын
@@RaghavPal console.log("Hello World..."); let varURL = pm.variables.get("url"); let varURL2 = pm.variables.get("url2"); console.log("Value of varURL is " + varURL); console.log("Value of varURL2 is " + varURL2); pm.variables.set("name", "POSTMAN"); console.log(pm.variables.get("name")); let glo_var = pm.globals.get("globalVar"); console.log(glo_var); pm.environment.set("env_var", "environment_variable"); console.log(pm.variables.get("env_var"));
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Polina this looks fine to me. May be some console updates. For now continue with rest of the tutorials. Will let you know if I find something
@thirstyhammad
@thirstyhammad 4 жыл бұрын
Hi Raghav, how to update environment variable value from body variables? for e.g: I am hitting update my profile API in which I am updating my name in body, and in response body, it's only showing me a message "Updated profile successfully".
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Hammad, you will need to capture and store the value and update in the variable. Now have to find where exactly you can extract value from
@user-rt3lt4tw7p
@user-rt3lt4tw7p Жыл бұрын
hello Raghav, help me what i have to do in the skill check where they are asking me to set a variable for favorite actor and his name through test?
@RaghavPal
@RaghavPal Жыл бұрын
Hi Priyanka To set the value for an API request parameter through a test script in Postman, you can follow these steps: 1. Create a new Postman collection. 2. In the collection, create a new request. 3. In the request, set the parameter that you want to set the value for. 4. Create a new test script for the request. 5. In the test script, set the value of the parameter. 6. Save the collection and the test script. Here is an example of a test script that sets the value of the name parameter to Robert Downey Jr.: Code snippet function testSetParam() { var request = this.request; request.url = request.url + "?name=" + "Robert Downey Jr."; } This test script will set the value of the name parameter to Robert Downey Jr.. To run the test script, you can right-click on the request and select "Run". Here are some additional things to keep in mind: * The test script will be run when the request is sent. * The test script will be run in the context of the request. * The test script can access the request object. I hope this helps
@user-rt3lt4tw7p
@user-rt3lt4tw7p Жыл бұрын
@@RaghavPal thank you so much for responding me..:)
@rickmedlin5389
@rickmedlin5389 3 жыл бұрын
When I print out my variables, they have quote marks around them in the log, whereas yours do not. Is there some setting to change that?
@RaghavPal
@RaghavPal 3 жыл бұрын
Hi Rick, check this community.postman.com/t/how-to-escape-double-quote-when-setting-using-variables/13505
@saiphanideep6788
@saiphanideep6788 4 жыл бұрын
hi bro.....TypeError: Cannot read property 'get' of undefined this error is coming what to do
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Sai, Try to print where you are trying to do a get. May be the variables is empty.
@prachimuddapur
@prachimuddapur 4 жыл бұрын
Hi Raghav, slightly confused between how an environment variable differs from global variable?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Prachi, The diff is as follows: 1. Scope- Environment variables can be accessed with the corresponding environments. Global variables can be accessed broadly regardless of the selected environment. 2. Priority : priority is as follows: - local - data - environment - collection - global So in case a global variables shares same name with an environment variables, at runtime value will be referenced from env variable 3. Getting & Setting variables through scripts - Global - pm.globals.set() - pm.globals.get() - Env - pm.environment.set() - pm.environment.get() learning.getpostman.com/docs/postman/environments_and_globals/intro_to_environments_and_globals/ pm.variables is for local variables for e.g. pm.variables.set("variable_key", "variable_value"); Local variables are temporary values you set in your request scripts. Also //access a variable at any scope including local pm.variables.get("variable_key"); //access a global variable pm.globals.get("variable_key"); //access a collection variable pm.collectionVariables.get("variable_key"); //access an environment variable pm.environment.get("variable_key");
@lowrencek3592
@lowrencek3592 4 жыл бұрын
Raghav, the autocomplete is set correctly in Settings, Still I dont get the autocomplete. Pls suggest.
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Lawrence, pls try to restart Postman and check
@feliks_magnificentbrowniez
@feliks_magnificentbrowniez 3 жыл бұрын
Can you let me know the code to sum two variables which were stored as Value1 and Value2 in test section of GET request as I would want to pass on the Sum value on to POST request. Cheers.
@RaghavPal
@RaghavPal 3 жыл бұрын
Hi Subhash, in general we get the values extracted from response and store them in variables and then you can use these variables in next request and do the calculations as needed, can check some examples online
@juergenschubert3247
@juergenschubert3247 4 жыл бұрын
great video. Thumbs up !!! do you also have an explanation on how it looks like when I let say do get an auth token back from login and wanna have thisvalue of the auth token set to an env variable, so I can use it.
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Juergen, this may help you - kzfaq.info/get/bejne/fq5xhseeqLiVknk.html
@kiranbastwad8178
@kiranbastwad8178 4 жыл бұрын
Hi Raghav, What is difference between scripting in Test level and scripting in pre request level
@RaghavPal
@RaghavPal 4 жыл бұрын
Scripts in Pre-request sections gets executed before running the api request, Tests section is executed after we receive the response.
@alokkumar4485
@alokkumar4485 4 жыл бұрын
what is the difference between pm.variables and pm.globals. where the variable is set when executing pm.variables?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Alok, pm.variables is for local variables for e.g. pm.variables.set("variable_key", "variable_value"); Local variables are temporary values you set in your request scripts. Also //access a variable at any scope including local pm.variables.get("variable_key"); //access a global variable pm.globals.get("variable_key"); //access a collection variable pm.collectionVariables.get("variable_key"); //access an environment variable pm.environment.get("variable_key");
@NaveenSharma069
@NaveenSharma069 5 жыл бұрын
I defined an environment variable as url and able to fetch its value using the command - : let urlVar=pm.variables.get("url"); So it seems that without using the pm.environment.get("variablename") I can get the value. Please correct me if my understanding is wrong.
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Naveen, I will re-check this, Pls check do you have any local or collection variable with same name
@NaveenSharma069
@NaveenSharma069 5 жыл бұрын
@@RaghavPal thanks Raghav. I did not setup any local variable with such name.
@RaghavPal
@RaghavPal 5 жыл бұрын
Okay, that means pm.variables.get("variableName") command works for env variable as well. I will also check the same. You can continue with other videos.
@sharanarani6800
@sharanarani6800 5 жыл бұрын
Hi Raghav I have a doubt in running collections, I have headers and parameters for all the request I am sending and it is same for all How can I set Universal parameter and Headers for all the API I run?
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Sharana, pls see if this is something you want github.com/postmanlabs/postman-app-support/issues/1947 community.getpostman.com/t/setting-headers-for-entire-collection-folder/708/7
@renujoshi3935
@renujoshi3935 3 жыл бұрын
Can you explain let urlVar portion please? If the variables are stored in urlVar can you tell me the location where it is stored? Also why did you add a + in the console.log(); line.
@RaghavPal
@RaghavPal 3 жыл бұрын
Hi Renu, let me first inform on +, it is used for concatenation that is joining, so on the console we can see the complete information. On variables, this will help Priority : priority is as follows: - local - data - environment - collection - global - Global - pm.globals.set() - pm.globals.get() - Env - pm.environment.set() - pm.environment.get() pm.variables is for local variables for e.g. pm.variables.set("variable_key", "variable_value"); Local variables are temporary values you set in your request scripts. Also //access a variable at any scope including local pm.variables.get("variable_key"); //access a global variable pm.globals.get("variable_key"); //access a collection variable pm.collectionVariables.get("variable_key"); //access an environment variable pm.environment.get("variable_key");
@Garisons
@Garisons 5 жыл бұрын
Hi Raghav, The get and set works well, but I am having an error with Let. It gives me a red cross. Missing ";" before the statement
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Jean, will need more info/logs on this to troubleshoot
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Jean, will need more details/logs to troubleshoot
@kimberley4883
@kimberley4883 5 жыл бұрын
Hi Jean! I received the same error and realized the "L" should be lowercase and not capital. When I changed Let to let I was able to successfully send the API request. Hopes this helps as I am a novice at this. I am learning a lot from Raghav's videos. Thanks Raghav!
@pging8328
@pging8328 4 жыл бұрын
Thx for the tutorials. Is the scripting language JavaScript?
@RaghavPal
@RaghavPal 4 жыл бұрын
Yes
@kamalpreetkaur8247
@kamalpreetkaur8247 4 жыл бұрын
When a tutorial is for beginner, plz explain code you are writing. How can a beginner know what is pm.variable.get
@RaghavPal
@RaghavPal 4 жыл бұрын
Thanks for the feedback Kamal. I will take are of this. For now if you require there is a separate tutorial on JavaScript automationstepbystep.com/
@sviatkey
@sviatkey 5 жыл бұрын
Please clarify: what means/does "Pre-request scripts" tab? How it helps us in a case when we have "Tests" tab for that?
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Sviatoslav, Pre-request scripts will run before the test and tests scripts run after the test execution. So you can see it like in case you need to do any setup before running the test you can put those scripts in pre-request scripts
@sviatkey
@sviatkey 5 жыл бұрын
@@RaghavPal Hi Raghav. Thanks for the update. Could you please give an example of such case? I am trying to figure out how I would manage that and what would be the purpose. Thanks.
@RaghavPal
@RaghavPal 5 жыл бұрын
I believe I covered this in a video in the playlist. Pls check
@mohanish3169
@mohanish3169 2 жыл бұрын
Hey Raghav, I have been following your tutorials and its been easy so far except for 2:35 I didn't quite understand why we used LET command, if you can please shed some light. Thank you.
@RaghavPal
@RaghavPal 2 жыл бұрын
let is a keyword to declare variables in JavaScript Older way is var, both can work
@omkarkhatavkar3650
@omkarkhatavkar3650 4 жыл бұрын
when u set the global and environment variable , the current value gets changed which you can see by clicking on eye symbol . The initial value remains the same.
@RaghavPal
@RaghavPal 4 жыл бұрын
Yes, the current value is what will be referred in the test request. The initial value is what gets shared with the team, when you share your collection
@nsaiprasad8462
@nsaiprasad8462 4 жыл бұрын
i am getting this error "TypeError: Cannot read property 'get' of undefined" why?
@RaghavPal
@RaghavPal 4 жыл бұрын
I see your other comment and looks like you found the solution. Pls put it here to help others
@bharathchinni6168
@bharathchinni6168 5 жыл бұрын
What are different Scripting languages that we can use Postman? I think u write scripts using JavaScript right?
@RaghavPal
@RaghavPal 5 жыл бұрын
That's right Bharath
@accountingmarketjd275
@accountingmarketjd275 4 жыл бұрын
Rag - I'm getting a "Syntax error: unexpected identifier" error here and I'm not seeing what it is. Can you help? console.log("Hello World..."); Let urlVar = pm.variables.get("url"); console.log ("Value for url variable is:" +urlVar);
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi, can you check if l should be lower case in let. It should also be mentioned in the detailed logs
@accountingmarketjd275
@accountingmarketjd275 4 жыл бұрын
@@RaghavPal My apologies. I think the font made it look like a capitalized L but it was indeed a lower-case. Thx
@debanjandas4957
@debanjandas4957 4 жыл бұрын
What does pm in pm.variables.get stand here?
@RaghavPal
@RaghavPal 4 жыл бұрын
PostMan
@DucNguyen-xn5bd
@DucNguyen-xn5bd 5 жыл бұрын
missing subtitle for this video. However, thank you so much for your helpful video
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Duc, yes it's not automatically generated. Thanks for watching.
@mathewjohn9092
@mathewjohn9092 5 жыл бұрын
Can you pls share the link of your video Postman Beginner Tutorial- API chaining
@RaghavPal
@RaghavPal 5 жыл бұрын
Pls find video 18 here - kzfaq.info/sun/PLhW3qG5bs-L-oT0GenwPLcJAPD_SiFK3C
@JudyMendes
@JudyMendes 4 жыл бұрын
Hi Raghav, what is the scope of the different variables defined at the Collection, global and environment level.
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Judy, 1. Scope- Environment variables can be accessed with the corresponding environments. Global variables can be accessed broadly regardless of the selected environment. 2. Priority : priority is as follows: - local - data - environment - collection - global So in case a global variables shares same name with an environment variables, at runtime value will be referenced from env variable 3. Getting & Setting variables through scripts - Global - pm.globals.set() - pm.globals.get() - Env - pm.environment.set() - pm.environment.get() learning.getpostman.com/docs/postman/environments_and_globals/intro_to_environments_and_globals/
@JudyMendes
@JudyMendes 4 жыл бұрын
@@RaghavPal Thanks Raghav for your reply. All of your tutorials have been of great help and blessing to me. I do have one more question on the Priority, what do you mean data variable. is the data got from a data file?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Judy, that's right, see this - learning.getpostman.com/docs/postman/environments_and_globals/variables/#data-variables
@hudakhaled8353
@hudakhaled8353 5 жыл бұрын
Thank you for the video Could you please give a real example for the purpose of using global and collection variables? what is the actual purpose of setting and getting variables... and I don't understand when we should use the get and set whether at collection or global level. Thank you
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Huda, we can use variables whenever there are places where we need to use dynamic data i.e. data can change based on scenarios. Now if the data needs to be changed at a global level we can use global variables
@rajuboine
@rajuboine 3 жыл бұрын
When trying to create an Environment variable from the script, I am seeing an error as "newEnvVar is not defined".
@RaghavPal
@RaghavPal 3 жыл бұрын
Hi Yashvi, after creating a env variable Save and then try
@fachrizalmasugi8703
@fachrizalmasugi8703 3 жыл бұрын
sir i wnna ask, how we make sure we have a correct data-type from API the datas like: ID -> Integer name-> String ty if u notice this.
@RaghavPal
@RaghavPal 3 жыл бұрын
Hi Fachrizal, you can use *typeof()* function. This will help you stackoverflow.com/questions/48776821/postman-how-to-check-the-data-type-of-each-value-in-a-response stackoverflow.com/questions/42973515/how-to-check-the-field-data-type-only-using-postman/42992446 community.postman.com/t/check-datatype-of-a-response-body/13804
@akalyamohan2023
@akalyamohan2023 4 жыл бұрын
Hi Rahul, I have 2 doubts, 1) Do we need to know JavaScript for Postman Automation Testing? If Yes, Basic javascript like that we use (java for selenium) or we need to know in depth of java script? Do Postman Rest API has lots of coding? 2) my friend got interview to test API like, They given the website and they going to add a editor to their existing website. So they asked to do Rest API Testing. I dont understand the clear picture of her interview. She has 0 knowledge when she got interview.so we couldn't discuss about more. What will be the overall picture. any idea?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Akalya, 1) Basic knowledge of JS will be good for starting. You should be ready to learn more if required. 2) APIs work at the backend of your UI. So when you send some request by clicking something on the UI, its an API request at the backend that goes to server, The server sends the response, which is formatted and shown on the UI. So basically when you do API testing, You will send the request with diff parameters combination and assert the response. You can also do performance testing of the api to check response time
@akalyamohan2023
@akalyamohan2023 4 жыл бұрын
@@RaghavPal Thank you so much
@ankitprajapati6382
@ankitprajapati6382 3 жыл бұрын
Hello Raghav, This is really wonderful explaination about API passing values. But i have one requirement in project. How I can Pass Global Environement Variable from One Post Call Response to Another Post Call Request Body? It wont take Parameter i have to send via Request Payload in .NET Zero Architecture. Urgent Suggestion and Help Needed!
@RaghavPal
@RaghavPal 3 жыл бұрын
Hi Ankit, in general we use variables for this, I will need to check more for your scenario
@vamshidharreddy684
@vamshidharreddy684 5 жыл бұрын
How can I get a console on PM using web services
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Vamshidhar, are you talking about postman console. Pls see kzfaq.info/get/bejne/pMthhdaKyM3Pg40.html
@renujoshi3935
@renujoshi3935 3 жыл бұрын
Regarding setting variables -> can you tell where these variables are set?
@RaghavPal
@RaghavPal 3 жыл бұрын
There are diff scope Renu Priority : priority is as follows: - local - data - environment - collection - global
@lisazhou7776
@lisazhou7776 5 жыл бұрын
what's PM stands for? like to know how to assert a value. thanks.
@RaghavPal
@RaghavPal 5 жыл бұрын
its PostMan
@suwarnasonawane6480
@suwarnasonawane6480 5 жыл бұрын
@@RaghavPal I am also looking for same Answer. Thanks!
@vibhabs2359
@vibhabs2359 4 жыл бұрын
when I click run it is displaying 3 times same output
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Vibha, pls check your setup again.
@gazalbhullar2464
@gazalbhullar2464 3 жыл бұрын
Hi Raghav, do you any tutorial on RestAssured API?
@RaghavPal
@RaghavPal 3 жыл бұрын
Hi Gazal, yes, pls check here - automationstepbystep.com/
@supriyapawar8417
@supriyapawar8417 6 жыл бұрын
Hi Raghav, Can you please tell us which scripting language you are using here
@RaghavPal
@RaghavPal 6 жыл бұрын
Hi Supriya, its Javascript
@supriyapawar8417
@supriyapawar8417 6 жыл бұрын
Automation Step by Step - Raghav Pal thank you .. I searched lot for JavaScript tutorial of yours but unable to find Can you please help and assist us on JavaScript tutorial as well
@RaghavPal
@RaghavPal 6 жыл бұрын
Sure Supirya, i will soon create a series on JS
@jeeturanjan1271
@jeeturanjan1271 4 жыл бұрын
where we can see the set variable (POSTMAN) in request?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Jeetu, you just the variable using this command. If required you can do get and print on console to verify
@testercms2407
@testercms2407 4 жыл бұрын
is that java script y ou are using for test?
@RaghavPal
@RaghavPal 4 жыл бұрын
Yes
@saifalisanadi6519
@saifalisanadi6519 4 жыл бұрын
Which language are you using in test code
@RaghavPal
@RaghavPal 4 жыл бұрын
Its JavaScript
@pogo3332
@pogo3332 4 жыл бұрын
Am getting Type error in console,let me know wat s d mistake.
@RaghavPal
@RaghavPal 4 жыл бұрын
Is it in the scripting, ls check on the postman console - kzfaq.info/get/bejne/pMthhdaKyM3Pg40.html
@vigneshrino1399
@vigneshrino1399 4 жыл бұрын
It shows syntax error in this line:- Let urlVar = pm.variables.get("URL"); but what you taught in this lecture i've using the same code here but it has syntax error
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Vignesh, May be some space or semi colon missing in the earlier line.
@SS_Cooking
@SS_Cooking 5 жыл бұрын
Sir will you please tell me the actual difference between Access token and Refresh token?
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Sayma, I thought of writing this in my language but then I found these very useful links. This should make it clear auth0.com/learn/refresh-tokens/ stackoverflow.com/questions/3487991/why-does-oauth-v2-have-both-access-and-refresh-tokens
@SS_Cooking
@SS_Cooking 5 жыл бұрын
@@RaghavPal thank you so much sir
@ravivishwakarma7786
@ravivishwakarma7786 Жыл бұрын
What is pm in console
@RaghavPal
@RaghavPal Жыл бұрын
postman
@TheAnu1998
@TheAnu1998 2 жыл бұрын
Can you show us how to pass a variable in a test. I have a test pm.test("mode", function () { pm.expect(pm.response.text()).to.include('"mode":"AIR"'); }); Instead of AIR I want to pass a global variable. How can I do that? Thanks
@RaghavPal
@RaghavPal 2 жыл бұрын
Hi Anupreet, you can use double curly brackets {{global_var}}, can also get global variables with script - pm.globals.get()
@TheAnu1998
@TheAnu1998 2 жыл бұрын
@@RaghavPal I tried that it did not work, but no problem. I got it figured. Here is the solution - bodyData = JSON.parse(responseBody) var modeV1 = bodyData.features[0].properties.mode console.log(modeV1) pm.test("mode_ver", function () { pm.expect(pm.response.text()).to.include('"mode":"'+modeV1+'"') }); The variable is local at the moment and I will be setting it as a global variable, I think it would work now.
@senalihasanika6029
@senalihasanika6029 3 жыл бұрын
Hi Raghav why we use" set and get VARIABLES through SCRIPTING" I mean what is the purpose of doing this
@RaghavPal
@RaghavPal 3 жыл бұрын
Hi Senali, there can be several use-cases like sometimes we may need to capture value from a response and store it in a variable and use it in a later request. Sometimes we need to generate some random value everytime.. etc
@senalihasanika6029
@senalihasanika6029 3 жыл бұрын
@@RaghavPal Thanks
@PramodChamlingRai
@PramodChamlingRai 4 жыл бұрын
can you make python tutorial? its way easier to learn from your channel. so impressed
@RaghavPal
@RaghavPal 4 жыл бұрын
So happy to know, You can find Python here - automationstepbystep.com/
@devanand5861
@devanand5861 3 жыл бұрын
Useful video..How could I use environment variable in my test script for verification? I need to reverify if my response body contains "hello welcome"
@RaghavPal
@RaghavPal 3 жыл бұрын
Hi Dev, you just need to refer the end variables with the syntax pm.environment.get("variable_key"); Ensure to select the env before execution
@devanand5861
@devanand5861 3 жыл бұрын
Thanks.
@MovingDirection
@MovingDirection 6 жыл бұрын
Raghav: You have written at 4th line -" pm.variables.set("name", "POSTMAN"); ". It is set to which variable. How do I check ?
@RaghavPal
@RaghavPal 6 жыл бұрын
Hi, this will be a local variable created during the session.
@stevenclark1973
@stevenclark1973 4 жыл бұрын
@@RaghavPal similar to a question I just posted.. where was this local variable set?
@abhishekthomas7799
@abhishekthomas7799 4 жыл бұрын
Hi Raghav, How much JS knowledge is required for postman?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Abhishek, You need basic knowledge and as you work you can explore more if required in your scenario. Can check JS tutorials here - automationstepbystep.com/
@abhishekthomas7799
@abhishekthomas7799 4 жыл бұрын
@@RaghavPal Thanks. Does pm stands for postman here?
@RaghavPal
@RaghavPal 4 жыл бұрын
Yes Abhishek
@kavivenky6216
@kavivenky6216 4 жыл бұрын
hi, is this automation Api testing? or manual api testing? if im not wrong your writing scripts so it is automation rite?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Kavi, this is created for both manual and automation testing with TestProject. The scripting part also can be used in manual if required. You can find all here - automationstepbystep.com/
@kavivenky6216
@kavivenky6216 4 жыл бұрын
@@RaghavPal then wat is the difference between manual api and automation api? pls help
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Kavi, wrt Postman, if you are setting up your requests and then running them manually i.e. a user is required to run and check the result and then do the reporting, it will be manual. If you setup scripts and solutions and do integrations in a way that all testing can be triggered on its own without human intervention, it will be automation
@kavivenky6216
@kavivenky6216 4 жыл бұрын
@@RaghavPal thanks raghav ,much appreciated, i did see your course in UDEMY as well,they were nice.keep going.also one last thing pls help us as a beginner in testing which site is good for doing freelancing .
@RaghavPal
@RaghavPal 4 жыл бұрын
Can check upwork
@twinklevarshney4854
@twinklevarshney4854 4 жыл бұрын
Hi , please view this I am getting the syntax error for this script... Collection is running well without this script... console.log("twinkle"); Let urlVar = pm.variables.get("url"); console.log("Valuse of url is" + urlVar);
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Twinkle, I believe let should be with lowercase L
@twinklevarshney4854
@twinklevarshney4854 4 жыл бұрын
Ahaa ..thank you so much for response 🤟
@dotnettitbits8517
@dotnettitbits8517 5 жыл бұрын
What is the difference between pm.globals.set() and pm.environment.set() ??
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi, you will need to understand scope of variables 1. Scope- Environment variables can be accessed with the corresponding environments. Global variables can be accessed broadly regardless of the selected environment. 2. Priority : priority is as follows: - local - data - environment - collection - global So in case a global variables shares same name with an environment variables, at runtime value will be referenced from env variable 3. Getting & Setting variables through scripts - Global - pm.globals.set() - pm.globals.get() - Env - pm.environment.set() - pm.environment.get() learning.getpostman.com/docs/postman/environments_and_globals/intro_to_environments_and_globals/
@dotnettitbits8517
@dotnettitbits8517 5 жыл бұрын
@@RaghavPal Thanks !
@AndyGrem
@AndyGrem 4 жыл бұрын
You are typing the Test Code with no explanation whatosever what it does. Great...
@RaghavPal
@RaghavPal 4 жыл бұрын
Sorry for that Andrew, I will plan a session with more inputs
@AndyGrem
@AndyGrem 4 жыл бұрын
@@RaghavPal Thank's. Waiting for that)
@hemalathapalani3940
@hemalathapalani3940 4 жыл бұрын
Hi Raghav, If I add the script in Collection-> pre request script I'm getting an error "getaddrinfo ENOTFOUND link link:80" can u please help me
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Hema, Pls check your endpoint url is correct & variables are referred correctly. Check the variables, SAVE and then run again. You can also try debugging - kzfaq.info/get/bejne/pMthhdaKyM3Pg40.html
@delightful730
@delightful730 3 жыл бұрын
Need Swagger documentation tutorial plz
@RaghavPal
@RaghavPal 3 жыл бұрын
I will plan on this
@iamthekd07
@iamthekd07 4 жыл бұрын
I don't know how to get/set variables for pm.environment?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Kuldeep, try the examples shown, Let me know if you face any issues
@iamthekd07
@iamthekd07 4 жыл бұрын
Sorry I asked that question before watched full video
@iamthekd07
@iamthekd07 4 жыл бұрын
Raghav need your help regarding my question - what is token exactly ? Actually this question is asked so many times by interviewers
POSTMAN BEGINNER TUTORIAL 8 💡 How to create ENVIRONMENTS
8:15
Automation Step by Step
Рет қаралды 240 М.
Loop request based on data from response in Postman
13:13
Valentin Despa
Рет қаралды 58 М.
I'm Excited To see If Kelly Can Meet This Challenge!
00:16
Mini Katana
Рет қаралды 29 МЛН
Опасность фирменной зарядки Apple
00:57
SuperCrastan
Рет қаралды 12 МЛН
لقد سرقت حلوى القطن بشكل خفي لأصنع مصاصة🤫😎
00:33
Cool Tool SHORTS Arabic
Рет қаралды 28 МЛН
Postman Tutorial #10 -Variables in Postman | Variable Scope in Postman
12:35
Software Testing Mentor
Рет қаралды 14 М.
Postman Beginner Tutorial 8 | Get and Set Variables with Scripts
12:50
Automation Step by Step
Рет қаралды 53 М.
Postman Beginner Tutorial 7 | How to add and refer Variables
9:02
Automation Step by Step
Рет қаралды 54 М.
Writing Tests in Postman - with Examples | The Exploratory
12:53
Postman Beginner Tutorial 9 | Environments
12:15
Automation Step by Step
Рет қаралды 47 М.
Postman Tutorial #53 - Better Approach to Set Variables from API JSON Response
20:33
Software Testing Mentor
Рет қаралды 2,3 М.
I'm Excited To see If Kelly Can Meet This Challenge!
00:16
Mini Katana
Рет қаралды 29 МЛН