My for loop only seems to only find the first item from https://public.tableau.com/en-gb/gallery/?tab=viz-of-the-day&type=viz-of-the-day instead of looping through all dates and titles. If I print(viz) I can see different elements, but that doesn't seem to be carried through.
driver.get("https://public.tableau.com/en-gb/gallery/?tab=viz-of-the-day&type=viz-of-the-day")
wait = WebDriverWait(driver, 10)
time.sleep(10)
vizzes = wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, ".gallery-items-list div.gallery-list-item-container")))
for viz in vizzes:
print(viz)
#publish date
date_id = driver.find_element_by_css_selector('[data-test-id="published-date"]').text
print(date_id)
#name of the viz
viz_name = driver.find_element_by_xpath("//a[contains(@href, '/en-gb/gallery/')]").text
print(viz_name)
For xpath I tried using
viz_name = driver.find_element_by_xpath(".//a[contains(@href, '/en-gb/gallery/')]").text
and
viz_name = driver.find_element_by_xpath("//*[contains(@href, '/en-gb/gallery/')]").text
which yielded the same result.
date_id = driver.find_element_by_css_selector('[data-test-id="published-date"]').textdoesn't referencevizanywhere, so of course it returns the same thing every time