3

I am trying to determine if my Selector is capturing the correct HTML elements. The only thing that is being outputted is the Selector object which doesn't tell me anything.

I tried to put a debugger in VScode and use the console to view the Selector.

For example if I have this HTML,

<html>
  <body>
    <h1>This is a test</h1>
  </body>
</html>

and my Selector is as followed... const h1 = Selector('h1');

Is there a way for me to see the HTML of the captured element? Eg; have to output

<h1>This is a test</h1>?
Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
Brett
  • 33
  • 3
  • console.log(h1); – Andy Danger Gagne Apr 05 '19 at 18:00
  • 2
    Logging of TestCafe Selector will not provide any useful information since TestCafe Selector is a complex object that initially does not contain html code. For TestCafe you can use the following approach: const html = await Selector('h1').innerText; console.log(html); – Alex Kamaev Apr 08 '19 at 10:48

1 Answers1

3

Debugging a Selector object in debug mode is quite difficult. The best way I found to check if a Selector is correct is to hover over it before doing any action or assertion:

const h1 = Selector('h1');
await t
  .hover(h1)
  ...

Then you should see the big cursor moving and hover over the selector.

hdorgeval
  • 3,000
  • 8
  • 17