Skip to content
Advertisement

How do i use/print the value inside a generic attribute in TestCafe

What I’m trying to do is print/use the value of the Polyline attribute.

<Polyline points="x,y x,y x,y x,y">

I’ve tried to get them with these methods:

This is an util function

export const getPointAttribute = async () => {
  const polyline = s.polyline;
  const polylineData = ClientFunction(() => polyline().attributes, {
    dependencies: { polyline }
  });
  return polylineData 
}

This is inside the test script

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

or

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

And I include my selectors external

import * as s from '../utilities/selectors';

But all I get is a promise as output in the console log

Promise { }

or

ReExecutablePromise { _then: [], _fn: [Function], _taskPromise: null }

Any help is appreciated!

Advertisement

Answer

You should await the call inside the console.log:

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

or

test('', async (t) => {
   console.log(await s.polyline.getAttribute('points'));
}
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement