We use selenium for Test Automation. Where ever we have mxGraph in our application, we are not able to record the test cases, as Selenium expects a unique identifier (say id or name) for an element (say vertex, edge or overlay).
Currently, mxGraph does not assign an id for the svg element created for vertex, edge or overlay.
Requirement: To use selenium for test automation, we need an identifier (say id or name) for the svg element for selecting a vertex, egde or an overlay uniquely.
The identifier can be a running number for "id" or a known convention for "name".
Also, each time the canvas is created (with same nodes), the identifier should be the same for the node.
Can you kindly provide us with a solution for the above mentioned problem or let us know if we have missed anything from our side?
The following will add an ID to the shape and label SVG nodes for vertices and edges (for overlays, mxCellRenderer.initializeOverlay can be overridden accordingly):
Note that initializeOverlay takes an mxCellState and and mxImageShape as the second argument.
If you need to assign an ID to a child element of a shape for a cell, the following code can be used instead: