Need Help - Youtube ADD COMMENT Element ID See description

I am in the process of building a bot that does the following.

  1. Asks for Input dialog on What is MY video about & What is the link to the video I am promoting
  2. It then opens a browser @
  3. Types in the search field my Variable created by Input Dialog on (step 1)
  4. Clicks search button
  5. Scrolls the page until it has at least 100 options
  6. Scraps data and puts this into an excel file (COLUMN 0 =URL of Youtube video) (COLUMN 1 = Name of Creator of video ) … I need this info because i do not want it to post to the same creator even if it finds multiple videos from that creator.
  7. Then it navigates to Youtube/(ListofURLS) row by row
  8. As it navigates it scrolls page just a bit so that the (Add public comment…) loads on the page

Steps 1-8 Work perfectly

Step 9. Clicks Add a public comment…
Step 10. Type into with my custom SPUN text that this message ( Video Link is from step 1 )
(“Hey “+YTnamesDT+”,This is some serious “+Adjative +SearchFor+”. I really enjoyed this video, thought I would see if you would be willing to check out my video.”+VideoLink+" It is not the most fancy “+SearchFor+” video but I have more coming just curious how people like my play, and tips are always appreciated as well! Mr. Joints")

The problem lies within step 9. it is having trouble selecting the Element. I have tried numerous things such as an Anchor Base Search for text and more… Here is an example of what you get when you pull that element

The problem here is I cannot use a wildcard in the name fields as when I do it cannot find the element at all and if thinks it did it starts clicking all over the place sending me to random pages.
All the ctrl Fields change so I cannot change just the titles and leave the IDX

Does anyone know the best way to solve this?
If you want to test your self.
Validate your Element for the Add public comment…
THEN go to another Youtube video and try to capture that same element.

I look forward to hearing from anyone that thinks they know the right answer


Have you tried “Click Image”?

1 Like

Wow this was real close it worked on the first Page which is a improvement
However when it scrolls down if its passes the Add comment area it is not able to find it
This box moves depending on some things going on with the page
but Wow it feels good to see it work once atleast :stuck_out_tongue:

As well this click image is way more stable it seems with clicking the search button thanks for that on all sorts of levels =P i was always aiming at elements with wildcards and such

It’s better to use elements because you can have them run in the background but there will be times when you have no choice but to use OCR. I’m glad I was able to help. :slight_smile:

Yeah I think I got it. I had to switch what you said to do.
Then i had to switch my scrolling feature from the keystroke END to keystroke PGDN so that it would not pass the element. If someones About video section is very large though i still cant see it so im going to put a Try catch statement in so that if it runs into that it will just skip that one. Curious question though
I need to save the NAMES from the scraped info in step 6 to seperate data table that will NOT be changed when i run this program again. I just want it to keep adding to that data table so that I dont double tap the same person on Youtube. Is the correct function to make this happen Add Data row?

Yes, use add Add Data Row. I use add row in situations like this to output the info in excel, I just put my variables within an array like this: {extractedName, ExtractedComment), the variables must be string type. The add row will place in colum 1 the first string in the array (ExtractedName) and ExtractedComment in colum 2 and so on. Also for the scroll problem you can use the Image exist activity which outputs a boolean value. Place it inside a do while and have it scroll down until it finds the image and place the click after the exit loop.

1 Like

Give this a try in just a moment. Your awesome thanks so much!

1 Like

I seem to be having trouble with the first part with the array not sure what I’m doing wrong do I need a write range?

Go to variables in Uipath and then change the scope for the variables to be able to get the info from were the info is coming from. Also, all variables must be of the same type. If they are Generic change them to String .

Hey Rmunro,

You have been awesome with the help you provided and many hours worth of watching youtube videos and reading on google. I have completed this bot. I am on the free edition and my understanding is that I can only have 2 bots. This bot was to make sure I could do anything I needed to which I can it just takes the right knowledge. I plan to delete this bot as I am fairly sure it will get my marked for spam if i officially activate it, Which could lead to being banned from youtube and I learn from youtube every day so do not want to lose that free resource of knowledge.
But I was in no way going to delete it before I could show the UI path community as hopefully someone else who wants to work with youtube content and can spark their imagination for what they are trying to do.
Time to start explaining

This bot was made for the purpose of Free marketing through a Commenting bot that would join youtube comments related to my content and say nice things to them and then leave a link ( links do not 100% Youtube has put a stop to links being put into Comments it will cause an error or at minimum make the content creator have to Approve your comment before it will be allowed to be viewed.)

  1. step in the process will involve getting the information that I want to work with into the bot
    This is done with an INPUT DIALOG activity
    It asks me What is my video about? - This is what goes into the Search field on youtube.
    It also asks me What is the link to the video I am trying to promote, This would be the link to my Youtube video.

