I'm trying to get the watch urls of all uploaded videos in the video manager on YouTube. How do I select all videos on the page? I figured that the class name vm-video-title-content yt-uix-sessionlink
exists in the a
tag on every video but how can it be used to retrieve all of the href
attributes? I'm struggling with the selector.
This is the html snippet I'm basically dealing with:
<a href="/watch?v=THE_WATCH_ID" class="vm-video-title-content yt-uix-sessionlink" data-sessionlink="THE_SESSION_LINK_ID_OR_SOMETHING">THE_VIDEO_TITLE</a>
In Selenium
I tried doing
By videoSelector = By.className("vm-video-title-content.yt-uix-sessionlink");
List<WebElement> webElements = webDriver.findElements(videoSelector);
System.out.println(webElements.size());
but it prints a size of 0.
Note that I placed a dot in the class name since compound class names are not supported.
Is my approach promising or is there a better way of doing it?