SAPUI5 OPA5测试拖放(理想情况下,没有外部库)

时间:2018-09-25 08:04:39

标签: javascript jquery jquery-ui testing sapui5

我正在寻求有关SAPUI5拖放测试主题的帮助。

假设我有sap.m.Table,我想在其中更改元素的顺序。接下来是配置:

<Table id="attributeList" mode="MultiSelect" itemPress="handleAttributeSelect"
    items="{path: 'state>attributes', sorter: {path : 'properties/order', descending: true}}">
    <dragDropConfig>
         <dnd:DragInfo groupName="attributesList" sourceAggregation="items"/>
         <dnd:DropInfo id="" groupName="attributesList" drop="onDropAttributeInList"
              targetAggregation="items" dropPosition="Between"/>
    </dragDropConfig>

我尝试jquery-simulate在下一个重要部分中实施测试方案

1)Index.html(测试的开始文件)

<script src="./thirdparty/jquery-simulate.js"></script>

<script>
     sap.ui.require([
        "jquery.sap.global",
        "sap/ui/test/gherkin/opa5TestHarness",
        // Code coverage will be calculated for all modules loaded after the harness
        "test/Steps",
        "test/arrangements/Frame",
        "test/pages/Object",
        "test/pages/tabs/Properties",
        "test/pages/tabs/Attributes",
        "test/pages/Worklist",
        "sap/ui/thirdparty/jqueryui/jquery-ui-core",
        "sap/ui/thirdparty/jqueryui/jquery-ui-widget",
        "sap/ui/thirdparty/jqueryui/jquery-ui-mouse",
        "sap/ui/thirdparty/jqueryui/jquery-ui-draggable",
        "sap/ui/thirdparty/jqueryui/jquery-ui-droppable"
    ], function ($, opa5TestHarness, Steps, Arrangement) {

2)opa5部分:

  iDragAndDropTheRowOfTheTable: function (sTableId, iDragStartPosition, iDragEndPosition) {
        return this.waitFor({
            autoWait: 3000,
            id: sTableId,
            success: function (oTable) {
                var oDraggable = $(oTable.getItems()[iDragStartPosition].getDomRef()).draggable(),
                    oDroppable = $(oTable.getItems()[iDragEndPosition].getDomRef()).droppable(),

                    sDyProperty = (iDragStartPosition > iDragEndPosition) ? "bottom" : "top",

                    iDraggableOffset = oDraggable.offset(),
                    iDroppableOffset = oDroppable.offset(),

                    iDx = iDroppableOffset.left - iDraggableOffset.left,
                    iDy = iDroppableOffset[sDyProperty] - iDraggableOffset[sDyProperty];

                oDraggable.simulate("drag", {dx: iDx, dy: iDy, handle: "corner"});
            }
        });
    }

在每种测试方案中,我都有3行的表,并且有4种测试:

1)将第一个拖放到非最后一个之后

2)将第一个拖放到最后一个之后

3)最后拖动,然后拖放到非第一个

4)最后拖放,然后先拖放

因此,在第一个测试中,我交换第1行和第2行。作为当前结果,我将第一行高亮显示,就像在鼠标按下后一样,但是没有拖动。这是我需要帮助的部分。

0 个答案:

没有答案