The 2. step is to Open a new browser, I preferred to use Firefox for this as I use Chrome more often for myself and wanted my Bot to be working on a different area for setup reasons, etc…etc…
During this, it will also use a Type into the field for the search field and will input my response from INPUT DIALOG. Then it will use a Click Image command for the Search button ( previously I was using an Element Click and it would bug out every so often even with delays put in place, after switching to clock Image I never had the problem again

Step 3. gets a bit more advanced, As it is going to Scroll the page using a condition in a WHILE activity the Condition is Scroll<25 When the scroll is less than 25 it may stop. I scroll the page using a SEND HOTKEY activity. you have 3 options here to scroll down - Use the Down arrow key, Use the Page down key - Use the End key
This is how they react
Down arrow - Minimal movement page will only move a tiny bit.
Page down - Will move a pretty good distance almost half a window down
End key - This will scroll your screen down as far as it can go.
I used the End key as it allowed me to constantly make the page larger so when I extracted data I had a large amount to extract.

The Extracted Structure Data is an amazing Tool BUT it bugs out a bit on Firefox I had to do the initial setup of this Data Scrape from Chrome THEN switch the browser to Firefox within the activity. I am not sure why this is but it is what it is. SEE Picture below for important NOTES from extraction

Step 4 will load my PREVIOUS sent Comments and put them into a data table. Why I do this is because the top page of search results for youtube typically have the same persons content. I did not want to blow up 1 person with my comments so every time it sends out a comment it will store this information back in the excel list and reference to it before it starts up again If the name exists in the Data table it will SKIP that scraped data and move to the next to see if that one has the same name and so on till it finds a new target.UI%20Path%20-%20Youtube%20Bot%20-%20Step%204

Step 5 is where all the magic happens
It will first read the extracted data and put it into a temporary excel these get deleted every time you run the bot a new time. FOR EACH ROW in that Excel it will GET ROW ITEM twice one for Watch url on youtube and the other for the content creators name
It will repeat step 4 within the FOR EACH ROW this is there so that as the bot sends a comment it will check the NamesMaster excel file to make sure it has not just sent that person a comment.
It will then use an IF activity with the conditions that Commented already videos STRING contains the NAME string of the next target. This is done by turning my Master Names Data table to a long string to use in this condition. You would do this with an Output Data Table To see the Exact layout of the IF condition please check out the Snapshot as it will help to understand of how the code looks I am no programmer so this part took me a bit to get down.

Step 5.1
Add Data Row activity when the Condition is met in my IF activity what this does is it adds the Current scraped NAME as a string to the Data table that is currently holding the Master Commented already names. This is so that the name is added on its own.
right after this, it will use the Attached Browser that I’m currently in at this point and it will Navigate to “”+YTurlsSDT
YTurlsSDT is my string variable for the current scraped video I am on. I use a TRY CATCH activity
below this contained in the TRY area is a Do while activity the Condition is DidIFindtheCommentBox which will come back TRUE or FALSE depending on the Image exists which is looking for the Add a public comment…
The reason this is all in a Try catch command is that some people do not allow comments on there video when they do this the Image exists will never find the image because it is not there. Mainly this TRY CATCH works as skip over this one if you can’t find it. in the Type into activity once it finds and Clicks the Add a public comment… it uses this to write there a message

“Hey “+YTnamesDT+”,This is some serious “+Adjative +SearchFor+”. I really enjoyed this video, thought I would see if you would be willing to check out my video. “+VideoLink+” It is not the most fancy “+SearchFor+” video but I have more coming just curious how people like my play and tips are always appreciated as well! Mr. Joints”

This was designed to be a Spin text function definitely more complicated then it has to be but I did not want it sending multiple messages that are all the same with just the name changing.

Step 5.2
After all that it will Overwrite the Previous Master list names with the new Data table of Commented names. At this point, the data table contains all the same names as when previously opened and as well now it has the 1 additional name from whatever it just commented on.
Remember this is all in a FOR EACH ROW activity for the Scraped data. It will continue steps 5 - 5.2 until the Scraped data list is at the bottom.

That is pretty much to full bot. I currently did not have it send any comments because I would be building it but I would frequently test it to make sure it navigated correctly and typed into the comments correctly but it would skip hitting send till I was done with the building of the bot. Than after I finished it i decided I did not want to get banned for spamming, sooooo I’m not going to use it :upside_down_face: Either way it was really fun to build and it made me feel like I have a good understanding of how to build a UI Path that works with finicky websites like Youtube.

This Thread can now be closed as I no longer need help but I hope my post can help someone else out there!!

Mr. Joints

1 Like

Awesome work @MrJoints, I’m glad I was able to help. Great job! :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.