Javascript 如何在TestCafe中使用/打印泛型属性中的值

Javascript 如何在TestCafe中使用/打印泛型属性中的值,javascript,reactjs,testing,e2e-testing,testcafe,Javascript,Reactjs,Testing,E2e Testing,Testcafe,我要做的是打印/使用属性的值 <Polyline points="x,y x,y x,y x,y"> 这在测试脚本中 test('', async (t) => { console.log(u.getPointAttribute()) } 或 我还包括我的选择器 import * as s from '../utilities/selectors'; 但我得到的只是一个在控制台日志中作为输出的承诺 承诺{} 或 ReExecutablePromise{u then:

我要做的是打印/使用属性的值

<Polyline points="x,y x,y x,y x,y">
这在测试脚本中

test('', async (t) => {
   console.log(u.getPointAttribute())
}

我还包括我的选择器

import * as s from '../utilities/selectors';
但我得到的只是一个在控制台日志中作为输出的承诺

承诺{}

ReExecutablePromise{u then:[],_fn:[函数],_taskPromise:null}


感谢您的帮助

您的
getPointAttribute
函数返回
polylineData
对象,该对象是一个实例,如果是(这反过来又基于承诺)。这就是为什么当您记录
u.getPointAttribute()
时,您会收到这些消息。在调用ClientFunction之前,只需使用
wait
关键字。请参阅以下代码:

请参阅以下文章以获取更多信息


我还想指出,您不需要在
getPointAttribute
函数中使用
async

您应该在console.log中等待调用:

test('', async (t) => {
   console.log(await s.polyline.getAttribute('points'));
}


我已经设法让它与一个实用功能的人谁感兴趣的工作

export function getPoints(object: Selector) : Promise<string> {
  return object.getAttribute('points');
}

谢谢你们的帮助

谢谢你的回复!async是一个草率的副本,感谢您的注意,它已被删除。不幸的是,函数仍然返回:Promise{}
const polylineData = ClientFunction(() => polyline().attributes, {
    dependencies: { polyline }
});
await polylineData();
test('', async (t) => {
   console.log(await s.polyline.getAttribute('points'));
}
test('', async (t) => {
   console.log(await s.polyline.getAttribute('points'));
}
export function getPoints(object: Selector) : Promise<string> {
  return object.getAttribute('points');
}
import * as u from '../utilities/functions';
import * as s from '../utilities/selectors';
console.log(await u.getPoints( s.polyline ));