https://cypress.io logo
Get value property from a list of elements
# i-need-help
m
I attempted to get the
value
property from a list of input elements, but I just only get the first value. I tried something like this, to get all the values:
Copy code
typescript
cy.get('table tbody tr td:nth-child(2) input')invoke('prop', 'value').each(($el) => actualResult.push($el));
but I'm getting an error since it's not possible to chain the
invoke()
and
each()
commands together. Is there a way to get the values for my list of elements? And other question that comes to me, related to this: How can I get the values for the other existing properties of my list of elements? Thanks in advance for your answers!
g
so you first get all inputs and then want to map them into their values?
m
nope, I want to get their values (by default they have a value)
g
something like

https://www.youtube.com/watch?v=OmVzv6pJN6I

m
Yep, thanks! In
map('value')
,
value
is the property? And, I'm curious about my second question: How can I get the values for the other existing properties of my list of elements (for example, the
webkitEntries
?
g
yes, dom html input has
value
property. You can get other properties the same way
m
So, can I do something like this:
map('webkitEntries')
2 Views