2

I have the code below and it does drag and drop from a position to another position but it't not exactly the correct position. How can I slow it down or see what it's doing? I have used Mouse.Move in CodedUI and Mouse.StartDragging etc and you can set the speed and see what they're doing and correct them if required. It's for dragging something on a canvas to another item on a canvas so it is related to position.

I know I'll get there at some point and PMeter is a great tool to use to help you here but I'd like to be able to see what I'm doing sometimes to debug.

        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();
Ewan
  • 541
  • 8
  • 23
  • My session is a WPF session btw. WindowsDriver session – Ewan Nov 22 '18 at 15:20
  • I had my mouse properly dragging an element.. but it's stopped working. MoveByOffset basically teleports the mouse, instead of actually moving it.. :\ – jfaron May 01 '20 at 16:25

2 Answers2

0

if you want to know where is pointing the mouse just select 'show highlight rectangle' in Inspection program. In attached image you'll find the option remarked.

0

I created a method for showing the cursor flashing in a colour of your choice...

    /// <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);
        }
    }
Ewan
  • 541
  • 8
  • 23