Answer the question
In order to leave comments, you need to log in
Why is Selenium script fetching data from the wrong page?
Here is my code:
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome(executable_path="H:\Pycharm projects\Web-driver\chromedriver.exe")
driver.get("https://www.youtube.com")
search_bar = driver.find_element(By.XPATH, """//input[@id = "search"]""")
search_bar.send_keys("gachi memes")
search_button = driver.find_element(By.XPATH, """//*[@id="search-icon-legacy"]""")
search_button.click()
video = driver.find_elements(By.ID, "video-title")
for i in range(len(video)):
print(video[i].text)
if i == 10:
break
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question