打印数组值 testCafe typeScript
print array values testCafe typeScript
请帮我弄清楚如何从数组中获取实际值而不是这些值:
[object ReExecutablePromise]
[object ReExecutablePromise]
[object ReExecutablePromise]
[object ReExecutablePromise]
[object ReExecutablePromise]
这是我的代码示例:
test('Reference Type', async t=>{
await loginPage.login(oceanconfig.testUser, oceanconfig.password);
await t.click(HomePage.button);
const rowsNum = await CreateShipmentPage.referenceTypeOption().count;
const arr = [];
for(let i = 1; i< rowsNum-1; i++){
const referenceType = CreateShipmentPage.referenceTypeSelect().innerText;
arr.push(referenceType);
}
const item = await arr.slice(1, 6);
for (let row of item) {
console.log(row);
}
})
您在获取 'referenceType' 时似乎错过了 'await' 运算符。
请尝试以下代码:
test('Reference Type', async t=>{
await loginPage.login(oceanconfig.testUser, oceanconfig.password);
await t.click(HomePage.button);
const rowsNum = await CreateShipmentPage.referenceTypeOption().count;
const arr = [];
for(let i = 1; i< rowsNum-1; i++){
const referenceType = await CreateShipmentPage.referenceTypeSelect().innerText;
arr.push(referenceType);
}
const item = await arr.slice(1, 6);
for (let row of item) {
console.log(row);
}
})
请帮我弄清楚如何从数组中获取实际值而不是这些值:
[object ReExecutablePromise]
[object ReExecutablePromise]
[object ReExecutablePromise]
[object ReExecutablePromise]
[object ReExecutablePromise]
这是我的代码示例:
test('Reference Type', async t=>{
await loginPage.login(oceanconfig.testUser, oceanconfig.password);
await t.click(HomePage.button);
const rowsNum = await CreateShipmentPage.referenceTypeOption().count;
const arr = [];
for(let i = 1; i< rowsNum-1; i++){
const referenceType = CreateShipmentPage.referenceTypeSelect().innerText;
arr.push(referenceType);
}
const item = await arr.slice(1, 6);
for (let row of item) {
console.log(row);
}
})
您在获取 'referenceType' 时似乎错过了 'await' 运算符。 请尝试以下代码:
test('Reference Type', async t=>{
await loginPage.login(oceanconfig.testUser, oceanconfig.password);
await t.click(HomePage.button);
const rowsNum = await CreateShipmentPage.referenceTypeOption().count;
const arr = [];
for(let i = 1; i< rowsNum-1; i++){
const referenceType = await CreateShipmentPage.referenceTypeSelect().innerText;
arr.push(referenceType);
}
const item = await arr.slice(1, 6);
for (let row of item) {
console.log(row);
}
})