View canvas element on dom

Hey, I’m using Agnular 6 with GoJS version ‘1.8.35’
I want to see the elements inside the canvas html.
I want to see the elements I’m using on my code and not as canvas on the inspect element browser.
Can it possiable?

The HTMLCanvasElement doesn’t really support much in the way of child elements.

I suggest that you use JavaScript to get the Diagram for the HTMLDivElement and then look at its Diagram.nodes and Diagram.links collections.

You might want to look at the Robot extension:

I want to make testing authomation on my results.
Maybe there is another way to testing the HTMLelement?
Maybe just on dev mode? or other interesting way?

For performance reasons the HTMLCanvasElement does not support any interesting and meaningful DOM children.

I suppose you could look at the diagram as SVG. Something like:


and then dive into that SVG DOM to look at the SVG elements that you care about.

But I really do recommend instead that you look at the actual representations of the Nodes and Links that are being rendered by the Diagram. I assume you have a way of checking what state there should be, as every test system does. You can do things such as this, assuming a function called assert in your environment:

var diag = document.getElementById("myDiagramDiv").goDiagram;
assert(diag.nodes.count === 4);
var gamma = diag.findNodeForKey("Gamma");
assert(gamma !== null && === "Gamma" && gamma.location.equalTo(0, 70));

The GoJS API tells you what you can write in JavaScript:

Although the use of the “goDiagram” property on the HTMLDivElement isn’t documented, because it’s technically outside of the API. The official way to get a reference to a Diagram instance is by calling the static function Diagram.fromDiv:

var diag = go.Diagram.fromDiv(document.getElementById("myDiagramDiv"));
. . .

But we very recently added that “goDiagram” property for convenience, since some people build web pages don’t make the “go” namespace available.