Forum Discussion

damieny's avatar
damieny
Occasional Contributor
15 years ago

Drag and drop of an item from a list box to another drop box area

Hello,



I have questions regarding the Drag and drop features of Test Complete.  We use Test Complete to test an application that developers use C# to designed and implemented.  The Drag of one item from a list box to another drop area causes problem when we minimize the app to half screen or change screen resolution (the distance from the list box to the drop area is different in length when the app is resized).  I know that Test Complete Click and Drag features are based on x,y coordination.  We need help to solve this kind of problem so we can execute the same test with different PC with different resolution.  There is no other way except to drag the desired item from the list on the right screen to the drop box area on the left side of the screen.  Is there a function to return the x and y value (coordination) on the fly when an object had been clicked?



Hope that you will have a suggestion/idea how to solve this problem.



Thanks,





DY

3 Replies

  • karkadil's avatar
    karkadil
    Valued Contributor
    Every onscreen object has several properties which will be useful in your case:


    • Left, Top - coordinates of the left and top bounds object within a parent control

    • Height, Width - this should be obvious

    • ScreenLeft, ScreenTop - absolute coordinates on the screen




    Using these coordinates you should be able to calculate distance between the objects and perform drag-n-drop operation.
  • damieny's avatar
    damieny
    Occasional Contributor
    Hi Gennadiy,



    Could you point me to these Test Complete functions to return the point coordination.  I tried to use built in function with TC but it didn't work.  Maybe my syntax was wrong or use the wrong function.



    Thanks,





    DY

  • karkadil's avatar
    karkadil
    Valued Contributor
    They are not functions, but properties of any onscreen object.



    Here is an example. In this function we are performing drag-n-drop of the button "4" in Calculator Plus onto the button "6". Of course, the button will not be really moved since it can't be moved by design, but I believe you'll get the idea.




    function DragDropDemo()

    {

      wCalc = Sys.Process("CalcPlus").Window("SciCalc", "Calculator Plus", 1);

      wCalc.Activate();

      btn4 = wCalc.Window("Button", "4");

      btn6 = wCalc.Window("Button", "6");

      

      deltaX = btn6.Left - btn4.Left;

      btn4.Drag(btn4.Width/2, btn4.Height/2, deltaX, 0);

    }


    You should download Calculator Plus application from Microsoft download site if you'd like to run this function.