Search code examples
testingautomationautomated-testse2e-testingtestcafe

Print current DOM element


I'm trying to select an element based on a sibling element, similar to this post. However, I get an error The specified selector does not match any element in the DOM tree. which means that testcafe didn't find my element.

To help debug, it would be good if I could print the DOM element currently being read by Selector().

Using console.log(Selector('element')) prints out the object. Is there a way to output the current DOM element?


Solution

  • You can output any property of DOM Node Snapshot.

    For example

    console.log(await Selector('element').innerText);
    console.log(await Selector('element').value);