getAgGridData 返回包含回车符的 innerHTML 属性的值( ),我只需要验证 insideText 的值,而不需要 ' ' 如显示网页一样。我该如何实施?
cy.get('@AG-Table')
.should('be.visible')
.getAgGridData()
.then((data) => {
cy.agGridValidateRowsExactOrder(data, expectedTable);
});
断言错误: 预期:[{"Description":"刻度大小 - 无效字段}] 实际:[{"描述":"刻度大小 - 无效字段}]
不确定是否有直接的api,你可以尝试下面的方法看看是否有效。
// Assuming you have an instance of the grid API
var gridApi = gridOptions.api;
// Function to get all grid data without carriage returns
function getAllGridDataWithoutCR() {
var rowData = [];
gridApi.forEachNode(function(node) {
rowData.push(node.data);
});
// Process rowData to remove carriage returns if necessary
rowData = rowData.map(row => {
for (let key in row) {
if (typeof row[key] === 'string') {
// Replace carriage returns and new lines
row[key] = row[key].replace(/(\r\n|\n|\r)/gm,"");
}
}
return row;
});
return rowData;
}
// Call the function to get the processed data
var cleanData = getAllGridDataWithoutCR();
console.log(cleanData);