Hi ,
I want to do automation testing on Nodes , by simulating node click and node selection etc.
How can i select node by passing its index.
say …go.Diagram.fromDiv(graphDiagram).select(0) etc
i can get the selection node location by…
go.Diagram.fromDiv(graphDiagram).selection.first().location
walter
July 28, 2016, 10:05am
2
The value of graphDiagram
appears to be an HTML DIV element. Is that correct?
If so, then evaluating go.Diagram.fromDiv(graphDiagram)
will get you a Diagram object, from which you can do anything. Diagram | GoJS API
You might want to do:
var node = diagram.findNodeForKey(...);
if (node !== null) {
var viewpos = diagram.transformDocToView(node.location);
// viewpos is in coordinate system of graphDiagram DIV
}
Read more at GoJS Coordinate Systems-- Northwoods Software .
Yes it is HTML DIV element ,
can you pass me example to select any node
ex : go.Diagram.fromDiv(graphDiagram).select(0) where 0 is inxex or node Id or node name etc
walter
July 28, 2016, 10:29am
4
I just gave you that code. You just need to know the unique key of the desired node in the model. That will be a string or a number.
i am able to get the nodeData List through go.Diagram.fromDiv(graphDiagram).model.nodeDataArray[0] ,
how to view the node content ( i have button inside the node ) want to click on it through automation.
walter
July 29, 2016, 12:03pm
6
If you have given the button a GraphObject.name (i.e. { name: "BUTTON" }
), then you can do something like:
var button = node.findObject("BUTTON");
if (button !== null) {
var buttonpos = diagram.transformDocToView(button.getDocumentPoint(go.Spot.Center);
// buttonpos is in coordinate system of the DIV
}
not able to find button inside the selected node , ( i have added button inside node) . Any other way to find ?
Sample node template :
var nodeTemplate =
goJ(go.Node, "Vertical",
{
zOrder:100
},
new go.Binding("location", "loc"),
{ isShadowed: true,shadowColor:"#cccccc",shadowBlur:5},
{ selectionObjectName: "BODY" },
goJ(go.Panel, "Auto",
{ name: "BODY"},
goJ(go.Shape, "RoundedRectangle",
{ fill: "transparent" , stroke: "#67D5E0", width:200, height:54},
goJ(go.TextBlock,{ font:'12px roboto', textAlign: "center", wrap: go.TextBlock.WrapFit, width:180,margin: new go.Margin(2, 1, 22, 1)}, new go.Binding("text", "value",scope.getNodeText)),
goJ("Button",new go.Binding("location", "loc"),{margin:1,alignment: new go.Spot(0, 1),cursor: "pointer"},
goJ(go.Picture,{source: "images/add-plus-blue.png"}),{
click: scope.tets
}
)
)
walter
August 1, 2016, 9:47am
8
It’s hard for me to read your unindented code. Code Formatting
It does not appear as if you gave the “Button” a name as I suggested in my previous reply.
please find the formatted sample code , do you see i need to add anything in button ?
walter
August 1, 2016, 11:03am
10
If you want to run the code I gave you in my reply, you need to give your button a name, as I gave in that same reply.
Thanks Walter , i am able to get the selected node button location details …
similarly , How to get link location information ?
walter
August 2, 2016, 10:49am
12
The same techniques work for GraphObjects within links as well as in nodes.