Noob question (1 month of coding):
I wanted to limit the number of videos clicked to only the first 3 (arbitrary number) videos.
I am able to run the code successfully but it will click on all videos. I'm ok with all the videos being opened in new tabs but I was just wondering if there was a way to limit the number of videos being opened.
I tried using loops but was unsuccessful.
Thanks in advance.
'''
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
# open URL
url = 'https://www.youtube.com/user/MegatoadStonie/videos'
driver = webdriver.Chrome()
driver.get(url)
# click on videos
links = driver.find_elements_by_xpath("//a[@id='video-title']")
for x in links:
x.send_keys(Keys.CONTROL,Keys.ENTER)
'''