Show context Menu with selenium

Hi,

I am using a diagram component, and i want to test my UI with Selenium.
I manage to select a node, but i am not able to show the context menu of that node. I've tried to call contextMenuOpen with a contextMenuModel instance of my own (using the API : https://ej2.syncfusion.com/documentation/api/context-menu/contextMenuModel/), but without success.
Do you have a clue for this?


The definition of my diagram, if it helps:
       <ejs-diagram id="diagram" dataSourceSettings="ViewBag.DataSourceSettings" width="100%" height="400px"
                                 getNodeDefaults="ViewBag.NodeDefaults" getConnectorDefaults="ViewBag.ConnectorDefaults"
                                 sourcePointChange="sourceConnectionChange"
                                 setNodeTemplate="ViewBag.NodeTemplate" targetPointChange="targetConnectionChange"
                                 contextMenuOpen="contextMenuOpen" contextMenuClick="contextMenuClick" textEdit="updateName"
                                 created="diagramCreated" collectionChange="collectionChange">
                        <e-diagram-snapsettings constraints="None"></e-diagram-snapsettings>
                        <e-diagram-scrollsettings scrollLimit="Diagram"></e-diagram-scrollsettings>
                        <e-diagram-contextmenusettings show="true" showCustomMenuOnly="true" items="@ViewBag.ContextMenu"></e-diagram-contextmenusettings>
                        <e-diagram-layout type="ComplexHierarchicalTree" horizontalSpacing="25" verticalSpacing="25" connectionPointOrigin="DifferentPoint"></e-diagram-layout>
                    </ejs-diagram>

1 Reply 1 reply marked as answer

GG Gowtham Gunashekar Syncfusion Team April 6, 2021 02:47 PM UTC

 
Hi Laurent,  
  
On the further analysis on the shared details, we suspect you have used click event, in this case normally right click mouse event will trigger, but we should trigger left click mouse  event to render the content menu. 
 
Code snippet: 
 
let mousedown = document.createEvent('MouseEvent'); 
var element = document.getElementById('diagram' + 'content'); 
        mousedown.initMouseEvent('mousedown', false, false, window, 1, 0, 0, 700, 400, false, false, false, false, 0, null); 
        element.dispatchEvent(mousedown); 
 
 
If we misunderstood your requirement means we request you to share us more details like simple sample to replicate the reported issue with replication procedure. 
 
Regards   
Gowtham  


Marked as answer
Loader.
Up arrow icon