Forum Discussion

Veroniquelu's avatar
Veroniquelu
Contributor
10 years ago

Drag and Drop without using cordinate system

Hi All,

I wanted to Drag a web Object to and Drop it to another web Object, is there any way that i can do it without using this cordinate system? Or I can find the object and press my left mouse and release it when the mouse is over on the target object? 

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    You can use this function to drag an object to another object:

     

    // JScript

    // Drags the source object to the specified destination object
    function DragToObject(source, destination) { var point1 = source.WindowToScreen(source.Width/2, source.Height/2); var point2 = destination.WindowToScreen(destination.Width/2, destination.Height/2); source.Drag(source.Width/2, source.Height/2, point2.X - point1.X, point2.Y - point1.Y); }

    Here's a demo for the http://html5demos.com/drag page:

     

    function DragDropTest()
    {
      var strUrl = "http://html5demos.com/drag";
      Browsers.Item(btIExplorer).Run(strUrl);
      var page = Sys.Browser().Page(strUrl);
    
      // Drag&drop "two" into the trash bin
      var item = page.FindChildByXPath("//a[@id='two']");
      var trash = page.FindChildByXPath("//div[@id='bin']");
    
      DragToObject(item, trash);
    }
    • Veroniquelu's avatar
      Veroniquelu
      Contributor

      I found "<a title="" class="jstree-anchor jstree-clicked" href="#"><i class="jstree-icon jstree-themeicon jstree-themeicon-custom" style='background-position: center; background-image: url("/Images/treeView/icon_book_black.png"); background-size: auto;'></i>course1</a>" object

      But it says it doesn't support this method..

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        How did you search for the object?

        Can you provide us with your actual code, exact line of error and the error text iteself?