Loop enter and do action for elements / links

Hi would you please help , I’m able to do the whole action but not able to do it for the next element / links in search result

when I’m doing loop for example 5 times I;m geting action for first item 5 times not same action for the 5 results

{
“Name”: “youtube.com”,
“CreationDate”: “2020-8-7”,
“Commands”: [
{
“Command”: “store”,
“Target”: “true”,
“Value”: “!errorignore”
},
{
“Command”: “bringBrowserToForeground”,
“Target”: “”,
“Value”: “”
},
{
“Command”: “open”,
“Target”: “https://www.youtube.com/results?search_query=aa”,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “0”,
“Value”: “Loop_Counter”
},
{
“Command”: “label”,
“Target”: “Macro_Code”,
“Value”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return Number ({Loop_Counter}) + 1", "Value": "Loop_Counter" }, { "Command": "click", "Target": "xpath=//*[@id=\"video-title\"]/yt-formatted-string", "Value": "", "Targets": [ "xpath=//*[@id=\"video-title\"]/yt-formatted-string", "xpath=//a/yt-formatted-string", "css=#video-title > yt-formatted-string" ] }, { "Command": "waitForPageToLoad", "Target": "3000", "Value": "" }, { "Command": "XType", "Target": "{KEY_BKSP}{KEY_BACKSPACE}{KEY_BACKSPACE}{KEY_BACKSPACE}{KEY_BACKSPACE}”,
“Value”: “”
},
{
“Command”: “XType”,
“Target”: “{KEY_BKSP}{KEY_BACKSPACE}{KEY_BACKSPACE}{KEY_BACKSPACE}{KEY_BACKSPACE}", "Value": "" }, { "Command": "XType", "Target": "{KEY_BKSP}”,
“Value”: “”
},
{
“Command”: “XType”,
“Target”: “{KEY_BACKSPACE}", "Value": "" }, { "Command": "XType", "Target": "{KEY_PGDN}”,
“Value”: “”
},
{
“Command”: “XType”,
“Target”: “{KEY_BKSP}", "Value": "" }, { "Command": "waitForPageToLoad", "Target": "3000", "Value": "" }, { "Command": "waitForPageToLoad", "Target": "3000", "Value": "" }, { "Command": "XType", "Target": "{KEY_BKSP}”,
“Value”: “”
},
{
“Command”: “XType”,
“Target”: “${KEY_BACKSPACE}”,
“Value”: “”
}
]
}

What do you want to do with this macro?

Why did you use xtype and desktop automation instead of selenium commands?

Hi I use xtype to scroll down and scrap comments

all the function work good for me but the problem is the macro just enter to first video in search result and if I make loop it’s getting same comments to same first video in the result ,

but I need to enter each video ! thnaks

Hi

You used a part of my old code and you make some error in macro code.

I upgraded in better way the macro now can views unlimited video in easy way, i added notify to with loop number and macro finished message.

To use this macro you must buy paid version because free version can execute only 25 xtype/xclick per execution of macro/test suite (max 25 xclick/xtype in log of execution macro).

Next time please do not paste part of code, you used a part of code that was not needed for this job so I removed it.

Here macro code

{
  "Name": "Youtube_Video_Viewer",
  "CreationDate": "2020-8-8",
  "Commands": [
    {
      "Command": "store",
      "Target": "true",
      "Value": "!errorignore"
    },
    {
      "Command": "bringBrowserToForeground",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "open",
      "Target": "https://www.youtube.com/results?search_query=cash",
      "Value": ""
    },
    {
      "Command": "times",
      "Target": "5",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=(//*[@id=\"video-title\"]/yt-formatted-string)[${!TIMES}]",
      "Value": ""
    },
    {
      "Command": "waitForPageToLoad",
      "Target": "3000",
      "Value": ""
    },
    {
      "Command": "XType",
      "Target": "{KEY_BKSP}{KEY_BACKSPACE}{KEY_BACKSPACE}{KEY_BACKSPACE}{KEY_BACKSPACE}",
      "Value": ""
    },
    {
      "Command": "XType",
      "Target": "{KEY_BKSP}{KEY_BACKSPACE}{KEY_BACKSPACE}{KEY_BACKSPACE}{KEY_BACKSPACE}",
      "Value": ""
    },
    {
      "Command": "XType",
      "Target": "{KEY_BKSP}",
      "Value": ""
    },
    {
      "Command": "XType",
      "Target": "{KEY_BACKSPACE}",
      "Value": ""
    },
    {
      "Command": "XType",
      "Target": "{KEY_PGDN}",
      "Value": ""
    },
    {
      "Command": "XType",
      "Target": "{KEY_BKSP}",
      "Value": ""
    },
    {
      "Command": "waitForPageToLoad",
      "Target": "3000",
      "Value": ""
    },
    {
      "Command": "waitForPageToLoad",
      "Target": "3000",
      "Value": ""
    },
    {
      "Command": "XType",
      "Target": "{KEY_BKSP}",
      "Value": ""
    },
    {
      "Command": "XType",
      "Target": "${KEY_BACKSPACE}",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "Loop Number ${!TIMES} Completed",
      "Value": "#shownotification"
    },
    {
      "Command": "end",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "Macro Finished",
      "Value": "#shownotification"
    }
  ]
}

thanks for help I bought pro

1 Like

Mark this post wuth the solution button please