We are using Go.JS in our project and we were trying to automate it with Selenium.
So far we are successfully able to play with the nodes, and also able to link two node with the help of Robot class in JavaScript.
Now we are stuck at a point and not able to find any solution.
The problem is we want to click on the link connecting the 2 nodes.
In case of nodes, with the help of document.getElementsByClassName(‘gojs-diagram-div’)[0].goDiagram.model.nodeDataArray would return a collection of all the objects within the diagram, so in this case we can use “Location” attribute to trigger mouse up and down events.
Instead of using the model arrays, use the actual diagram collections – Diagram.nodes and Diagram.links – or Diagram.findNodeForKey/findLinkForKey. Unless you actually need the data for your testing…
the solution you suggested where path is used, I have a small question here is this path any user defined attribute or GO JS attribute ?
Because in our case we don’t have any path attribute, pls refer ss for reference
with document.getElementsByClassName(‘gojs-diagram-div’)[0].goDiagram.model.findLinkDataForKey(lindID), we are able to get point attribute but that returns null value.
By using the document.getElementsByClassName(‘gojs-diagram-div’)[0].goDiagram.findLinkForKey(“linkID”).geometry.getPointAlongPath(0.5) I am getting the x and y points, but it seems to be incorrect, for instance, the 2 nodes linked both has y as 100, but we are getting y value as 0 by using above method.
The points of a Geometry are always in the Shape’s local coordinate system. So every Link whose Link.path is a straight horizontal line will have a Geometry whose points have y values that are zero no matter where the Link is in in the document or in the viewport.
Input events are always in document coordinates. If you want to click on a Link.path Shape you need to convert a Shape.geometry point from its local coordinates to document coordinates. That is why the code we gave you, above, called GraphObject.getDocumentPoint on the Shape.