Trying to understand how to best parse HTML content in Postman test script.
So far, I am able to print the content to the console, but I did not find an elegant way to iterate through two type of element.
My HTML content is a with a bunch of lines. Each line (tr) contains multiple elements (td) and I would like to extract the name in the link (text inside ) if the line is Active - for this first line, getting the value
<tbody> <tr id="row_1" class="tr-content"> <td class="tr-content-td "> <a href="index.phtml?page=company&cny=29383900">28683A1</a> </td> <td title="28683A1" class="tr-content-td "> 28683A1 </td> <td title="production" class="tr-content-td "> production </td> <td title="0" class="tr-content-td tr-content-td-nr"> 0 </td> <td title="MAIN_OWNER_02" class="tr-content-td "> MAIN_OWNER_02 </td> <td title="Active" class="tr-content-td "> Active </td>
How I found the problem:
I’ve already tried:
// I need to filter on those values with
Active as status value
// path: tbody/tr/td/a/value
const $ = cheerio.load(pm.response.text())
const tbody = $(".tr-content-td a").text();
console.log(tbody); // this dump all the text, but I have not find the way to make it conditional on the other field.
But not sure where to find this in the documentation of Postman or elsewhere.