Kantu don't recognize button in browser mode

Hi, I’m working on this macro to create a playlist on spotify and add a song to the playlist.
The macro executes the login well, creates the new playlist, searches for the song to add, selects it to add it to the playlist, but the last click to assign the track to the playlist is done correctly by the console, but is not heard by the browser, and it is no longer heard even if I do it directly.
At this point if I manually do the same procedure of adding the track to the playlist, everything goes ok and now if I start the macro from add to playlist, everything goes ok and the browser hears the click that it didn’t hear before.
Does anyone know why?
This is the link to the csv file

This is the code:

{
  "Name": "Plist error",
  "CreationDate": "2019-11-22",
  "Commands": [
    {
      "Command": "comment",
      "Target": "https://open.spotify.com/browse/featured",
      "Value": ""
    },
    {
      "Command": "open",
      "Target": "https://accounts.spotify.com/it/login?continue=https:%2F%2Fopen.spotify.com%2Fbrowse%2Ffeatured",
      "Value": ""
    },
    {
      "Command": "comment",
      "Target": "read csv",
      "Value": ""
    },
    {
      "Command": "csvRead",
      "Target": "SpotifyDataTestCopy.csv",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "id=login-username",
      "Value": "${!COL1}"
    },
    {
      "Command": "type",
      "Target": "id=login-password",
      "Value": "${!COL2}"
    },
    {
      "Command": "comment",
      "Target": "login",
      "Value": ""
    },
    {
      "Command": "clickAndWait",
      "Target": "id=login-button",
      "Value": ""
    },
    {
      "Command": "comment",
      "Target": "create playlist",
      "Value": ""
    },
    {
      "Command": "clickAt",
      "Target": "xpath=//*[@id=\"main\"]/div/div[4]/div[1]/nav/div[2]/div/div/div/button/span",
      "Value": "16,10"
    },
    {
      "Command": "csvRead",
      "Target": "SpotifyDataTestCopy.csv",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "xpath=//*[@id=\"main\"]/div/div[5]/div/div[1]/div/div/input",
      "Value": "${!COL3}"
    },
    {
      "Command": "clickAt",
      "Target": "xpath=//*[@id=\"main\"]/div/div[5]/div/div[2]/div[2]/button",
      "Value": "47,18"
    },
    {
      "Command": "comment",
      "Target": "search song",
      "Value": ""
    },
    {
      "Command": "clickAt",
      "Target": "xpath=//*[@id=\"main\"]/div/div[4]/div[1]/nav/ul/li[2]/div/a/div/span",
      "Value": "23,11"
    },
    {
      "Command": "csvRead",
      "Target": "SpotifyDataTestCopy.csv",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "xpath=//*[@id=\"searchPage\"]/div/div[1]/label/input",
      "Value": "${!COL4}"
    },
    {
      "Command": "clickAt",
      "Target": "xpath=//*[@id=\"searchPage\"]/div/div[2]/section[1]/div/div[2]/div/div/div/div[4]",
      "Value": "88,89"
    },
    {
      "Command": "comment",
      "Target": "add to playlist",
      "Value": ""
    },
    {
      "Command": "clickAt",
      "Target": "xpath=//*[@id=\"main\"]/div/div[4]/div[3]/footer/div/div[3]/div/div/div[1]/div/button",
      "Value": "16,18"
    },
    {
      "Command": "clickAt",
      "Target": "xpath=//*[@id=\"main\"]/div/div[4]/div[2]/div[1]/div/div/section/div/section/ol/div/div/li/div[3]/div/div/button/div",
      "Value": "24,16"
    },
    {
      "Command": "clickAt",
      "Target": "xpath=//*[@id=\"main\"]/div/nav[1]/div[4]",
      "Value": "142,14"
    },
    {
      "Command": "clickAt",
      "Target": "css=#main > div > div.dialog.dialog--without-background > div > div > div > div.container-fluid.container-fluid--noSpaceAround > div > div > div > div > div > div > div > div.react-contextmenu-wrapper > div > div:nth-child(2) > div > svg",
      "Value": "12,9"
    }
  ]
}

Never use clickAt with coordinates use simple click with xpath without any coordinate.

1 Like

