postmanlabs / newman

Newman is a command-line collection runner for Postman
https://www.postman.com
Apache License 2.0
6.88k stars 1.16k forks source link

Unable to run Postman collection in Newman which has dynamic variables and parsing in the test scripts #1542

Closed UA55 closed 6 years ago

UA55 commented 6 years ago

First of all I tried to run the newman from the cmd but it didnt work (newman’ is not recognized as an internal or external command, operable program or batch file..) I tried all possible solutions and it doesn't seems to work. so now I am using the node.js cmd and my collections seems to be running atleast but they are not recognizing my environment variables even when I export the environment file in the same location as my collection and give the following command: newman run test.json -e env.json -r html,cli,json,junit I passed several requests and the ones that had environment variable failed instantly but the ones which didnt passed and the test scripts ran just fine.

I guess I need help with figuring out how to get my collection with environment variables and my test scripts (with Parsing and passing those variables in the chained request format) run in the node.js cmd and get the reports generated. Please help!

kunagpal commented 6 years ago

@UA55 Could you complete the provided issue template? It'll help us resolve your issue faster 😄

UA55 commented 6 years ago

What details am I missing?? Node Js verison : 10.1.0 npm version: 5.6.0 I am using Postman installed on my desktop and not the google chrome extension. Let me know if you need any additional details

kunagpal commented 6 years ago

@UA55 Thanks for sharing those details, could you also go through the following?

  1. Newman isn't recognized: Could you confirm that you have installed Newman globally using npm, like so? npm i -g newman (This might require you to open up a command prompt/PowerShell terminal in Administrative mode).
  2. Could you also confirm that the Newman executable was added to your system path correctly by running the following command: where newman? This will return the path of the global Newman install.
  3. Requests with environment variables fail: In any one of the requests with environment variables that is failing, could you add console.log(pm.environment.toObject()); to the test/pre-request script code and confirm that the environment variables are not being resolved, even with the -e env.json flag passed to Newman?
UA55 commented 6 years ago

I delete d the newman package from ....appData/Roaming/npm and then installed using npm i -g newman again. It installed successfully and update 194 packages but when I did where newman it says could not find files for given pattern (s). Do I need to add the question mark too? Passing with the environment variables is resolved actually there was the self certificate issue which got resolved by adding -k. So I guess my on;y question remaining is that I am running this node.js cmd, can you please help me get this run through normal cmd

kunagpal commented 6 years ago

@UA55 No, the question mark was not needed. Could you go through the solution described here: https://stackoverflow.com/questions/23860262/npm-global-install-does-not-add-packages-to-path-on-windows-8-1? There are known issues where globally installed npm modules would not become instantly usable in Windows.

kunagpal commented 6 years ago

Hey @UA55, is this issue still occurring for you?

kunagpal commented 6 years ago

@UA55 Closing issue due to inactivity, feel free to revert if you're facing difficulties 😄

raviforever14 commented 4 years ago

i am working on windows 10, i am not able to Postman request commands into Jenkins,these commands are wokring fine on cmd prompt. sending my commands and errors: Here i am posting build and error plz help. C:\Users\MY\Desktop\Export collection newman run collection1.postman_collection.json Error: FailedConsole Output Started by user ravi kumar Running as SYSTEM Building in workspace C:\Program Files (x86)\Jenkins\workspace\PostmanCollectionRequest [PostmanCollectionRequest] $ cmd /c call C:\WINDOWS\TEMP\jenkins3008023594651108106.bat

C:\Program Files (x86)\Jenkins\workspace\PostmanCollectionRequest>C:\Users\MY\Desktop\Export collection 'C:\Users\MY\Desktop\Export' is not recognized as an internal or external command, operable program or batch file.

C:\Program Files (x86)\Jenkins\workspace\PostmanCollectionRequest>newman run collection1.postman_collection.json
'newman' is not recognized as an internal or external command, operable program or batch file.

C:\Program Files (x86)\Jenkins\workspace\PostmanCollectionRequest>exit 9009 Build step 'Execute Windows batch command' marked build as failure Finished: FAILURE Thanks

kostiahuryuk commented 4 years ago

having same error

jmorrisfmc commented 4 years ago

Same error. Have tried all kinds of Re-installs. No solution. Please advise if anyone has anything that works. Thanks!

kostiahuryuk commented 4 years ago

My solution was like this: 1) try to execute from Jenkins commands like:

node -v
npm -v
newman -v

in case something missing just install it, for example npm install newman or npm install -g newman-reporter-htmlextra if everything works fine go to the next step otherwise try to figure out what's wrong

2) In Jenkins specify workspace to your project https://prnt.sc/s5d0ab 3) add Windows batch command https://prnt.sc/s5d20b

Tips(if something not working):

  1. Install 'NodeJS Plugin' thru Jenkins plugins > restart Jenkins after installation > add configurations

    • Manage Jenkins Global Tool Configuration > NodeJS
    • Name: Latest Node
    • Install automatically: YES
    • Version: latest
    • Global npm packages to install: bower@~1.8.0 grunt-cli@~1.2.0
    • Global npm packages refresh hours: 100
  2. Set 'system envintoment variables' for: {code}Variable: NODE_PATH Value: C:\Users\name\AppData\Roaming\npm\node_modules <- path to your npm folder Variable: PATH VALUE: C:\Program Files\nodejs -> path to nodejs{code}

  3. In Jenkins job configuration -> go to Build Environment Provide Node & npm bin/ folder to PATH

Olubori-O commented 7 months ago

I am having troubles running newman on my Windows CMD. I copied my folder path successfully but the error says the requested file in my folder cannot be found. I am trying to run my exported postman collection and exported postman environment. Please help