How to validate HTML response returned by the API?

1.5k views Asked by At

In the API testing using Flask, I have some APIs which returns the HTML in the response. While API testing I check only status code '200' in the response. But from now I also want to validate data returned by the API. Is it possible to validate HTML returned by the API

I am using python unittest to automate API testing.

1

There are 1 answers

0
Denis Koreyba On

Sure you can validate your response.

If you get it in HTML just parse it and check what you need.

A very good example of how to parse HTML is here Parsing HTML using Python.

What you need to do is to import a class BeautifulSoup like this " from BeautifulSoup import BeautifulSoup" and use it how is's shown in the examples in the link above.