How to use Robot.js in C# automation?

Thanks for your help, I was able to get it work, I had to clean up a couple other minor things. We may look at that later, these are very simple tests for now.

This is how the js file we are using looks now after the changes we made for anyone else that may run into a similar situation using Selenium C# automation in the future.

// Create Diagram
var diagramDiv = document.getElementById(“myDiagramDiv”);
var diagram = go.Diagram.fromDiv(diagramDiv);

/**

  • Transfer property settings from a JavaScript Object to an InputEvent.
  • @param {InputEvent} e
  • @param {Object} props
    */
    function initializeEvent(e, props) {
    if (!props) return;
    for (var p in props) {
    if (p !== “sourceDiagram”) e[p] = props[p];
    }
    };

/**

  • Simulate a mouse down event.

  • @param {number} x the X-coordinate of the mouse point in document coordinates.

  • @param {number} y the Y-coordinate of the mouse point in document coordinates.

  • @param {number=} time the timestamp of the simulated event, in milliseconds; default zero

  • @param {object=} eventprops an optional argument providing properties for the InputEvent.
    */
    function MouseDown(x, y, time, eventprops) {
    if (typeof x !== “number” || typeof y !== “number”) throw new Error(“MouseDown first two args must be X,Y numbers”);
    if (time === undefined) time = 0;

    if (!diagram.isEnabled) return;

    var n = new go.InputEvent();
    n.diagram = diagram;
    n.documentPoint = new go.Point(x, y);
    n.viewPoint = diagram.transformDocToView(n.documentPoint);
    n.timestamp = time;
    n.down = true;
    initializeEvent(n, eventprops);
    diagram.lastInput = n;
    diagram.firstInput = n.copy();
    diagram.currentTool.doMouseDown();
    };

/**

  • Simulate a mouse up event.

  • @param {number} x the X-coordinate of the mouse point in document coordinates.

  • @param {number} y the Y-coordinate of the mouse point in document coordinates.

  • @param {number=} time the timestamp of the simulated event, in milliseconds; default zero

  • @param {object=} eventprops an optional argument providing properties for the InputEvent.
    */
    function MouseUp(x, y, time, eventprops) {
    if (typeof x !== “number” || typeof y !== “number”) throw new Error(“MouseUp first two args must be X,Y numbers”);
    if (time === undefined) time = 0;

    if (!diagram.isEnabled) return;

    var n = new go.InputEvent();
    n.diagram = diagram;
    n.documentPoint = new go.Point(x, y);
    n.viewPoint = diagram.transformDocToView(n.documentPoint);
    n.timestamp = time;
    n.up = true;
    if (diagram.firstInput.documentPoint.equals(n.documentPoint)) n.clickCount = 1; // at least??
    initializeEvent(n, eventprops);
    diagram.lastInput = n;
    if (diagram.simulatedMouseUp(null, n.sourceDiagram, n.documentPoint, n.targetDiagram)) return;
    diagram.currentTool.doMouseUp();
    };

// Call MouseDown
MouseDown(arguments[0], arguments[1], 0, { });

// Call MouseUp
MouseUp(arguments[0], arguments[1], 100, { });