I am trying to get a list of titles after activating a search function but I keep getting an empty list even if the path is correct in finding the various iterations of h3 class titles. See below an example of where one title I am trying to copy is located in HTML. The class type changes every time but the position is always within h3.
So I tried with the code below to extract the list of titles:
import pandas as pd
from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager
from selenium.webdriver.firefox.options import Options
options = Options()
options.set_preference("dom.push.enabled", False)
browser = webdriver.Firefox(options=options)
browser.get("https://medium.com/search")
browser.find_element_by_xpath("//input[@type='search']").send_keys("Flying elephant",Keys.ENTER)
titles = browser.find_elements_by_xpath("//h3[contains(@class,'graf')]")
lista = []
for names in titles:
print(names.text)
lista.append(names.text)
browser.quit()
The code runs but the list I get back does not have any element. Thank you for any tips to help me with this