EDJ
EDJ

Reputation: 1023

Cheerio - Unable to obtain children of element

This is the output when printing my ${element}: enter image description here

I wish to obtain the data of the first child of my ${element} that has a type: "text" and data valid duration (hours:minutes:seconds). In my case I want to obtain "5:01".

However, when trying to obtain all the children using ${element}.children() I get the following: enter image description here

Basically there is no data and no type which I can check/obtain. What am I doing wrong?

Upvotes: 0

Views: 1620

Answers (2)

Gaurav Saraswat
Gaurav Saraswat

Reputation: 1383

From the log image I can see children property is an array not a function.

Following Code should get you the desired data.

element.children.find(child => child.type == 'text').data;

Upvotes: 2

mytuny
mytuny

Reputation: 865

${element}.children().first().data()

Upvotes: 1

Related Questions