Clicking a youtube video element


I’m trying to create my first test robot what i’m trying to do is

Grab a name from my excel sheet: Eg:

Dua Lipa Future nostalgia
Dua Lipa - Break My Heart
Loud Luxury feat. Brando - Body
Justin Bieber - Ghost

Type it into youtube and search for the video, open the video and take the amount of views it has and write it back into the same excel.

I’m having trouble finding the element that works to “click” on the video since it always selects it as an unique and not an element

See my screenshot if I’m not clear enough. It works until the last step because it’s looking for a dua lipa video instead of the general element of a video (which I can’t find how to select)

In general, you want to avoid idx in the selectors. However, in this case you do really want to click the first song title in the list so the idx is ok to use.

It’s repeating the process for every title in the list, I can get it to work for one specific title but it doesn’t work for the others because the video is unique and not a general selectable element

Then you want to use a variable to store the idx value, and increment it each iteration of your loop.

Then make your selector dynamic:

<webctrl parentid='video-title' tag='YT-FORMATTED-STRING' idx='" + idxVar.ToString + "' />"

1 Like

Note that assuming you’re using a For Each you can just use the Index property to auto-increment for you. But it’s a zero-based index so your selector would have to be:

<webctrl parentid='video-title' tag='YT-FORMATTED-STRING' idx='" + (idxVar + 1).ToString + "' />"