Simulate SelectionAdorrnmentTemplate Click Selenium

Hi,

I am trying to provide E2E tests using protractor. I can simulate select,click,etc events on a node but how can I simulate a button click on a selectionAdorrnmentTemplate for a given node.

Example selecting node with a selectionAdornmentTemplate:
var diagram = go.Diagram.fromDiv(diagramId);
var entity = diagram.model.nodeDataArray.filter(filterByCategory);
var node = diagram.findNodeForData(entity);
diagram.select(node);

Thanks,
Patrick

I’m not familiar with Selenium, but I assume you have already searched this forum for any additional information about it.

You might find the Robot class in the Extensions directory useful:
http://gojs.net/latest/extensions/Robot.html
http://gojs.net/latest/extensions/Robot.js

Hi Walter,

Yes I have read the other posts and am following in a similar approach with respect to Selenium. However how can I programmatically click a button that is part of a nodes selectionAdornmentTemplate?

Example Selection Adornment:
var = $$(go.Adornment, ‘Vertical’,
$$(go.Panel, ‘Auto’,
$$(go.Shape, {
fill: null,
stroke: ‘deepskyblue’,
strokeWidth: 2
}),
$$(go.Placeholder)
),
$$(go.Panel, ‘Horizontal’, {
defaultStretch: go.GraphObject.Vertical
},
$$(‘Button’, $$(go.Shape, {
geometryString: ‘M0 0 L10 0’,
fill: null,
stroke: ‘red’,
margin: 3
}),
{
click: addTransition,
toolTip: nodeUtil.makeTooltip(‘Add Transition’)
},
new go.Binding(‘visible’, ‘’, canAddTransition).ofObject()),
$$(‘Button’, $$(go.Shape, {
geometryString: ‘M0 0 L10 0 10 6 0 6z’,
fill: ‘lightyellow’,
margin: 3
}),
{
click: addUnitProcedure,
toolTip: nodeUtil.makeTooltip(“Add Unit Procedure”)
},
new go.Binding(‘visible’, ‘’, canAddUnitProcedure).ofObject())
)
);

Patrick

I think the extensions/Robot.html sample shows an example of clicking.

If you are wondering where that particular button is, you can find it by looking the “Selection” Adornment associated with the selected Node.

First, find the Node that you care about. Maybe you’ll use myDiagram.selection.first() or myDiagram.findNodeForData(someData).
http://gojs.net/latest/api/symbols/Diagram.html

Second, find the “Selection” Adornment: node.findAdornment("Selection").
http://gojs.net/latest/api/symbols/Part.html#findAdornment

Third, find the button somehow, probably with: adornment.findObject("ButtonName").
http://gojs.net/latest/api/symbols/Panel.html#findObject

Fourth, get the button’s center point in document coordinates: button.getDocumentPoint(go.Spot.Center).
http://gojs.net/latest/api/symbols/GraphObject.html#getDocumentPoint

Fifth, pretend to click at that point, as shown in:
http://gojs.net/latest/extensions/Robot.html

Thanks Walter, that worked perfectly.

I am trying to work with E2E also.
can someone explain how to make this work?
var diagram = go.Diagram.fromDiv(diagramId);
I tried to do this
> var diagram = go.Diagram.fromDiv( “diagramdiv”);

how do I get reference to go.diagram via protractor?

I don’t know Protractor, so I cannot answer your question.

But I would think that it would offer access to any HTML DOM element in the page. And even if it didn’t, you should be able to refer to the diagram Div’'s id.

Thanks @walter,
How do you do e2e test?
do you know how @patrick_fay handles his tests?

I cannot speak for other people.

I don’t understand the question – aren’t some answers given above?

I am looking for appraoch to do End To End tests,

one apprachi is to use jasmine,
the problem with jasmine is that it does not have access to the DIAGRAM library,
so i cannot do this

var diagram = go.Diagram.fromDiv(diagramId);

because jasmine does not have access to go.Diagram.

Are you not able to evaluate JavaScript in the context of the browser?

I work with selinum and jusmine

here is the link to the architecture

in this architecture I have access to the html but not to the libraries of the applicaton.

I don’t mind using another architecute that you may propose,

thanks

@patrick_fay - Did you able to automate it with selenium?