gpt4 book ai didi

javascript - 在get()。within()中嵌套有get()的自定义命令返回错误的数据

转载 作者:行者123 更新时间:2023-12-03 07:23:43 25 4
gpt4 key购买 nike

更新后, Cypress 使用5.4版的自定义命令将返回错误的数据。在更新之前,此自定义命令返回tr的数组,但是现在,它返回整个表元素,就像只有第一个get()工作并返回一个值一样。更有趣的是,在第二个回调内部,在.within()内部,其中的值正确,但是整个命令返回了其他内容。

// Works in 4.7 but not in 5.4

Cypress.Commands.add('getTableColumnValues', (selector) => {
cy.get(selector).within(() => {
cy.get('tbody tr').then((rows) => {
// here rows is correct array of tr
return rows;
});
});
});
// Usage

cy.getGridColumnValues('.custom-table').then((values) => {
// Expected value: array of tr
// Actual result: array with 1 element - table.custom-table
});
// Works fine

Cypress.Commands.add('getTableColumnValues', (selector) => {
cy.get(`${selector} tbody tr`).then((rows) => {
return rows;
});
});
有人可以帮助我理解为什么这样工作吗?

最佳答案

在5.4.0版中对within()进行了更改。在其changelog中的错误修正中提到了它:
cypress 5.4.0 changelog bugfix

关于javascript - 在get()。within()中嵌套有get()的自定义命令返回错误的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64676802/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com