Validating HTTP Response Codes in Automated Testing Using Webship-js


Checking HTTP response codes is essential for web reliability. These codes indicate server status, helping to identify issues like broken links or unauthorized access, ensuring optimal performance and a better user experience.
In this blog, we will test HTTP response codes using the World Meteorological Organization website (https://wmo.int/
) as an example.
We need step definitions to create the scenarios required for testing, such as:
Then the response status code should be {number}
This step definition is used after making a request to the web service under test. Once the response is received, this step definition asserts HTTP status code returned by the server matches the expected code.
Example:
Then the response status code should be 200
The status code 200 refers to a successful request. Meaning that the server has processed the request and returned the appropriate response.
Example:
Then the response status code should not be 404
The status code 404 refers to that the requested resource not found on the server. Meaning a possible error or invalid URL. So that it should not be 404.
You can see more step definitions: https://webship.co/docs
See all the blog: https://webship.co/blog/validating-http-response-codes-automated-testing-using-webship-js
Watch the recorded video of the robot while running the automated functional testing feature
Subscribe to my newsletter
Read articles from webshipco directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

webshipco
webshipco
Love to help in speeding up the work of having Automated Functional Acceptance Testing for products to ship websites in a swift way.