Win App Driver中的动作MoveByOffset:如何查看或放慢速度?

时间:2018-11-22 15:20:07

标签: winappdriver

我有下面的代码,它确实从一个位置拖放到另一个位置,但它不是正确的位置。如何减慢速度或查看其运行状况?我在CodedUI和Mouse.StartDragging等中使用过Mouse.Move,您可以设置速度并查看它们的作用,并在需要时进行更正。用于将画布上的某些内容拖动到画布上的其他项目,以便与位置相关。

我知道我会在某个时候到达那里,PMeter是一个很好的工具,可以用来在这里为您提供帮助,但是我希望能够看到我有时在做的调试工作。

        Actions builder = new Actions(session);
        builder.MoveByOffset(100, -85);
        builder.ClickAndHold();
        builder.MoveByOffset(gridPos2.X - gridPos1.X, gridPos2.Y - gridPos1.Y);
        builder.Release();
        builder.Perform();

2 个答案:

答案 0 :(得分:0)

如果您想知道鼠标指向何处,只需在 Inspection 程序中选择“显示高亮矩形” 。在所附的图像中,您会发现已选中的选项。

答案 1 :(得分:0)

我创建了一种方法来显示光标以您选择的颜色闪烁...

    /// <summary>
    /// This method is useful for seeing what the cursor is doing. **Call it like this...**
    /// CommonMethods.HighlightCursor(new System.Drawing.Pen(System.Drawing.Color.Red));
    /// </summary>
    /// <param name="colour"></param>
    public static void HighlightCursor(Pen colour)
    {
        for (int i = 0; i < 10; i++)
        {
            Point pt = Cursor.Position; // Get the mouse cursor in screen coordinates
            using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
            {
                g.DrawEllipse(colour, pt.X - 5, pt.Y - 5, 10+i, 10+i);
            }

            Thread.Sleep(150);
        }
    }