DEV Community

Cover image for Validating HTTP Response Codes in Automated Testing Using Webship-js
webship.co
webship.co

Posted on

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
https://www.youtube.com/watch?v=FD_bOdPjZ0w

Top comments (0)