Need help with Cheerio parsing HTML Data

cheerios

Hi Team, I have my HTML response as attached.

I tried to verify if the database value is equal to Success and Connection value is Up.
I am able to grab the database but unable to check the next line or the value of the Database using Cheerios.
Can anyone suggest what needs to be done to check the values of Database and Connection?

Any help is appreciated !!!

Hey @karumuriabhishek,

I have very limited knowledge of cheerio but this worked for me:

const $ = cheerio.load(pm.response.text());

pm.test("Database value is SUCCESS", function () {
    pm.expect($('tr:nth-child(1) > td:nth-child(2)').text()).to.equal('SUCCESS');
});

pm.test("Connection value is SUCCESS", function () {
    pm.expect($('tr:nth-child(2) > td:nth-child(2)').text()).to.equal('SUCCESS');
}); 

This was based on you having a HTML response that looks like this:

<table>
	<tr>
		<td>Database</td>
		<td>SUCCESS</td>
	</tr>
	<tr>
		<td>Connection</td>
		<td>SUCCESS</td>
	</tr>
</table>

Not sure if this is what you’re looking for but hopefully it helps :slight_smile:

1 Like