如何将$el.text()转换为数字类型



我在柏树中得到这段代码是为了只获取表中的数字。

cy.get('.MuiTable-root > .MuiTableBody-root > .MuiTableRow-root  > .MuiTableCell-root:first-child')
.each(($el, $index) => {
if ($el.text() !== 'REDHAIR')
values.push($el.text())
expect(values.parseInt()).to.be.within(1,3)

但是有一个错误,它说parseInt((在值中没有属性。

cy.log具有以下结果

log 1
log 2
log 3  

谢谢。

我应该是我很确定

parseInt(values)
我找到了答案。谢谢你的想法。
if ($el.text() !== REDHAIR') 
values.push($el.text()) 
items = values.map(value => parseInt(value)) cy.log('Items', items) 
}).then(() => {
items.forEach((value) => {
expect(value).to.be.within(1,3)
}
}

这将迭代数组中的数字。

最新更新