There are many instances of the same class name. I'd like to click the first instance, pull the information I need from that page, go back to the previous page, click the second instance, pull the information I need, and so on until no more instances of the class name exist. Here's what I have so far, but I don't think I'm using the counter correctly.
elems = driver.find_elements(By.CLASS_NAME, 'XYZabc')
count = 1
data = []
for elem in elems:
if count <= 10:
#get text I'm clicking
data.append(elem.get_attribute('innerText'))
#click link
link = driver.find_element(By.CLASS_NAME, 'XYZabc').click()
count = count + 1
#get info from page
title = driver.find_element(By.XPATH,'//*[@id="main"]/div[1]/div/div/div/div/h1').get_attribute('innerText')
date = driver.find_element(By.CLASS_NAME, 'publish-date').get_attribute('innerText')
data.append({
"Title": title,
"Date": date
})
#go back to the first page
driver.back()
Any help/advice would be amazing! Thanks so much.