dragAndDropTo macro complete but nothing happens

Hi, I have a problem with the drag & drop command.
I want to add a song to a playlist with the command dragAndDropTo.
If I run my macro on Spotify, Kantu tells me that it has executed all the commands correctly, but the song is not added to the playlist. I can’t understand the reason and why there are no errors in the logs window.

{
  "Name": "Drag&drop",
  "CreationDate": "2019-11-27",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://accounts.spotify.com/it/login?continue=https:%2F%2Fopen.spotify.com%2F",
      "Value": ""
    },
    {
      "Command": "clickAndWait",
      "Target": "link=Accedi con Facebook",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"main\"]/div/div[4]/div[1]/nav/div[2]/div/div/div/button/span",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"main\"]/div/div[4]/div[1]/nav/div[2]/div/div/div/button/span",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "xpath=//*[@id=\"main\"]/div/div[5]/div/div[1]/div/div/input",
      "Value": "Plist"
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"main\"]/div/div[5]/div/div[2]/div[2]/button",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"main\"]/div/div[4]/div[1]/nav/ul/li[2]/div/a/div/span",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"searchPage\"]/div/div[1]/label/input",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "xpath=//*[@id=\"searchPage\"]/div/div[1]/label/input",
      "Value": "Ace of Spades"
    },
    {
      "Command": "dragAndDropToObject",
      "Target": "xpath=//*[@id=\"searchPage\"]/div/div[2]/section[1]/div/div[2]/div/div",
      "Value": "link=Plist"
    }
  ]
}

It has ever happened to anyone? Can anyone help me?
Thanx :grinning:

The native Selenium IDE drag and drop commands fail often if the page is more complex. What I use as solution is to do drag and drop with the XMove command:

  • XMove (old position)
  • XMove (old position) | #down
  • XMove (new position)
  • XMove (new position) | #up

This is slower, but it works with all kinds of pages. It works similar to the canvas drawing demo in DemoXClick.

1 Like

Thank you very much Plankton, with xMove everything works very well now!

Hi

Xmove can work with regular selenium xpath ?

I tried without success.

Can you post an example of xmove with xpath (not image) please ?

Thanks

XMove can use XPath just like XClick can. There is no difference. The logic is always:

  • Find element with XPath (or ID=… or any other Selenium IDE selector)
  • Get the x/y of the middle of this element
  • Simulate a mouse move to x/y

Demo: => The text turns red as the mouse is moved over it by XMove.

Macro used is:

{
  "Name": "xmove",
  "CreationDate": "2020-10-9",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onmouseover_html",
      "Value": ""
    },
    {
      "Command": "selectFrame",
      "Target": "id=iframeResult",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=/html/body/p",
      "Value": ""
    },
    {
      "Command": "comment",
      "Target": "click // id=demo",
      "Value": ""
    },
    {
      "Command": "XMove",
      "Target": "id=demo",
      "Value": ""
    }
  ]
}

Thank you but still can not understand how xmove works and if it can move objects in the screen yet I have not found an example of how xmove moves objects in the screen and very few examples that I saw work with images but I have not seen any examples with dragAndDrop with xpath.

The example here not working because domain was expired

https://ui.vision/rpa/docs/selenium-ide/draganddroptoobject

Can you update with a working domain dragAndDropToObject Example please ?

At the moment I still can’t figure out how xmove works with xpath and I don’t find adequate explanation anywhere.

I updated the demo URL to HTML5 Demo: Drag and drop

The DemoDragDrop macro shows how to to drag and drop with XPath only. Of course, this only works if the element(s) you want to drag and drop can be identified by Xpath or ID:

{
  "Name": "DemoDragDrop",
  "CreationDate": "2020-10-9",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://ui.vision/demo/webtest/dragdrop/",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "Reduce replay speed so we can better see what is going on...",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "medium",
      "Value": "!replayspeed"
    },
    {
      "Command": "dragAndDropToObject",
      "Target": "id=one",
      "Value": "id=bin"
    },
    {
      "Command": "dragAndDropToObject",
      "Target": "id=two",
      "Value": "id=bin"
    },
    {
      "Command": "dragAndDropToObject",
      "Target": "id=three",
      "Value": "id=bin"
    },
    {
      "Command": "dragAndDropToObject",
      "Target": "id=four",
      "Value": "id=bin"
    },
    {
      "Command": "dragAndDropToObject",
      "Target": "id=five",
      "Value": "id=bin"
    }
  ]
}
1 Like

Thanks admin

You were very nice, I tried the macro code that you indicated and it works, unfortunately in the site where I care does not work.

You can convert the dragAndDropToObject command to Xmove always using xpath ?

I can’t figure out how xpath how I can calculate var x and var y for coordinates.

Thank you