thank you so much for your answer. I changed all the clickAt commands with simple click using the xpath as you suggested, but now there is an error with the last command, probably I have made an error for add the xpath. If you want you can use the csv attached to my first post to do a test and check by yourself. Here is the code I have try to correct according as your indications.
Thanks again

{
  "Name": "Plist error",
  "CreationDate": "2019-11-23",
  "Commands": [
    {
      "Command": "comment",
      "Target": "https://open.spotify.com/browse/featured",
      "Value": ""
    },
    {
      "Command": "open",
      "Target": "https://accounts.spotify.com/it/login?continue=https:%2F%2Fopen.spotify.com%2Fbrowse%2Ffeatured",
      "Value": ""
    },
    {
      "Command": "comment",
      "Target": "read csv",
      "Value": ""
    },
    {
      "Command": "csvRead",
      "Target": "SpotifyDataTestCopy.csv",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "id=login-username",
      "Value": "${!COL1}"
    },
    {
      "Command": "type",
      "Target": "id=login-password",
      "Value": "${!COL2}"
    },
    {
      "Command": "comment",
      "Target": "login",
      "Value": ""
    },
    {
      "Command": "clickAndWait",
      "Target": "id=login-button",
      "Value": ""
    },
    {
      "Command": "comment",
      "Target": "create playlist",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"main\"]/div/div[4]/div[1]/nav/div[2]/div/div/div/button/span",
      "Value": ""
    },
    {
      "Command": "csvRead",
      "Target": "SpotifyDataTestCopy.csv",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "xpath=//*[@id=\"main\"]/div/div[5]/div/div[1]/div/div/input",
      "Value": "${!COL3}"
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"main\"]/div/div[5]/div/div[2]/div[2]/button",
      "Value": ""
    },
    {
      "Command": "comment",
      "Target": "search song",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"main\"]/div/div[4]/div[1]/nav/ul/li[2]/div/a/div/span",
      "Value": ""
    },
    {
      "Command": "csvRead",
      "Target": "SpotifyDataTestCopy.csv",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "xpath=//*[@id=\"searchPage\"]/div/div[1]/label/input",
      "Value": "${!COL4}"
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"searchPage\"]/div/div[2]/section[1]/div/div[2]/div/div/div/div[4]",
      "Value": ""
    },
    {
      "Command": "comment",
      "Target": "add to playlist",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"main\"]/div/div[4]/div[3]/footer/div/div[3]/div/div/div[1]/div/button",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"main\"]/div/div[4]/div[2]/div[1]/div/div/section/div/section/ol/div/div/li/div[3]/div/div/button/div",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"main\"]/div/nav[1]/div[4]",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"main\"]> div > div.dialog.dialog--without-background > div > div > div > div.container-fluid.container-fluid--noSpaceAround > div > div > div > div > div > div > div > div.react-contextmenu-wrapper > div > div:nth-child(2) > div > svg",
      "Value": ""
    }
  ]
}

Please edit the post and use the code so it formats correctly so we can copy/paste it in and test.

2 Likes

Thank you very much for your advice, and sorry for my shortcomings, now I have found how to format the code correctly and I have edit the posts.
Thank you all for your advices.

Try to use a better xpath recognizer addon

Read here

Xpath works great but since Spotify is such a large site and I’m sure changes often, try to stay away from absolute xpath and try to use other selectors that wouldn’t change as much. For example in your “create playlist” section you have this to click the “Create Playlist” button:

xpath=//*[@id="main"]/div/div[4]/div[1]/nav/div[2]/div/div/div/button/span

I would change it to this:

//*[text()='Create Playlist']

you then type your data into “New Playlist” box in which you have this:

xpath=//*[@id="main"]/div/div[5]/div/div[1]/div/div/input

I would change it to this:

//input[@placeholder='New Playlist']

It then clicks the “create” button:

xpath=//*[@id="main"]/div/div[5]/div/div[2]/div[2]/button

I would use:

//*[text()='CREATE PLAYLIST']

You have to go through every step but doing so will make your macro much less resistant to breaks whenever changes are made to sites.

2 Likes

Your is a good tips !

thank you so much it’s a good trick. The last click command that assigns the track to the newly created playlist has no effect. The console says that the command is executed correctly, but nothing happens to the video on browser. I can’t understand why.