If you want to run API tests without using Postman, you can use Newman. Using newman is useful when you are in CI/CD pipeline as it is impossible to open Postman from there. So we can just pass the newman script to devOps to execute the tests. Before installing Newman, need to install Node.js To confirm that Node js and newman was successfully installed To install Newman extension (for report generation) Using Newman to execute test where highlighted portion is the collection name and underlined portion is the environment name (can just type initial letter and then press "tab" button) Sample outcome: To execute test and generating report (where underlined is script for report generation): The report will be available in the folder where this command was run. Sample HTML report: To give title to the report:
Common API status code: 1. 200 - request was successful 2. 201 - record has been created successfully 3. 204 - no content 4. 400 - bad request 5. 401 - unauthorised 6. 403 - forbidden 7. 404 - not found 8. 429 - too many request 9. 500 - server error 10. 501 - internal server error 11. 503 - time out ------------- In postman, we can use the snippet packages written in javascript such as below: Below is a sample of how to run an automation test in Postman for API testing This will be checking the specific value of a variable Creating, storing and using a variable in Postman storing in an environment invoking the variable in a different API (must select the correct environment) Checking the first returned id data: If need to run the full collection: Test result:
Synchronisation issue with Selenium Sometimes when we run our code, Selenium cannot find the element even when we know that that element is there. Why does this happen? The webdriver is slower than actual code. What if when we go to url and we open the page, what happens when it doesn't load yet but the code is already at the next step trying to find the element. So to fix this issue, we can use the thread sleep or wait functionality.
Comments
Post a Comment