【问题标题】:Using gojs for UI automation使用 gojs 实现 UI 自动化
【发布时间】:2018-12-11 01:11:46
【问题描述】:

是否有关于如何彻底使用 gojs 进行 UI 自动化的文档?我只想将托盘上的控件拖放到画布上以创建流程图。请帮忙。我只需要指向一个教程或参考即可开始。

【问题讨论】:

  • 要求我们推荐或查找书籍、工具、软件库、教程或其他场外资源的问题对于 Stack Overflow 来说是无关紧要的,因为它们往往会吸引固执己见的答案和垃圾邮件。相反,describe the problem 以及迄今为止为解决它所做的工作。

标签: selenium-webdriver automated-tests selenium-chromedriver gojs


【解决方案1】:

我不确定您到底想要什么,但是您是否使用 Robot 类来模拟用户输入? https://gojs.net/latest/extensions/Robot.html

// a shared Robot that can be used by all commands for this one Diagram
robot = new Robot(myDiagram);  // defined in Robot.js

然后可以进行如下操作:

function clickLambda() {
    var lambda = myDiagram.findNodeForKey("Lambda");
    if (lambda === null) return;
    var loc = lambda.location;

    // click on Lambda
    robot.mouseDown(loc.x + 10, loc.y + 10, 0, { });
    robot.mouseUp(loc.x + 10, loc.y + 10, 100, { });

    // Clicking is just a sequence of input events.
    // There is no command in CommandHandler for such a basic gesture.
}

或:

function dragFromPalette() {
    // simulate a drag-and-drop between Diagrams:
    var dragdrop = { sourceDiagram: myPalette, targetDiagram: myDiagram };
    robot.mouseDown(5, 5, 0, dragdrop); // this should be where the Alpha node is in the source myPalette
    robot.mouseMove(60, 60, 100, dragdrop);
    robot.mouseUp(100, 100, 200, dragdrop); // this is where the node will be dropped in the target myDiagram

    // If successful in dragging a node from the Palette into the Diagram,
    // the DraggingTool will perform a transaction.
}

【讨论】:

    【解决方案2】:

    使用 chrome 浏览器并选择加载 GoJ 的框架。 使用控制台并选择 mainGoJs 图表名称。

    我们在 Selenium Java 文件中使用以下 JavaScriptExecutor 来自动化 GoJs 组织结构图。

    ((JavascriptExecutor) driver).executeScript(""
            + "for(let i = 0; i <"+count+"; i++)"
            + "{"
            + "var key= dgmOrganizationUnit.model.nodeDataArray[i].key;"
            + "var node = dgmOrganizationUnit.findNodeForKey(key);"
            + "var ntxt= node.text; "
            + "if (ntxt==='"+ parentname+"')"
            + "{"
            + "dgmOrganizationUnit.centerRect(node.actualBounds);"
            + "dgmOrganizationUnit.select(node);"
            + "}"
            + "}"
            );
    

    dgmOrganizationUnit 是主要的 GoJs ORG 单元框架容器。在 chrome DevTools“控制台”上输入您的应用程序中可用的类似名称,您会看到所有参数都弹出。

    【讨论】:

      猜你喜欢
      • 2017-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-10
      • 2021-09-28
      • 2018-11-27
      • 2016-11-27
      相关资源
      最近更新 更多