简体   繁体   中英

Postman: How to compare variable with value in pre-request script?

I have a variable value that is either true or false set in a JSON file. For my pre-request script, how would I compare the value of a variable with an expected value? Right now I am doing:

if (pm.variables.get("VARIABLE_NAME")=="true"){ ... }

However, the if statement is running everytime, regardless of whether VARIABLE_NAME is set as true or false.

我唯一的想法是,如果您在“ VARIABLE_NAME”中具有bool值,那么在将“ == bool”与非空字符串(“ test”是一个字符串)进行比较时,始终为true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM