Hi, we use GoJS which is displayed as gojs-diagram and canvas when viewing elements. We are using a Record and playback tool for our testing and need to be able to access specific elements displayed within the canvas. Is there a way we can do this? At the moment the canvas is the only element accessible.
An HTMLCanvasElement cannot contain HTML DOM elements.
I suppose you could set Diagram.renderer to “svg”, in which case the Diagram generates an SVG DOM tree instead of drawing to the Canvas. The SVG elements corresponding to Parts such as Nodes and Links have “data-…” attributes that you might find useful. The Canvas element is still used for input handling.
Many thanks Walter. I will pass this onto our dev team.
Which version of GoJS are you using?
You don’t need to involve the dev team – just set it on the Diagram in your testing environment. You can get the Diagram instance from the hosting HTMLDivElement and then set its properties or call its methods:
document.getElementById("myDiagramDiv").goDiagram.renderer = "svg"