0

I find that I often want to be able to log out what a Selector was looking for at various times during execution. I couldn't find a "legit" way to do this so I worked around it by creating the following function:

function printSelector(selector) {
  console.log(selector[Object.getOwnPropertySymbols(selector)[0]].options.apiFnChain.join(""));
}

// And with this, if you have something like:
let mySelector = Selector('button').withText('foo').with({ visibilityCheck: true });

// You can run:
printSelector(mySelector);

// and get: Selector('button').withText('foo').with({ visibilityCheck: true })

My question is: is there some better way that doesn't require using the internal apiFnChain to find / log this info?

Thanks

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
strylee
  • 31
  • 4

1 Answers1

2

TestCafe does not allow you to log Selectors if there were no Selector errors. However, the approach we use is similar to yours. You can continue using your approach. However, please note that this is private API and it can be changed in the future.

Ilya Afanasenko
  • 517
  • 2
  • 7